diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index ae8fb11ce0..f10c75fbc3 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -214,44 +214,4 @@ size_t getMultiSparkCount(int rpm) { } } -/** - * @param octane gas octane number - * @param bore in mm - */ -float getTopAdvanceForBore(chamber_style_e style, int octane, double compression, double bore) { - int octaneCorrection; - if ( octane <= 90) { - octaneCorrection = -2; - } else if (octane < 94) { - octaneCorrection = -1; - } else { - octaneCorrection = 0; - } - - int compressionCorrection; - if (compression <= 9) { - compressionCorrection = 2; - } else if (compression <= 10) { - compressionCorrection = 1; - } else if (compression <= 11) { - compressionCorrection = 0; - } else { - // compression ratio above 11 - compressionCorrection = -2; - } - int base; - if (style == CS_OPEN) { - base = 33; - } else if (style == CS_CLOSED) { - base = 28; - } else { - // CS_SWIRL_TUMBLE - base = 22; - } - - float boreCorrection = (bore - 4 * 25.4) / 25.4 * 6; - float result = base + octaneCorrection + compressionCorrection + boreCorrection; - return ((int)(result * 10)) / 10.0; -} - #endif // EFI_ENGINE_CONTROL diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 6b39769330..0d0697aa78 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -506,13 +506,6 @@ typedef enum { Internal_ForceMyEnumIntSize_timing_mode = ENUM_32_BITS, } timing_mode_e; -typedef enum { - CS_OPEN = 0, - CS_CLOSED = 1, - CS_SWIRL_TUMBLE = 2, - - Internal_ForceMyEnumIntSize_chamber_stype = ENUM_32_BITS, -} chamber_style_e; /** * Net Body Computer types diff --git a/unit_tests/tests/test_engine_math.cpp b/unit_tests/tests/test_engine_math.cpp index 21cbb739bc..d5d9a9cefb 100644 --- a/unit_tests/tests/test_engine_math.cpp +++ b/unit_tests/tests/test_engine_math.cpp @@ -64,6 +64,55 @@ TEST(misc, testEngineMath) { ASSERT_NEAR(56.9762f/*kg/h*/, engine->engineState.airflowEstimate, EPS4D); } +typedef enum { + CS_OPEN = 0, + CS_CLOSED = 1, + CS_SWIRL_TUMBLE = 2, + + Internal_ForceMyEnumIntSize_chamber_stype = ENUM_32_BITS, +} chamber_style_e; + +/** + * @param octane gas octane number + * @param bore in mm + */ +static float getTopAdvanceForBore(chamber_style_e style, int octane, double compression, double bore) { + int octaneCorrection; + if ( octane <= 90) { + octaneCorrection = -2; + } else if (octane < 94) { + octaneCorrection = -1; + } else { + octaneCorrection = 0; + } + + int compressionCorrection; + if (compression <= 9) { + compressionCorrection = 2; + } else if (compression <= 10) { + compressionCorrection = 1; + } else if (compression <= 11) { + compressionCorrection = 0; + } else { + // compression ratio above 11 + compressionCorrection = -2; + } + int base; + if (style == CS_OPEN) { + base = 33; + } else if (style == CS_CLOSED) { + base = 28; + } else { + // CS_SWIRL_TUMBLE + base = 22; + } + + float boreCorrection = (bore - 4 * 25.4) / 25.4 * 6; + float result = base + octaneCorrection + compressionCorrection + boreCorrection; + return ((int)(result * 10)) / 10.0; +} + + TEST(misc, testIgnitionMapGenerator) { printf("*************************************************** testIgnitionMapGenerator\r\n");