min/maxF -> std::min/max

This commit is contained in:
Matthew Kennedy 2024-09-25 17:00:33 -04:00 committed by Andrey
parent c3bc395cf5
commit e26f1b0c93
4 changed files with 20 additions and 16 deletions

View File

@ -350,7 +350,7 @@ expected<percent_t> EtbController::getSetpointEtb() {
// Keep the throttle just barely off the lower stop, and less than the user-configured maximum
float maxPosition = engineConfiguration->etbMaximumPosition;
// Don't allow max position over 100
maxPosition = minF(maxPosition, 100);
maxPosition = std::min(maxPosition, 100.0f);
targetPosition = clampF(minPosition, targetPosition, maxPosition);
etbCurrentAdjustedTarget = targetPosition;

View File

@ -53,17 +53,17 @@ float TpsAccelEnrichment::getTpsEnrichment() {
isFractionalEnrichment = engineConfiguration->tpsAccelFractionPeriod > 1 || engineConfiguration->tpsAccelFractionDivisor > 1.0f;
if (isFractionalEnrichment) {
// make sure both values are non-zero
float periodF = (float)maxI(engineConfiguration->tpsAccelFractionPeriod, 1);
float divisor = maxF(engineConfiguration->tpsAccelFractionDivisor, 1.0f);
float periodF = std::max<int>(engineConfiguration->tpsAccelFractionPeriod, 1);
float divisor = std::max(engineConfiguration->tpsAccelFractionDivisor, 1.0f);
// if current extra fuel portion is not "strong" enough, then we keep up the "pump pressure" with the accumulated portion
floatms_t maxExtraFuel = maxF(extraFuel, accumulatedValue);
floatms_t maxExtraFuel = std::max(extraFuel, accumulatedValue);
// use only a fixed fraction of the accumulated portion
fractionalInjFuel = maxExtraFuel / divisor;
// update max counters
maxExtraPerCycle = maxF(extraFuel, maxExtraPerCycle);
maxInjectedPerPeriod = maxF(fractionalInjFuel, maxInjectedPerPeriod);
maxExtraPerCycle = std::max(extraFuel, maxExtraPerCycle);
maxInjectedPerPeriod = std::max(fractionalInjFuel, maxInjectedPerPeriod);
// evenly split it between several engine cycles
extraFuel = fractionalInjFuel / periodF;
@ -87,7 +87,7 @@ void TpsAccelEnrichment::onEngineCycleTps() {
// we used some extra fuel during the current cycle, so we "charge" our "acceleration pump" with it
accumulatedValue -= maxExtraPerPeriod;
maxExtraPerPeriod = maxF(maxExtraPerCycle, maxExtraPerPeriod);
maxExtraPerPeriod = std::max(maxExtraPerCycle, maxExtraPerPeriod);
maxExtraPerCycle = 0;
accumulatedValue += maxExtraPerPeriod;

View File

@ -31,17 +31,21 @@ static void setDefaultIatTimingCorrection() {
}
static float getAdvanceForRpm(float rpm, float advanceMax) {
if (rpm >= 3000)
return advanceMax;
if (rpm < 600)
return 10;
return interpolateMsg("advance", 600, 10, 3000, advanceMax, rpm);
if (rpm >= 3000) {
return advanceMax;
}
if (rpm < 600) {
return 10;
}
return interpolateMsg("advance", 600, 10, 3000, advanceMax, rpm);
}
#define round10(x) efiRound(x, 0.1)
float getInitialAdvance(float rpm, float map, float advanceMax) {
map = minF(map, 100);
map = std::min(map, 100.0f);
float advance = getAdvanceForRpm(rpm, advanceMax);
if (rpm >= 3000)

View File

@ -68,7 +68,7 @@ float ClosedLoopFuelCellImpl::getMaxAdjustment() const {
float raw = m_config->maxAdd * 0.01f;
// Don't allow maximum less than 0, or more than maximum adjustment
return minF(MAX_ADJ, maxF(raw, 0));
return clampF(0, raw, MAX_ADJ);
}
float ClosedLoopFuelCellImpl::getMinAdjustment() const {
@ -79,7 +79,7 @@ float ClosedLoopFuelCellImpl::getMinAdjustment() const {
float raw = m_config->maxRemove * 0.01f;
// Don't allow minimum more than 0, or more than maximum adjustment
return maxF(-MAX_ADJ, minF(raw, 0));
return clampF(-MAX_ADJ, raw, 0);
}
float ClosedLoopFuelCellImpl::getIntegratorGain() const {
@ -89,7 +89,7 @@ float ClosedLoopFuelCellImpl::getIntegratorGain() const {
}
// Clamp to reasonable limits - 100ms to 100s
float timeConstant = maxF(0.1f, minF(m_config->timeConstant, 100));
float timeConstant = clampF(0.1f, m_config->timeConstant, 100);
return 1 / timeConstant;
}