mirror of https://github.com/FOME-Tech/fome-fw.git
deduplicate getCrankDivider logic
This commit is contained in:
parent
d7e356cebf
commit
6767a755bd
|
@ -88,7 +88,7 @@ expected<float> 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;
|
||||
|
@ -98,12 +98,16 @@ static int getCrankDivider(operation_mode_e operationMode) {
|
|||
return SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER;
|
||||
case FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR:
|
||||
return SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER;
|
||||
default:
|
||||
case OM_NONE:
|
||||
case FOUR_STROKE_CAM_SENSOR:
|
||||
case TWO_STROKE:
|
||||
// That's easy - trigger cycle matches engine cycle
|
||||
return 1;
|
||||
}
|
||||
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "unexpected operationMode in getCrankDivider");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
|
||||
|
|
|
@ -215,3 +215,4 @@ void onConfigurationChangeTriggerCallback();
|
|||
#define SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER 24
|
||||
|
||||
TriggerCentral * getTriggerCentral();
|
||||
int getCrankDivider(operation_mode_e operationMode);
|
||||
|
|
|
@ -66,18 +66,19 @@ static int atTriggerVersion = 0;
|
|||
* todo: oh this method has only one usage? there must me another very similar method!
|
||||
*/
|
||||
static float getRpmMultiplier(operation_mode_e mode) {
|
||||
if (mode == FOUR_STROKE_THREE_TIMES_CRANK_SENSOR) {
|
||||
return SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER / 2;
|
||||
} else if (mode == FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR) {
|
||||
return SYMMETRICAL_CRANK_SENSOR_DIVIDER / 2;
|
||||
} else if (mode == FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR) {
|
||||
return SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER / 2;
|
||||
} else if (mode == FOUR_STROKE_CAM_SENSOR) {
|
||||
return 0.5;
|
||||
} else if (mode == FOUR_STROKE_CRANK_SENSOR) {
|
||||
switch (mode) {
|
||||
case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR:
|
||||
case FOUR_STROKE_THREE_TIMES_CRANK_SENSOR:
|
||||
case FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR:
|
||||
case FOUR_STROKE_CRANK_SENSOR:
|
||||
case FOUR_STROKE_CAM_SENSOR:
|
||||
case OM_NONE:
|
||||
return getCrankDivider(mode) / 2.0;
|
||||
case TWO_STROKE:
|
||||
// unit test coverage still runs if the value below is changed to '2' not a great sign!
|
||||
// but HW CI insists that we have '1' here
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue