From 71c860b648721c5a9fb066d6476149c1f7128a31 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 25 Sep 2024 00:20:18 -0700 Subject: [PATCH] int rpm -> float rpm --- firmware/controllers/algo/launch_control.cpp | 6 +++--- firmware/controllers/algo/launch_control.h | 4 ++-- .../controllers/engine_cycle/high_pressure_fuel_pump.cpp | 8 ++++---- .../controllers/engine_cycle/high_pressure_fuel_pump.h | 6 +++--- firmware/controllers/engine_cycle/rpm_calculator.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index dc192bb9b4..d31766eabf 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -73,12 +73,12 @@ bool LaunchControlBase::isInsideTpsCondition() const { /** * Condition is true as soon as we are above LaunchRpm */ -bool LaunchControlBase::isInsideRPMCondition(int rpm) const { +bool LaunchControlBase::isInsideRPMCondition(float rpm) const { int launchRpm = engineConfiguration->launchRpm; return (launchRpm < rpm); } -bool LaunchControlBase::isLaunchConditionMet(int rpm) { +bool LaunchControlBase::isLaunchConditionMet(float rpm) { activateSwitchCondition = isInsideSwitchCondition(); rpmCondition = isInsideRPMCondition(rpm); @@ -102,7 +102,7 @@ void LaunchControlBase::update() { return; } - int rpm = Sensor::getOrZero(SensorType::Rpm); + float rpm = Sensor::getOrZero(SensorType::Rpm); combinedConditions = isLaunchConditionMet(rpm); //and still recalculate in case user changed the values diff --git a/firmware/controllers/algo/launch_control.h b/firmware/controllers/algo/launch_control.h index 957fcbc820..9f0e020ef7 100644 --- a/firmware/controllers/algo/launch_control.h +++ b/firmware/controllers/algo/launch_control.h @@ -22,8 +22,8 @@ class LaunchControlBase : public launch_control_state_s { bool isInsideSpeedCondition() const; bool isInsideTpsCondition() const; bool isInsideSwitchCondition(); - bool isInsideRPMCondition(int rpm) const; - bool isLaunchConditionMet(int rpm); + bool isInsideRPMCondition(float rpm) const; + bool isLaunchConditionMet(float rpm); bool isLaunchSparkRpmRetardCondition() const; bool isLaunchFuelRpmRetardCondition() const; diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp index d7716c4d14..8b63f9736c 100644 --- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp +++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp @@ -68,7 +68,7 @@ angle_t HpfpLobe::findNextLobe() { } // As a percent of the full pump stroke -float HpfpQuantity::calcFuelPercent(int rpm) { +float HpfpQuantity::calcFuelPercent(float rpm) { float fuel_requested_cc_per_cycle = engine->engineState.injectionMass[0] * (1.f / fuelDensity) * engineConfiguration->cylindersCount; float fuel_requested_cc_per_lobe = fuel_requested_cc_per_cycle / engineConfiguration->hpfpCamLobes; @@ -79,7 +79,7 @@ float HpfpQuantity::calcFuelPercent(int rpm) { config->hpfpCompensationRpmBins, rpm); } -float HpfpQuantity::calcPI(int rpm, float calc_fuel_percent) { +float HpfpQuantity::calcPI(float rpm, float calc_fuel_percent) { m_pressureTarget_kPa = std::max( m_pressureTarget_kPa - (engineConfiguration->hpfpTargetDecay * (FAST_CALLBACK_PERIOD_MS / 1000.)), @@ -117,7 +117,7 @@ float HpfpQuantity::calcPI(int rpm, float calc_fuel_percent) { return p_control_percent + i_control_percent; } -angle_t HpfpQuantity::pumpAngleFuel(int rpm, HpfpController *model) { +angle_t HpfpQuantity::pumpAngleFuel(float rpm, HpfpController *model) { // Math based on fuel requested model->fuel_requested_percent = calcFuelPercent(rpm); @@ -133,7 +133,7 @@ angle_t HpfpQuantity::pumpAngleFuel(int rpm, HpfpController *model) { void HpfpController::onFastCallback() { // Pressure current/target calculation - int rpm = Sensor::getOrZero(SensorType::Rpm); + float rpm = Sensor::getOrZero(SensorType::Rpm); isHpfpInactive = rpm < rpm_spinning_cutoff || engineConfiguration->hpfpCamLobes == 0 || diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h index e75ec18800..6df35e0b98 100644 --- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h +++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h @@ -42,7 +42,7 @@ class HpfpQuantity { /** * Calculate where the pump should become active, in degrees before pump lobe TDC */ - angle_t pumpAngleFuel(int rpm, HpfpController *model); + angle_t pumpAngleFuel(float rpm, HpfpController *model); /** * Calculate the percent of the pump stroke needed to replace the fuel injected. Also @@ -54,7 +54,7 @@ class HpfpQuantity { * Return value is nominally 0-100, but may be outside that range (including negative) if * model parameters are not accurate. */ - float calcFuelPercent(int rpm); + float calcFuelPercent(float rpm); /** * Calculates the PI controller contribution as a percent. This amount should be added to @@ -66,7 +66,7 @@ class HpfpQuantity { * Return value is nominally 0-100, but may be outside that range (including negative) if * model parameters are not accurate. The sum of this and calc_fuel_percent will be 0-100. */ - float calcPI(int rpm, float calc_fuel_percent); + float calcPI(float rpm, float calc_fuel_percent); /** * Reset internal state due to a stopped engine. diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp index 384c8a41f8..5e2d13bf27 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.cpp +++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp @@ -345,7 +345,7 @@ static void onTdcCallback(void *) { } #endif /* EFI_UNIT_TEST */ - int rpm = Sensor::getOrZero(SensorType::Rpm); + float rpm = Sensor::getOrZero(SensorType::Rpm); addEngineSnifferTdcEvent(rpm); #if EFI_TOOTH_LOGGER LogTriggerTopDeadCenter(getTimeNowNt());