Plane: wrap Watt Limiiter in #if AP_BATTERY_WATT_MAX_ENABLED

This commit is contained in:
Tom Pittenger 2023-11-21 11:14:26 -08:00 committed by Peter Barker
parent 496125a8cb
commit b468af81ac
2 changed files with 6 additions and 0 deletions

View File

@ -586,10 +586,12 @@ private:
// this controls throttle suppression in auto modes // this controls throttle suppression in auto modes
bool throttle_suppressed; bool throttle_suppressed;
#if AP_BATTERY_WATT_MAX_ENABLED
// reduce throttle to eliminate battery over-current // reduce throttle to eliminate battery over-current
int8_t throttle_watt_limit_max; int8_t throttle_watt_limit_max;
int8_t throttle_watt_limit_min; // for reverse thrust int8_t throttle_watt_limit_min; // for reverse thrust
uint32_t throttle_watt_limit_timer_ms; uint32_t throttle_watt_limit_timer_ms;
#endif
AP_FixedWing::FlightStage flight_stage = AP_FixedWing::FlightStage::NORMAL; AP_FixedWing::FlightStage flight_stage = AP_FixedWing::FlightStage::NORMAL;

View File

@ -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 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) void Plane::throttle_watt_limiter(int8_t &min_throttle, int8_t &max_throttle)
{ {
uint32_t now = millis(); 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); 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 setup output channels all non-manual modes
@ -509,8 +511,10 @@ void Plane::set_servos_controlled(void)
// compensate for battery voltage drop // compensate for battery voltage drop
throttle_voltage_comp(min_throttle, max_throttle); throttle_voltage_comp(min_throttle, max_throttle);
#if AP_BATTERY_WATT_MAX_ENABLED
// apply watt limiter // apply watt limiter
throttle_watt_limiter(min_throttle, max_throttle); throttle_watt_limiter(min_throttle, max_throttle);
#endif
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, SRV_Channels::set_output_scaled(SRV_Channel::k_throttle,
constrain_float(SRV_Channels::get_output_scaled(SRV_Channel::k_throttle), min_throttle, max_throttle)); constrain_float(SRV_Channels::get_output_scaled(SRV_Channel::k_throttle), min_throttle, max_throttle));