diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index db8cd66f63..a7debc1610 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -96,7 +96,7 @@ expected TriggerCentral::getCurrentEnginePhase(efitick_t nowNt) const { /** * todo: why is this method NOT reciprocal to getRpmMultiplier?! */ -static int getCrankDivider(operation_mode_e operationMode) { +int getCrankDivider(operation_mode_e operationMode) { switch (operationMode) { case FOUR_STROKE_CRANK_SENSOR: return 2; diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 4e4665afb8..32253bb579 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -231,3 +231,4 @@ void onConfigurationChangeTriggerCallback(); #define SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER (12 * 2) TriggerCentral * getTriggerCentral(); +int getCrankDivider(operation_mode_e operationMode); diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 4aeb245cf8..9ff4438428 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -78,9 +78,9 @@ static int atTriggerVersions[NUM_EMULATOR_CHANNELS] = { 0 }; static float getRpmMultiplier(operation_mode_e mode) { switch (mode) { case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR: - return SYMMETRICAL_CRANK_SENSOR_DIVIDER / 2; + return getCrankDivider(mode) / 2; case FOUR_STROKE_THREE_TIMES_CRANK_SENSOR: - return SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER / 2; + return getCrankDivider(mode) / 2; case FOUR_STROKE_SIX_TIMES_CRANK_SENSOR: // todo: c'mon too much code duplication! at least reuse getCrankDivider when it works?! return SYMMETRICAL_SIX_TIMES_CRANK_SENSOR_DIVIDER / 2; @@ -89,10 +89,12 @@ static float getRpmMultiplier(operation_mode_e mode) { case FOUR_STROKE_CAM_SENSOR: return 0.5; case OM_NONE: + return 1; case TWO_STROKE: - case FOUR_STROKE_CRANK_SENSOR: // unit test coverage still runs if the value below is changed to '2' not a great sign! return 1; + case FOUR_STROKE_CRANK_SENSOR: + return getCrankDivider(mode) / 2; }; criticalError("We should not have reach this line"); return 1;