RPM refactoring done
This commit is contained in:
parent
85d2ad2fd7
commit
a3b10a0a04
|
@ -66,7 +66,7 @@ static msg_t auxPidThread(int param) {
|
||||||
pidReset();
|
pidReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
float rpm = engine->rpmCalculator.rpmValue;
|
float rpm = GET_RPM();
|
||||||
|
|
||||||
// todo: make this configurable?
|
// todo: make this configurable?
|
||||||
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
|
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
|
||||||
|
|
|
@ -186,7 +186,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
timeSinceCranking = nowNt - crankingTime;
|
timeSinceCranking = nowNt - crankingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = ENGINE(rpmCalculator.rpmValue);
|
int rpm = GET_RPM();
|
||||||
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
|
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
|
||||||
engine->sensors.currentAfr = getAfr(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->sensors.currentAfr = getAfr(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
|
@ -68,7 +68,7 @@ static msg_t AltCtrlThread(int param) {
|
||||||
|
|
||||||
|
|
||||||
// todo: migrate this to FSIO
|
// todo: migrate this to FSIO
|
||||||
bool alternatorShouldBeEnabledAtCurrentRpm = engine->rpmCalculator.rpmValue > 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) {
|
||||||
|
|
|
@ -307,7 +307,7 @@ static void applyIdleSolenoidPinState(PwmConfig *state, int stateIndex) {
|
||||||
OutputPin *output = state->outputPins[0];
|
OutputPin *output = state->outputPins[0];
|
||||||
int value = state->multiWave.waves[0].pinStates[stateIndex];
|
int value = state->multiWave.waves[0].pinStates[stateIndex];
|
||||||
if (!value /* always allow turning solenoid off */ ||
|
if (!value /* always allow turning solenoid off */ ||
|
||||||
(engine->rpmCalculator.rpmValue != 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,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(engine->rpmCalculator.rpmValue) * angle;
|
return getOneDegreeTimeMs(GET_RPM()) * angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
|
|
||||||
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
if (ENGINE(rpmCalculator.rpmValue) < CONFIG(fuelClosedLoopRpmThreshold) ||
|
if (GET_RPM() < CONFIG(fuelClosedLoopRpmThreshold) ||
|
||||||
ENGINE(sensors.clt) < CONFIG(fuelClosedLoopCltThreshold) ||
|
ENGINE(sensors.clt) < CONFIG(fuelClosedLoopCltThreshold) ||
|
||||||
getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) ||
|
getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) ||
|
||||||
ENGINE(sensors.currentAfr) < boardConfiguration->fuelClosedLoopAfrLowThreshold ||
|
ENGINE(sensors.currentAfr) < boardConfiguration->fuelClosedLoopAfrLowThreshold ||
|
||||||
|
@ -432,7 +432,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = ENGINE(rpmCalculator.rpmValue);
|
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?'
|
||||||
|
|
|
@ -48,6 +48,8 @@ typedef enum {
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|
||||||
|
#define GET_RPM() ( ENGINE(rpmCalculator.rpmValue) )
|
||||||
|
|
||||||
class RpmCalculator {
|
class RpmCalculator {
|
||||||
public:
|
public:
|
||||||
#if !EFI_PROD_CODE
|
#if !EFI_PROD_CODE
|
||||||
|
|
|
@ -79,7 +79,7 @@ void turnSparkPinLow(IgnitionEvent *event) {
|
||||||
static void turnSparkPinHigh2(IgnitionEvent *event, IgnitionOutputPin *output) {
|
static void turnSparkPinHigh2(IgnitionEvent *event, IgnitionOutputPin *output) {
|
||||||
|
|
||||||
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
|
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||||
if (engine->rpmCalculator.rpmValue > 2 * engineConfiguration->cranking.rpm) {
|
if (GET_RPM() > 2 * engineConfiguration->cranking.rpm) {
|
||||||
const char *outputName = output->name;
|
const char *outputName = output->name;
|
||||||
if (prevSparkName == outputName && engineConfiguration->ignitionMode != IM_ONE_COIL) {
|
if (prevSparkName == outputName && engineConfiguration->ignitionMode != 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);
|
||||||
|
|
Loading…
Reference in New Issue