Plane: fixed int8_t wrap with FWD_BAT_VOLT_MAX

this could cause crazy throttle values when the ratio pushes us over
127
This commit is contained in:
Andrew Tridgell 2022-06-22 21:41:48 +10:00
parent 0cd1f605f6
commit 3ffef61aec
1 changed files with 2 additions and 2 deletions

View File

@ -430,8 +430,8 @@ void Plane::throttle_voltage_comp(int8_t &min_throttle, int8_t &max_throttle) co
const float ratio = g2.fwd_thr_batt_voltage_max / batt_voltage_resting_estimate;
// Scale the throttle limits to prevent subsequent clipping
min_throttle = MAX((int8_t)(ratio * (float)min_throttle), -100);
max_throttle = MIN((int8_t)(ratio * (float)max_throttle), 100);
min_throttle = int8_t(MAX((ratio * (float)min_throttle), -100));
max_throttle = int8_t(MIN((ratio * (float)max_throttle), 100));
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle,
constrain_float(SRV_Channels::get_output_scaled(SRV_Channel::k_throttle) * ratio, -100, 100));