refactoring

This commit is contained in:
rusefi 2020-09-03 19:29:15 -04:00
parent c584e0d386
commit ca21d5b4c2
13 changed files with 21 additions and 21 deletions

View File

@ -841,7 +841,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
{
float instantRpm = engine->triggerCentral.triggerState.instantRpm;
tsOutputChannels->debugFloatField1 = instantRpm;
tsOutputChannels->debugFloatField2 = instantRpm / GET_RPM_VALUE;
tsOutputChannels->debugFloatField2 = instantRpm / GET_RPM();
}
break;
case DBG_ION:

View File

@ -72,7 +72,7 @@ class AlternatorController : public PeriodicTimerController {
}
// todo: migrate this to FSIO
bool alternatorShouldBeEnabledAtCurrentRpm = GET_RPM_VALUE > engineConfiguration->cranking.rpm;
bool alternatorShouldBeEnabledAtCurrentRpm = GET_RPM() > engineConfiguration->cranking.rpm;
engine->isAlternatorControlEnabled = CONFIG(isAlternatorControlEnabled) && alternatorShouldBeEnabledAtCurrentRpm;
if (!engine->isAlternatorControlEnabled) {

View File

@ -70,7 +70,7 @@ public:
}
float rpm = GET_RPM_VALUE;
float rpm = GET_RPM();
// todo: make this configurable?
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;

View File

@ -658,7 +658,7 @@ static void applyIdleSolenoidPinState(int stateIndex, PwmConfig *state) /* pwm_g
OutputPin *output = state->outputPins[0];
int value = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
if (!value /* always allow turning solenoid off */ ||
(GET_RPM_VALUE != 0 || timeToStopIdleTest != 0) /* do not run solenoid unless engine is spinning or bench testing in progress */
(GET_RPM() != 0 || timeToStopIdleTest != 0) /* do not run solenoid unless engine is spinning or bench testing in progress */
) {
output->setValue(value);
}

View File

@ -347,7 +347,7 @@ void Engine::OnTriggerInvalidIndex(int currentIndex) {
Engine *engine = this;
EXPAND_Engine;
// let's not show a warning if we are just starting to spin
if (GET_RPM_VALUE != 0) {
if (GET_RPM() != 0) {
warning(CUSTOM_SYNC_ERROR, "sync error: index #%d above total size %d", currentIndex, triggerCentral.triggerShape.getSize());
triggerCentral.triggerState.setTriggerErrorState();
}

View File

@ -66,7 +66,7 @@ class LaunchControl: public PeriodicTimerController {
return;
}
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
int speed = getVehicleSpeed();
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
int tpstreshold = engineConfiguration->launchTpsTreshold;
@ -139,13 +139,13 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
}
void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
int retardThresholdRpm = CONFIG(launchRpm) +
(CONFIG(enableLaunchRetard) ? CONFIG(launchAdvanceRpmRange) : 0) +
CONFIG(hardCutRpmRange);
if (retardThresholdRpm > GET_RPM_VALUE) {
if (retardThresholdRpm > GET_RPM()) {
*limitedSpark = engine->isLaunchCondition && engineConfiguration->launchSparkCutEnable;
*limitedFuel = engine->isLaunchCondition && engineConfiguration->launchFuelCutEnable;
engine->rpmHardCut = true;

View File

@ -64,7 +64,7 @@ static void auxValveTriggerCallback(trigger_event_e ckpSignalType,
if (index != engine->auxSchedulingIndex) {
return;
}
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
if (!isValidRpm(rpm)) {
return;
}

View File

@ -268,7 +268,7 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
if (printFuelDebug) {
InjectorOutputPin *output = outputs[0];
printf("handleFuelInjectionEvent fuelout %s injection_duration %dus engineCycleDuration=%.1fms\t\n", output->name, (int)durationUs,
(int)MS2US(getCrankshaftRevolutionTimeMs(GET_RPM_VALUE)) / 1000.0);
(int)MS2US(getCrankshaftRevolutionTimeMs(GET_RPM())) / 1000.0);
}
#endif /*EFI_PRINTF_FUEL_DETAILS */
@ -403,7 +403,7 @@ static void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEvent
return;
}
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
if (rpm == 0) {
// this happens while we just start cranking
// todo: check for 'trigger->is_synchnonized?'

View File

@ -235,7 +235,7 @@ void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
#endif /* EFI_TUNER_STUDIO */
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map;
angle_t start = interpolate2d("mapa", rpm, c->samplingAngleBins, c->samplingAngle);
@ -278,7 +278,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
if (index != (uint32_t)CONFIG(mapAveragingSchedulingAtIndex))
return;
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
if (!isValidRpm(rpm)) {
return;
}
@ -338,7 +338,7 @@ float getMap(void) {
}
#if EFI_ANALOG_SENSORS
if (!isValidRpm(GET_RPM_VALUE) || 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

@ -222,7 +222,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
// todo: no reason for this to be disabled in unit_test mode?!
#if ! EFI_UNIT_TEST
if (GET_RPM_VALUE > 2 * engineConfiguration->cranking.rpm) {
if (GET_RPM() > 2 * engineConfiguration->cranking.rpm) {
const char *outputName = output->getName();
if (prevSparkName == outputName && getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE) != IM_ONE_COIL) {
warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);

View File

@ -102,7 +102,7 @@ static floatms_t getCrankingSparkDwell(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} else {
// technically this could be implemented via interpolate2d
float angle = engineConfiguration->crankingChargeAngle;
return getOneDegreeTimeMs(GET_RPM_VALUE) * angle;
return getOneDegreeTimeMs(GET_RPM()) * angle;
}
}

View File

@ -252,7 +252,7 @@ static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index, efitic
ScopePerf perf(PE::Hip9011IntHoldCallback);
int rpm = GET_RPM_VALUE;
int rpm = GET_RPM();
if (!isValidRpm(rpm))
return;
@ -309,7 +309,7 @@ void hipAdcCallback(adcsample_t adcValue) {
hipValueMax = maxF(engine->knockVolts, hipValueMax);
engine->knockLogic(engine->knockVolts);
instance.handleValue(GET_RPM_VALUE DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS));
instance.handleValue(GET_RPM() DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS));
}
}

View File

@ -353,7 +353,7 @@ TEST(misc, testRpmCalculator) {
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffsetFromTriggerEvent);
eth.firePrimaryTriggerRise();
ASSERT_EQ(1500, eth.engine.rpmCalculator.rpmValue);
ASSERT_EQ(1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
assertEqualsM("dwell", 4.5, engine->engineState.dwellAngle);
assertEqualsM("fuel #2", 4.5450, engine->injectionDuration);
@ -407,7 +407,7 @@ TEST(misc, testRpmCalculator) {
assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle);
assertEqualsM("fuel #3", 4.5450, eth.engine.injectionDuration);
ASSERT_EQ(1500, eth.engine.rpmCalculator.rpmValue);
ASSERT_EQ(1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
eth.assertInjectorUpEvent("ev 0/2", 0, -4849, 2);
@ -1283,7 +1283,7 @@ TEST(big, testMissedSpark299) {
printf("*************************************************** testMissedSpark299 start\r\n");
ASSERT_EQ(3000, eth.engine.rpmCalculator.rpmValue);
ASSERT_EQ(3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
setWholeTimingTable(3);
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);