only:int rpm -> float rpm

This commit is contained in:
Matthew Kennedy 2024-09-25 03:16:53 -04:00 committed by rusefillc
parent 93bb3df05d
commit 4ba6cf4185
9 changed files with 19 additions and 20 deletions

View File

@ -32,11 +32,11 @@ bool AntilagSystemBase::isInsideALSSwitchCondition() {
} }
} }
bool AntilagSystemBase::isALSMinRPMCondition(int rpm) const { bool AntilagSystemBase::isALSMinRPMCondition(float rpm) const {
return engineConfiguration->ALSMinRPM < rpm; return engineConfiguration->ALSMinRPM < rpm;
} }
bool AntilagSystemBase::isALSMaxRPMCondition(int rpm) const { bool AntilagSystemBase::isALSMaxRPMCondition(float rpm) const {
return engineConfiguration->ALSMaxRPM > rpm; return engineConfiguration->ALSMaxRPM > rpm;
} }
@ -64,7 +64,7 @@ bool AntilagSystemBase::isInsideALSTimerCondition() {
return ALStime < engineConfiguration->ALSMaxDuration; return ALStime < engineConfiguration->ALSMaxDuration;
} }
bool AntilagSystemBase::isAntilagConditionMet(int rpm) { bool AntilagSystemBase::isAntilagConditionMet(float rpm) {
ALSMinRPMCondition = isALSMinRPMCondition(rpm); ALSMinRPMCondition = isALSMinRPMCondition(rpm);
@ -89,7 +89,7 @@ todo: looking for a hero to figure out unit test part of this
} }
void AntilagSystemBase::update() { void AntilagSystemBase::update() {
int rpm = Sensor::getOrZero(SensorType::Rpm); float rpm = Sensor::getOrZero(SensorType::Rpm);
isAntilagCondition = engineConfiguration->antiLagEnabled && isAntilagConditionMet(rpm); isAntilagCondition = engineConfiguration->antiLagEnabled && isAntilagConditionMet(rpm);
if (!ALSMaxRPMCondition) { if (!ALSMaxRPMCondition) {

View File

@ -16,15 +16,15 @@ class AntilagSystemBase : public antilag_system_state_s {
public: public:
void update(); void update();
bool isALSMinRPMCondition(int rpm) const; bool isALSMinRPMCondition(float rpm) const;
bool isALSMaxRPMCondition(int rpm) const; bool isALSMaxRPMCondition(float rpm) const;
bool isALSMinCLTCondition() const; bool isALSMinCLTCondition() const;
bool isALSMaxCLTCondition() const; bool isALSMaxCLTCondition() const;
bool isALSMaxThrottleIntentCondition() const; bool isALSMaxThrottleIntentCondition() const;
bool isInsideALSSwitchCondition(); bool isInsideALSSwitchCondition();
bool isInsideALSTimerCondition(); bool isInsideALSTimerCondition();
/* enabled and all conditions above */ /* enabled and all conditions above */
bool isAntilagConditionMet(int rpm); bool isAntilagConditionMet(float rpm);
private: private:
Timer ALStimer; Timer ALStimer;

View File

@ -222,7 +222,7 @@ void Engine::updateSlowSensors() {
updateSwitchInputs(); updateSwitchInputs();
#if EFI_SHAFT_POSITION_INPUT #if EFI_SHAFT_POSITION_INPUT
int rpm = Sensor::getOrZero(SensorType::Rpm); float rpm = Sensor::getOrZero(SensorType::Rpm);
triggerCentral.isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold; triggerCentral.isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold;
getEngineState()->sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF; getEngineState()->sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;

View File

@ -256,7 +256,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
} }
#endif // HW_CHECK_MODE #endif // HW_CHECK_MODE
int rpm = engine->rpmCalculator.getCachedRpm(); float rpm = engine->rpmCalculator.getCachedRpm();
if (rpm == 0) { if (rpm == 0) {
// this happens while we just start cranking // this happens while we just start cranking

View File

@ -374,7 +374,7 @@ void tdcMarkCallback(
// two instances of scheduling_s are needed to properly handle event overlap // two instances of scheduling_s are needed to properly handle event overlap
int revIndex2 = getRevolutionCounter() % 2; int revIndex2 = getRevolutionCounter() % 2;
int rpm = Sensor::getOrZero(SensorType::Rpm); float rpm = Sensor::getOrZero(SensorType::Rpm);
// todo: use tooth event-based scheduling, not just time-based scheduling // todo: use tooth event-based scheduling, not just time-based scheduling
if (isValidRpm(rpm)) { if (isValidRpm(rpm)) {
angle_t tdcPosition = tdcPosition(); angle_t tdcPosition = tdcPosition();

View File

@ -380,7 +380,7 @@ void turnSparkPinHighStartCharging(IgnitionEvent *event) {
#endif #endif
static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event, static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
int rpm, float dwellMs, float dwellAngle, float sparkAngle, efitick_t edgeTimestamp, float currentPhase, float nextPhase) { float rpm, float dwellMs, float dwellAngle, float sparkAngle, efitick_t edgeTimestamp, float currentPhase, float nextPhase) {
float angleOffset = dwellAngle - currentPhase; float angleOffset = dwellAngle - currentPhase;
if (angleOffset < 0) { if (angleOffset < 0) {
@ -529,11 +529,10 @@ static void prepareIgnitionSchedule() {
initializeIgnitionActions(); initializeIgnitionActions();
} }
void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase) { void onTriggerEventSparkLogic(float rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase) {
ScopePerf perf(PE::OnTriggerEventSparkLogic); ScopePerf perf(PE::OnTriggerEventSparkLogic);
if (!isValidRpm(rpm) || !engineConfiguration->isIgnitionEnabled) { if (!engineConfiguration->isIgnitionEnabled) {
// this might happen for instance in case of a single trigger event after a pause
return; return;
} }
@ -545,7 +544,7 @@ void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPha
const floatms_t dwellMs = engine->ignitionState.sparkDwell; const floatms_t dwellMs = engine->ignitionState.sparkDwell;
if (std::isnan(dwellMs) || dwellMs <= 0) { if (std::isnan(dwellMs) || dwellMs <= 0) {
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm); warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f", dwellMs);
return; return;
} }
@ -666,7 +665,7 @@ int getNumberOfSparks(ignition_mode_e mode) {
/** /**
* @see getInjectorDutyCycle * @see getInjectorDutyCycle
*/ */
percent_t getCoilDutyCycle(int rpm) { percent_t getCoilDutyCycle(float rpm) {
floatms_t totalPerCycle = engine->ignitionState.sparkDwell * getNumberOfSparks(getCurrentIgnitionMode()); floatms_t totalPerCycle = engine->ignitionState.sparkDwell * getNumberOfSparks(getCurrentIgnitionMode());
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (getEngineRotationState()->getOperationMode() == TWO_STROKE ? 1 : 2); floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (getEngineRotationState()->getOperationMode() == TWO_STROKE ? 1 : 2);
return 100 * totalPerCycle / engineCycleDuration; return 100 * totalPerCycle / engineCycleDuration;

View File

@ -7,11 +7,11 @@
#pragma once #pragma once
void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase); void onTriggerEventSparkLogic(float rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase);
void turnSparkPinHighStartCharging(IgnitionEvent *event); void turnSparkPinHighStartCharging(IgnitionEvent *event);
void fireSparkAndPrepareNextSchedule(IgnitionEvent *event); void fireSparkAndPrepareNextSchedule(IgnitionEvent *event);
int getNumberOfSparks(ignition_mode_e mode); int getNumberOfSparks(ignition_mode_e mode);
// fact: getInjectorDutyCycle is used by limpManager as cut reason but coil duty cycle is only logged not considered for control strategy // fact: getInjectorDutyCycle is used by limpManager as cut reason but coil duty cycle is only logged not considered for control strategy
// see also maxAllowedDwellAngle which only produces a warning without cutting spark // see also maxAllowedDwellAngle which only produces a warning without cutting spark
percent_t getCoilDutyCycle(int rpm); percent_t getCoilDutyCycle(float rpm);
void initializeIgnitionActions(); void initializeIgnitionActions();

View File

@ -10,7 +10,7 @@ static SimplePwm pwms[VR_THRESHOLD_COUNT];
#define VR_SUPPLY_VOLTAGE 3.3f #define VR_SUPPLY_VOLTAGE 3.3f
#endif #endif
static void updateVrThresholdPwm(int rpm, size_t index) { static void updateVrThresholdPwm(float rpm, size_t index) {
auto& cfg = engineConfiguration->vrThreshold[index]; auto& cfg = engineConfiguration->vrThreshold[index];
if (!isBrainPinValid(cfg.pin)) { if (!isBrainPinValid(cfg.pin)) {

View File

@ -212,7 +212,7 @@ static void reportWave(Logging *logging, int index) {
logging->appendPrintf("%s", LOG_DELIMITER); logging->appendPrintf("%s", LOG_DELIMITER);
efitimeus_t offsetUs = getWaveOffset(index); efitimeus_t offsetUs = getWaveOffset(index);
int rpm = Sensor::getOrZero(SensorType::Rpm); float rpm = Sensor::getOrZero(SensorType::Rpm);
if (rpm != 0) { if (rpm != 0) {
float oneDegreeUs = getOneDegreeTimeUs(rpm); float oneDegreeUs = getOneDegreeTimeUs(rpm);