refactoring
This commit is contained in:
parent
f9cad49f8d
commit
c476cd3b95
|
@ -841,7 +841,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
||||||
{
|
{
|
||||||
float instantRpm = engine->triggerCentral.triggerState.instantRpm;
|
float instantRpm = engine->triggerCentral.triggerState.instantRpm;
|
||||||
tsOutputChannels->debugFloatField1 = instantRpm;
|
tsOutputChannels->debugFloatField1 = instantRpm;
|
||||||
tsOutputChannels->debugFloatField2 = instantRpm / GET_RPM_VALUE;
|
tsOutputChannels->debugFloatField2 = instantRpm / GET_RPM();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DBG_ION:
|
case DBG_ION:
|
||||||
|
|
|
@ -72,7 +72,7 @@ class AlternatorController : public PeriodicTimerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: migrate this to FSIO
|
// 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;
|
engine->isAlternatorControlEnabled = CONFIG(isAlternatorControlEnabled) && alternatorShouldBeEnabledAtCurrentRpm;
|
||||||
|
|
||||||
if (!engine->isAlternatorControlEnabled) {
|
if (!engine->isAlternatorControlEnabled) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float rpm = GET_RPM_VALUE;
|
float rpm = GET_RPM();
|
||||||
|
|
||||||
// todo: make this configurable?
|
// todo: make this configurable?
|
||||||
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
|
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
|
||||||
|
|
|
@ -658,7 +658,7 @@ static void applyIdleSolenoidPinState(int stateIndex, PwmConfig *state) /* pwm_g
|
||||||
OutputPin *output = state->outputPins[0];
|
OutputPin *output = state->outputPins[0];
|
||||||
int value = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
|
int value = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
|
||||||
if (!value /* always allow turning solenoid off */ ||
|
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);
|
output->setValue(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,7 @@ void Engine::OnTriggerInvalidIndex(int currentIndex) {
|
||||||
Engine *engine = this;
|
Engine *engine = this;
|
||||||
EXPAND_Engine;
|
EXPAND_Engine;
|
||||||
// let's not show a warning if we are just starting to spin
|
// 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());
|
warning(CUSTOM_SYNC_ERROR, "sync error: index #%d above total size %d", currentIndex, triggerCentral.triggerShape.getSize());
|
||||||
triggerCentral.triggerState.setTriggerErrorState();
|
triggerCentral.triggerState.setTriggerErrorState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class LaunchControl: public PeriodicTimerController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
int speed = getVehicleSpeed();
|
int speed = getVehicleSpeed();
|
||||||
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
|
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
|
||||||
int tpstreshold = engineConfiguration->launchTpsTreshold;
|
int tpstreshold = engineConfiguration->launchTpsTreshold;
|
||||||
|
@ -139,13 +139,13 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
|
|
||||||
int retardThresholdRpm = CONFIG(launchRpm) +
|
int retardThresholdRpm = CONFIG(launchRpm) +
|
||||||
(CONFIG(enableLaunchRetard) ? CONFIG(launchAdvanceRpmRange) : 0) +
|
(CONFIG(enableLaunchRetard) ? CONFIG(launchAdvanceRpmRange) : 0) +
|
||||||
CONFIG(hardCutRpmRange);
|
CONFIG(hardCutRpmRange);
|
||||||
|
|
||||||
if (retardThresholdRpm > GET_RPM_VALUE) {
|
if (retardThresholdRpm > GET_RPM()) {
|
||||||
*limitedSpark = engine->isLaunchCondition && engineConfiguration->launchSparkCutEnable;
|
*limitedSpark = engine->isLaunchCondition && engineConfiguration->launchSparkCutEnable;
|
||||||
*limitedFuel = engine->isLaunchCondition && engineConfiguration->launchFuelCutEnable;
|
*limitedFuel = engine->isLaunchCondition && engineConfiguration->launchFuelCutEnable;
|
||||||
engine->rpmHardCut = true;
|
engine->rpmHardCut = true;
|
||||||
|
|
|
@ -64,7 +64,7 @@ static void auxValveTriggerCallback(trigger_event_e ckpSignalType,
|
||||||
if (index != engine->auxSchedulingIndex) {
|
if (index != engine->auxSchedulingIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
if (!isValidRpm(rpm)) {
|
if (!isValidRpm(rpm)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
|
||||||
if (printFuelDebug) {
|
if (printFuelDebug) {
|
||||||
InjectorOutputPin *output = outputs[0];
|
InjectorOutputPin *output = outputs[0];
|
||||||
printf("handleFuelInjectionEvent fuelout %s injection_duration %dus engineCycleDuration=%.1fms\t\n", output->name, (int)durationUs,
|
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 */
|
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ static void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEvent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
// this happens while we just start cranking
|
// this happens while we just start cranking
|
||||||
// todo: check for 'trigger->is_synchnonized?'
|
// todo: check for 'trigger->is_synchnonized?'
|
||||||
|
|
|
@ -235,7 +235,7 @@ void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
#endif /* EFI_TUNER_STUDIO */
|
||||||
|
|
||||||
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
if (isValidRpm(rpm)) {
|
if (isValidRpm(rpm)) {
|
||||||
MAP_sensor_config_s * c = &engineConfiguration->map;
|
MAP_sensor_config_s * c = &engineConfiguration->map;
|
||||||
angle_t start = interpolate2d("mapa", rpm, c->samplingAngleBins, c->samplingAngle);
|
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))
|
if (index != (uint32_t)CONFIG(mapAveragingSchedulingAtIndex))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
if (!isValidRpm(rpm)) {
|
if (!isValidRpm(rpm)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ float getMap(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_ANALOG_SENSORS
|
#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(getRawMap()); // maybe return NaN in case of stopped engine?
|
||||||
return validateMap(currentPressure);
|
return validateMap(currentPressure);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -222,7 +222,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
|
||||||
// todo: no reason for this to be disabled in unit_test mode?!
|
// todo: no reason for this to be disabled in unit_test mode?!
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
|
|
||||||
if (GET_RPM_VALUE > 2 * engineConfiguration->cranking.rpm) {
|
if (GET_RPM() > 2 * engineConfiguration->cranking.rpm) {
|
||||||
const char *outputName = output->getName();
|
const char *outputName = output->getName();
|
||||||
if (prevSparkName == outputName && getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE) != IM_ONE_COIL) {
|
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);
|
warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);
|
||||||
|
|
|
@ -102,7 +102,7 @@ static floatms_t getCrankingSparkDwell(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
} else {
|
} else {
|
||||||
// technically this could be implemented via interpolate2d
|
// technically this could be implemented via interpolate2d
|
||||||
float angle = engineConfiguration->crankingChargeAngle;
|
float angle = engineConfiguration->crankingChargeAngle;
|
||||||
return getOneDegreeTimeMs(GET_RPM_VALUE) * angle;
|
return getOneDegreeTimeMs(GET_RPM()) * angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index, efitic
|
||||||
|
|
||||||
ScopePerf perf(PE::Hip9011IntHoldCallback);
|
ScopePerf perf(PE::Hip9011IntHoldCallback);
|
||||||
|
|
||||||
int rpm = GET_RPM_VALUE;
|
int rpm = GET_RPM();
|
||||||
if (!isValidRpm(rpm))
|
if (!isValidRpm(rpm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ void hipAdcCallback(adcsample_t adcValue) {
|
||||||
hipValueMax = maxF(engine->knockVolts, hipValueMax);
|
hipValueMax = maxF(engine->knockVolts, hipValueMax);
|
||||||
engine->knockLogic(engine->knockVolts);
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,7 @@ TEST(misc, testRpmCalculator) {
|
||||||
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffsetFromTriggerEvent);
|
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffsetFromTriggerEvent);
|
||||||
|
|
||||||
eth.firePrimaryTriggerRise();
|
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("dwell", 4.5, engine->engineState.dwellAngle);
|
||||||
assertEqualsM("fuel #2", 4.5450, engine->injectionDuration);
|
assertEqualsM("fuel #2", 4.5450, engine->injectionDuration);
|
||||||
|
@ -407,7 +407,7 @@ TEST(misc, testRpmCalculator) {
|
||||||
|
|
||||||
assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle);
|
assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle);
|
||||||
assertEqualsM("fuel #3", 4.5450, eth.engine.injectionDuration);
|
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);
|
eth.assertInjectorUpEvent("ev 0/2", 0, -4849, 2);
|
||||||
|
|
||||||
|
@ -1283,7 +1283,7 @@ TEST(big, testMissedSpark299) {
|
||||||
|
|
||||||
printf("*************************************************** testMissedSpark299 start\r\n");
|
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);
|
setWholeTimingTable(3);
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
Loading…
Reference in New Issue