Skip to content

Commit

Permalink
int rpm -> float rpm
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Sep 25, 2024
1 parent 8952633 commit 71c860b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions firmware/controllers/algo/launch_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions firmware/controllers/algo/launch_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<float>(
m_pressureTarget_kPa - (engineConfiguration->hpfpTargetDecay *
(FAST_CALLBACK_PERIOD_MS / 1000.)),
Expand Down Expand Up @@ -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);

Expand All @@ -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 ||
Expand Down
6 changes: 3 additions & 3 deletions firmware/controllers/engine_cycle/high_pressure_fuel_pump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion firmware/controllers/engine_cycle/rpm_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 71c860b

Please sign in to comment.