refactoring: reducing code duplication

This commit is contained in:
rusefi 2018-07-24 19:58:32 -04:00
parent 9cce922b78
commit 1b1d2b16ee
6 changed files with 9 additions and 9 deletions

View File

@ -830,7 +830,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
{
float instantRpm = engine->triggerCentral.triggerState.instantRpm;
tsOutputChannels->debugFloatField1 = instantRpm;
tsOutputChannels->debugFloatField2 = instantRpm / engine->rpmCalculator.rpmValue;
tsOutputChannels->debugFloatField2 = instantRpm / GET_RPM();
}
break;
default:

View File

@ -222,7 +222,7 @@ void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
}
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int rpm = engine->rpmCalculator.rpmValue;
int rpm = GET_RPM();
if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map;
angle_t start = interpolate2d("mapa", rpm, c->samplingAngleBins, c->samplingAngle, MAP_ANGLE_SIZE);
@ -256,7 +256,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
return;
engine->m.beforeMapAveragingCb = GET_TIMESTAMP();
int rpm = ENGINE(rpmCalculator.rpmValue);
int rpm = GET_RPM();
if (!isValidRpm(rpm)) {
return;
}
@ -317,7 +317,7 @@ float getMap(void) {
}
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
if (!isValidRpm(engine->rpmCalculator.rpmValue) || currentPressure == NO_VALUE_YET)
if (!isValidRpm(GET_RPM() || currentPressure == NO_VALUE_YET)
return validateMap(getRawMap()); // maybe return NaN in case of stopped engine?
return validateMap(currentPressure);
#else

View File

@ -40,7 +40,7 @@ static void auxValveTriggerCallback(trigger_event_e ckpSignalType,
if (index != SCHEDULING_TRIGGER_INDEX) {
return;
}
int rpm = ENGINE(rpmCalculator.rpmValue);
int rpm = GET_RPM();
if (!isValidRpm(rpm)) {
return;
}

View File

@ -313,7 +313,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
InjectorOutputPin *output = event->outputs[0];
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
printf("fuelout %s duration %d total=%d\t\n", output->name, (int)durationUs,
(int)MS2US(getCrankshaftRevolutionTimeMs(ENGINE(rpmCalculator.rpmValue))));
(int)MS2US(getCrankshaftRevolutionTimeMs(GET_RPM())));
#endif /*EFI_PRINTF_FUEL_DETAILS */

View File

@ -425,7 +425,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
}
if (!isValidIndex(PASS_ENGINE_PARAMETER_SIGNATURE) && !isInitializingTrigger) {
// let's not show a warning if we are just starting to spin
if (engine->rpmCalculator.rpmValue != 0) {
if (GET_RPM() != 0) {
warning(CUSTOM_SYNC_ERROR, "sync error: index #%d above total size %d", currentCycle.current_index, TRIGGER_SHAPE(size));
lastDecodingErrorTime = getTimeNowNt();
someSortOfTriggerError = true;

View File

@ -234,7 +234,7 @@ static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE
return;
engine->m.beforeHipCb = GET_TIMESTAMP();
int rpm = engine->rpmCalculator.rpmValue;
int rpm = GET_RPM();
if (!isValidRpm(rpm))
return;
@ -303,7 +303,7 @@ void hipAdcCallback(adcsample_t value) {
prepareHip9011RpmLookup(currentAngleWindowWidth);
}
int integratorIndex = getIntegrationIndexByRpm(engine->rpmCalculator.rpmValue);
int integratorIndex = getIntegrationIndexByRpm(GET_RPM());
int gainIndex = getHip9011GainIndex(boardConfiguration->hip9011Gain);
int bandIndex = getBandIndex();
int prescalerIndex = engineConfiguration->hip9011PrescalerAndSDO;