From f4605e31957818a36cb45b99525a1940c260474e Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Tue, 21 Nov 2023 11:14:26 -0800 Subject: [PATCH] Plane: wrap Watt Limiiter in #if AP_BATTERY_WATT_MAX_ENABLED --- ArduPlane/Plane.h | 2 ++ ArduPlane/servos.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index d2fd912d4d293d..80e3cb8636ce1e 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -586,10 +586,12 @@ class Plane : public AP_Vehicle { // this controls throttle suppression in auto modes bool throttle_suppressed; +#if AP_BATTERY_WATT_MAX_ENABLED // reduce throttle to eliminate battery over-current int8_t throttle_watt_limit_max; int8_t throttle_watt_limit_min; // for reverse thrust uint32_t throttle_watt_limit_timer_ms; +#endif AP_FixedWing::FlightStage flight_stage = AP_FixedWing::FlightStage::NORMAL; diff --git a/ArduPlane/servos.cpp b/ArduPlane/servos.cpp index 85fe2689f3765a..729e67089e528a 100644 --- a/ArduPlane/servos.cpp +++ b/ArduPlane/servos.cpp @@ -422,6 +422,7 @@ void Plane::throttle_voltage_comp(int8_t &min_throttle, int8_t &max_throttle) co /* calculate any throttle limits based on the watt limiter */ +#if AP_BATTERY_WATT_MAX_ENABLED void Plane::throttle_watt_limiter(int8_t &min_throttle, int8_t &max_throttle) { uint32_t now = millis(); @@ -466,6 +467,7 @@ void Plane::throttle_watt_limiter(int8_t &min_throttle, int8_t &max_throttle) min_throttle = constrain_int16(min_throttle, min_throttle + throttle_watt_limit_min, 0); } } +#endif // #if AP_BATTERY_WATT_MAX_ENABLED /* setup output channels all non-manual modes @@ -509,8 +511,10 @@ void Plane::set_servos_controlled(void) // compensate for battery voltage drop throttle_voltage_comp(min_throttle, max_throttle); +#if AP_BATTERY_WATT_MAX_ENABLED // apply watt limiter throttle_watt_limiter(min_throttle, max_throttle); +#endif SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, constrain_float(SRV_Channels::get_output_scaled(SRV_Channel::k_throttle), min_throttle, max_throttle));