diff --git a/firmware/controllers/math/throttle_model.cpp b/firmware/controllers/math/throttle_model.cpp index c2dcea0834..1ca14d026a 100644 --- a/firmware/controllers/math/throttle_model.cpp +++ b/firmware/controllers/math/throttle_model.cpp @@ -93,8 +93,12 @@ float ThrottleModelBase::estimateThrottleFlow(float tip, float tps, float map, f // What throttle position gives us that flow at 0.95 PR? float throttleAngle95Pr = throttlePositionForFlow(p95Flow, crossoverPr, tip, iat); + throttleModelCrossoverAngle = throttleAngle95Pr; - if (tps > throttleAngle95Pr) { + bool useWotModel = tps > throttleAngle95Pr; + throttleUseWotModel = useWotModel; + + if (useWotModel) { // "WOT" model // Maximum flow if the throttle was removed @@ -128,6 +132,10 @@ expected ThrottleModelBase::estimateThrottleFlow(float map, float tps) { return estimateThrottleFlow(tip.Value, tps, map, iat.Value); } +void ThrottleModelBase::onSlowCallback() { + throttleEstimatedFlow = estimateThrottleFlow(Sensor::getOrZero(SensorType::Map), Sensor::getOrZero(SensorType::Tps1)).value_or(0); +} + float ThrottleModel::effectiveArea(float tps) const { return interpolate2d(tps, config->throttleEstimateEffectiveAreaBins, config->throttleEstimateEffectiveAreaValues); } diff --git a/firmware/controllers/math/throttle_model.h b/firmware/controllers/math/throttle_model.h index b189c1afb3..88c3215bf4 100644 --- a/firmware/controllers/math/throttle_model.h +++ b/firmware/controllers/math/throttle_model.h @@ -2,8 +2,10 @@ #include "throttle_model_generated.h" -struct ThrottleModelBase : public throttle_model_s { +struct ThrottleModelBase : public throttle_model_s, public EngineModule { public: + void onSlowCallback() override; + float estimateThrottleFlow(float tip, float tps, float map, float iat); expected estimateThrottleFlow(float map, float tps); diff --git a/firmware/controllers/math/throttle_model.txt b/firmware/controllers/math/throttle_model.txt index d9edd109a2..10e54f83b8 100644 --- a/firmware/controllers/math/throttle_model.txt +++ b/firmware/controllers/math/throttle_model.txt @@ -1,3 +1,7 @@ struct_no_prefix throttle_model_s - + bit throttleUseWotModel + + int16_t autoscale throttleModelCrossoverAngle;;"%", 0.01, 0, 0, 100, 1 + + float throttleEstimatedFlow;;"kg/s", 1, 0, 0, 5, 4 end_struct