RPM refactoring done

This commit is contained in:
rusefi 2017-07-08 07:19:26 -04:00
parent 85d2ad2fd7
commit a3b10a0a04
8 changed files with 10 additions and 8 deletions

View File

@ -66,7 +66,7 @@ static msg_t auxPidThread(int param) {
pidReset();
}
float rpm = engine->rpmCalculator.rpmValue;
float rpm = GET_RPM();
// todo: make this configurable?
bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;

View File

@ -186,7 +186,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
timeSinceCranking = nowNt - crankingTime;
}
int rpm = ENGINE(rpmCalculator.rpmValue);
int rpm = GET_RPM();
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER_SUFFIX);
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
engine->sensors.currentAfr = getAfr(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -68,7 +68,7 @@ static msg_t AltCtrlThread(int param) {
// 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;
if (!engine->isAlternatorControlEnabled) {

View File

@ -307,7 +307,7 @@ static void applyIdleSolenoidPinState(PwmConfig *state, int stateIndex) {
OutputPin *output = state->outputPins[0];
int value = state->multiWave.waves[0].pinStates[stateIndex];
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);
}

View File

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

View File

@ -328,7 +328,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if ! EFI_UNIT_TEST
if (ENGINE(rpmCalculator.rpmValue) < CONFIG(fuelClosedLoopRpmThreshold) ||
if (GET_RPM() < CONFIG(fuelClosedLoopRpmThreshold) ||
ENGINE(sensors.clt) < CONFIG(fuelClosedLoopCltThreshold) ||
getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) ||
ENGINE(sensors.currentAfr) < boardConfiguration->fuelClosedLoopAfrLowThreshold ||
@ -432,7 +432,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
return;
}
int rpm = ENGINE(rpmCalculator.rpmValue);
int rpm = GET_RPM();
if (rpm == 0) {
// this happens while we just start cranking
// todo: check for 'trigger->is_synchnonized?'

View File

@ -48,6 +48,8 @@ typedef enum {
class Engine;
#define GET_RPM() ( ENGINE(rpmCalculator.rpmValue) )
class RpmCalculator {
public:
#if !EFI_PROD_CODE

View File

@ -79,7 +79,7 @@ void turnSparkPinLow(IgnitionEvent *event) {
static void turnSparkPinHigh2(IgnitionEvent *event, IgnitionOutputPin *output) {
#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;
if (prevSparkName == outputName && engineConfiguration->ignitionMode != IM_ONE_COIL) {
warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);