diff --git a/firmware/controllers/algo/advance_map.h b/firmware/controllers/algo/advance_map.h index 9e8d47a7f4..3071615408 100644 --- a/firmware/controllers/algo/advance_map.h +++ b/firmware/controllers/algo/advance_map.h @@ -20,5 +20,5 @@ size_t getMultiSparkCount(int rpm); class IgnitionState : public ignition_state_s { public: - floatms_t getSparkDwell(int rpm); + floatms_t getSparkDwell(float rpm); }; diff --git a/firmware/controllers/algo/airmass/airmass.cpp b/firmware/controllers/algo/airmass/airmass.cpp index 316cf07f1e..53710516a5 100644 --- a/firmware/controllers/algo/airmass/airmass.cpp +++ b/firmware/controllers/algo/airmass/airmass.cpp @@ -14,7 +14,7 @@ static float getVeLoadAxis(ve_override_e mode, float passedLoad) { } } -float AirmassVeModelBase::getVe(int rpm, float load, bool postState) const { +float AirmassVeModelBase::getVe(float rpm, float load, bool postState) const { efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0); // Override the load value if necessary diff --git a/firmware/controllers/algo/airmass/airmass.h b/firmware/controllers/algo/airmass/airmass.h index 6451e7e0ed..0bb1add5a5 100644 --- a/firmware/controllers/algo/airmass/airmass.h +++ b/firmware/controllers/algo/airmass/airmass.h @@ -9,7 +9,7 @@ struct AirmassResult { }; struct AirmassModelBase { - virtual AirmassResult getAirmass(int rpm, bool postState) = 0; + virtual AirmassResult getAirmass(float rpm, bool postState) = 0; }; class AirmassVeModelBase : public AirmassModelBase { @@ -17,7 +17,7 @@ class AirmassVeModelBase : public AirmassModelBase { explicit AirmassVeModelBase(const ValueProvider3D& veTable); // Retrieve the user-calibrated volumetric efficiency from the table - float getVe(int rpm, percent_t load, bool postState) const; + float getVe(float rpm, percent_t load, bool postState) const; private: const ValueProvider3D* const m_veTable; diff --git a/firmware/controllers/algo/airmass/alphan_airmass.cpp b/firmware/controllers/algo/airmass/alphan_airmass.cpp index 84aeda439d..f364bac3f4 100644 --- a/firmware/controllers/algo/airmass/alphan_airmass.cpp +++ b/firmware/controllers/algo/airmass/alphan_airmass.cpp @@ -2,7 +2,7 @@ #include "alphan_airmass.h" -AirmassResult AlphaNAirmass::getAirmass(int rpm, bool postState) { +AirmassResult AlphaNAirmass::getAirmass(float rpm, bool postState) { auto tps = Sensor::get(SensorType::Tps1); if (!tps.Valid) { diff --git a/firmware/controllers/algo/airmass/alphan_airmass.h b/firmware/controllers/algo/airmass/alphan_airmass.h index decf34979c..027d1d3146 100644 --- a/firmware/controllers/algo/airmass/alphan_airmass.h +++ b/firmware/controllers/algo/airmass/alphan_airmass.h @@ -6,5 +6,5 @@ class AlphaNAirmass : public SpeedDensityBase { public: explicit AlphaNAirmass(const ValueProvider3D& veTable) : SpeedDensityBase(veTable) {} - AirmassResult getAirmass(int rpm, bool postState) override; + AirmassResult getAirmass(float rpm, bool postState) override; }; diff --git a/firmware/controllers/algo/airmass/lua_airmass.h b/firmware/controllers/algo/airmass/lua_airmass.h index 7acfeadbd4..972629653c 100644 --- a/firmware/controllers/algo/airmass/lua_airmass.h +++ b/firmware/controllers/algo/airmass/lua_airmass.h @@ -4,7 +4,7 @@ class LuaAirmass final : public AirmassModelBase { public: - AirmassResult getAirmass(int /*rpm*/, bool /*postState*/) override { + AirmassResult getAirmass(float /*rpm*/, bool /*postState*/) override { return m_airmass; } diff --git a/firmware/controllers/algo/airmass/maf_airmass.cpp b/firmware/controllers/algo/airmass/maf_airmass.cpp index 48f2565d5a..c3cd03119e 100644 --- a/firmware/controllers/algo/airmass/maf_airmass.cpp +++ b/firmware/controllers/algo/airmass/maf_airmass.cpp @@ -31,7 +31,7 @@ float MafAirmass::getMaf() const { } } -AirmassResult MafAirmass::getAirmass(int rpm, bool postState) { +AirmassResult MafAirmass::getAirmass(float rpm, bool postState) { float maf = getMaf(); return getAirmassImpl(maf, rpm, postState); @@ -41,7 +41,7 @@ AirmassResult MafAirmass::getAirmass(int rpm, bool postState) { * Function block now works to create a standardised load from the cylinder filling as well as tune fuel via VE table. * @return total duration of fuel injection per engine cycle, in milliseconds */ -AirmassResult MafAirmass::getAirmassImpl(float massAirFlow, int rpm, bool postState) const { +AirmassResult MafAirmass::getAirmassImpl(float massAirFlow, float rpm, bool postState) const { // If the engine is stopped, MAF is meaningless if (rpm == 0) { return {}; diff --git a/firmware/controllers/algo/airmass/maf_airmass.h b/firmware/controllers/algo/airmass/maf_airmass.h index 0966a394ad..599016ea45 100644 --- a/firmware/controllers/algo/airmass/maf_airmass.h +++ b/firmware/controllers/algo/airmass/maf_airmass.h @@ -6,10 +6,10 @@ class MafAirmass final : public AirmassVeModelBase { public: explicit MafAirmass(const ValueProvider3D& veTable) : AirmassVeModelBase(veTable) {} - AirmassResult getAirmass(int rpm, bool postState) override; + AirmassResult getAirmass(float rpm, bool postState) override; // Compute airmass based on flow & engine speed - AirmassResult getAirmassImpl(float massAirFlow, int rpm, bool postState) const; + AirmassResult getAirmassImpl(float massAirFlow, float rpm, bool postState) const; private: float getMaf() const; diff --git a/firmware/controllers/algo/airmass/speed_density_airmass.cpp b/firmware/controllers/algo/airmass/speed_density_airmass.cpp index e68532d989..921001c77d 100644 --- a/firmware/controllers/algo/airmass/speed_density_airmass.cpp +++ b/firmware/controllers/algo/airmass/speed_density_airmass.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include "speed_density_airmass.h" -AirmassResult SpeedDensityAirmass::getAirmass(int rpm, bool postState) { +AirmassResult SpeedDensityAirmass::getAirmass(float rpm, bool postState) { ScopePerf perf(PE::GetSpeedDensityFuel); auto map = getMap(rpm, postState); @@ -47,7 +47,7 @@ float SpeedDensityAirmass::getAirflow(float rpm, float map, bool postState) { return massPerCycle * rpm / 60; } -float SpeedDensityAirmass::getMap(int rpm, bool postState) const { +float SpeedDensityAirmass::getMap(float rpm, bool postState) const { float fallbackMap = m_mapEstimationTable->getValue(rpm, Sensor::getOrZero(SensorType::Tps1)); #if EFI_TUNER_STUDIO diff --git a/firmware/controllers/algo/airmass/speed_density_airmass.h b/firmware/controllers/algo/airmass/speed_density_airmass.h index 9b3f42f683..c75c1052ff 100644 --- a/firmware/controllers/algo/airmass/speed_density_airmass.h +++ b/firmware/controllers/algo/airmass/speed_density_airmass.h @@ -9,11 +9,11 @@ class SpeedDensityAirmass : public SpeedDensityBase { , m_mapEstimationTable(&mapEstimationTable) {} - AirmassResult getAirmass(int rpm, bool postState) override; + AirmassResult getAirmass(float rpm, bool postState) override; AirmassResult getAirmass(float rpm, float map, bool postState); float getAirflow(float rpm, float map, bool postState); - float getMap(int rpm, bool postState) const; + float getMap(float rpm, bool postState) const; private: const ValueProvider3D* const m_mapEstimationTable; diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index a8ba1563d8..38abfe59b5 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -99,7 +99,7 @@ void EngineState::periodicFastCallback() { engine->fuelComputer.running.timeSinceCrankingInSecs = crankingTimer.getElapsedSeconds(nowNt); - int rpm = Sensor::getOrZero(SensorType::Rpm); + float rpm = Sensor::getOrZero(SensorType::Rpm); engine->ignitionState.sparkDwell = engine->ignitionState.getSparkDwell(rpm); engine->ignitionState.dwellAngle = std::isnan(rpm) ? NAN : engine->ignitionState.sparkDwell / getOneDegreeTimeMs(rpm); diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 968985f90a..a2859ebd52 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -167,7 +167,7 @@ float getMaxAirflowAtMap(float map) { } // Per-cylinder base fuel mass -static float getBaseFuelMass(int rpm) { +static float getBaseFuelMass(float rpm) { ScopePerf perf(PE::GetBaseFuel); // airmass modes - get airmass first, then convert to fuel @@ -298,7 +298,7 @@ static float getCycleFuelMass(bool isCranking, float baseFuelMass) { * @returns Mass of each individual fuel injection, in grams * in case of single point injection mode the amount of fuel into all cylinders, otherwise the amount for one cylinder */ -float getInjectionMass(int rpm) { +float getInjectionMass(float rpm) { ScopePerf perf(PE::GetInjectionDuration); #if EFI_SHAFT_POSITION_INPUT diff --git a/firmware/controllers/algo/fuel_math.h b/firmware/controllers/algo/fuel_math.h index a0546ab51b..db0e4e0c00 100644 --- a/firmware/controllers/algo/fuel_math.h +++ b/firmware/controllers/algo/fuel_math.h @@ -26,7 +26,7 @@ float getCltFuelCorrection(); angle_t getCltTimingCorrection(); float getCrankingFuel(float baseFuel); float getCrankingFuel3(float baseFuel, uint32_t revolutionCounterSinceStart); -float getInjectionMass(int rpm); +float getInjectionMass(float rpm); percent_t getInjectorDutyCycle(int rpm); percent_t getInjectorDutyCycleStage2(int rpm); float getStage2InjectionFraction(int rpm, float fuelLoad); diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 783eb53642..2b2d625cf9 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -70,7 +70,7 @@ void setSingleCoilDwell() { /** * @return Spark dwell time, in milliseconds. 0 if tables are not ready. */ -floatms_t IgnitionState::getSparkDwell(int rpm) { +floatms_t IgnitionState::getSparkDwell(float rpm) { #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT float dwellMs; if (engine->rpmCalculator.isCranking()) { @@ -95,7 +95,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) { if (std::isnan(dwellMs) || dwellMs <= 0) { // this could happen during engine configuration reset - warning(ObdCode::CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%d", dwellMs, rpm); + warning(ObdCode::CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%.0f", dwellMs, rpm); return 0; } return dwellMs; diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 57a4a683b4..c2b2db375f 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -31,8 +31,6 @@ floatms_t getEngineCycleDuration(int rpm); float getFuelingLoad(); float getIgnitionLoad(); -floatms_t getSparkDwell(int rpm); - ignition_mode_e getCurrentIgnitionMode(); size_t getCylinderId(size_t index); diff --git a/unit_tests/mocks.h b/unit_tests/mocks.h index 9a8a42e5d2..60364c196c 100644 --- a/unit_tests/mocks.h +++ b/unit_tests/mocks.h @@ -90,7 +90,7 @@ class MockAirmass : public AirmassVeModelBase { MockVp3d veTable; - MOCK_METHOD(AirmassResult, getAirmass, (int rpm, bool postState), (override)); + MOCK_METHOD(AirmassResult, getAirmass, (float rpm, bool postState), (override)); }; class MockInjectorModel2 : public IInjectorModel { diff --git a/unit_tests/tests/ignition_injection/test_fuel_math.cpp b/unit_tests/tests/ignition_injection/test_fuel_math.cpp index e6d2c81fb3..161bc909cd 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_math.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_math.cpp @@ -145,7 +145,7 @@ TEST(AirmassModes, VeOverride) { struct DummyAirmassModel : public AirmassVeModelBase { DummyAirmassModel(const ValueProvider3D& veTable) : AirmassVeModelBase(veTable) {} - AirmassResult getAirmass(int rpm, bool postState) override { + AirmassResult getAirmass(float rpm, bool postState) override { // Default load value 10, will be overriden getVe(rpm, 10.0f, postState);