diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index 4338535ccb..274a3aadea 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -26,7 +26,6 @@ static tps_tps_Map3D_t tpsTpsMap; -// todo: eliminate code duplication between these two methods! Some pointer magic would help. floatms_t TpsAccelEnrichment::getTpsEnrichment() { ScopePerf perf(PE::GetTpsEnrichment); @@ -120,7 +119,7 @@ void TpsAccelEnrichment::onEngineCycleTps() { } } -int AccelEnrichment::getMaxDeltaIndex() { +int TpsAccelEnrichment::getMaxDeltaIndex() { int len = minI(cb.getSize(), cb.getCount()); if (len < 2) @@ -143,18 +142,14 @@ int AccelEnrichment::getMaxDeltaIndex() { return resultIndex; } -float AccelEnrichment::getMaxDelta() { +float TpsAccelEnrichment::getMaxDelta() { int index = getMaxDeltaIndex(); return (cb.get(index) - (cb.get(index - 1))); } -void AccelEnrichment::resetAE() { - cb.clear(); -} - void TpsAccelEnrichment::resetAE() { - AccelEnrichment::resetAE(); + cb.clear(); resetFractionValues(); } @@ -166,15 +161,15 @@ void TpsAccelEnrichment::resetFractionValues() { cycleCnt = 0; } -void AccelEnrichment::setLength(int length) { +void TpsAccelEnrichment::setLength(int length) { cb.setSize(length); } -void AccelEnrichment::onNewValue(float currentValue) { +void TpsAccelEnrichment::onNewValue(float currentValue) { cb.add(currentValue); } -AccelEnrichment::AccelEnrichment() { +TpsAccelEnrichment::TpsAccelEnrichment() { resetAE(); cb.setSize(4); } diff --git a/firmware/controllers/algo/accel_enrichment.h b/firmware/controllers/algo/accel_enrichment.h index 9ffc6ff722..74a10c2b43 100644 --- a/firmware/controllers/algo/accel_enrichment.h +++ b/firmware/controllers/algo/accel_enrichment.h @@ -16,24 +16,18 @@ typedef Map3D tps_tps_Map3D_t; -/** - * this object is used for MAP rate-of-change and TPS rate-of-change corrections - */ -class AccelEnrichment : public tps_accel_state_s { +class TpsAccelEnrichment : public tps_accel_state_s { public: - AccelEnrichment(); + TpsAccelEnrichment(); + int getMaxDeltaIndex(); float getMaxDelta(); - void resetAE(); void setLength(int length); cyclic_buffer cb; void onNewValue(float currentValue); int onUpdateInvocationCounter = 0; -}; -class TpsAccelEnrichment : public AccelEnrichment { -public: /** * @return Extra fuel squirt duration for TPS acceleration */