rc_update: throttle trim centering fix for reverse channel

The entire logic did not work for the case when the throttle channel is
reversed because then QGC sets trim = max for that channel and
the result is only half the throttle range.
This commit is contained in:
Matthias Grob 2023-06-05 14:02:36 +02:00
parent 7cbf720d26
commit f34fbdf0d3
1 changed files with 5 additions and 1 deletions

View File

@ -210,8 +210,12 @@ void RCUpdate::parameters_updated()
const uint16_t throttle_min = _parameters.min[throttle_channel];
const uint16_t throttle_trim = _parameters.trim[throttle_channel];
const uint16_t throttle_max = _parameters.max[throttle_channel];
const bool throttle_rev = _parameters.rev[throttle_channel];
if (throttle_min == throttle_trim) {
const bool normal_case = !throttle_rev && (throttle_trim == throttle_min);
const bool reversed_case = throttle_rev && (throttle_trim == throttle_max);
if (normal_case || reversed_case) {
const uint16_t new_throttle_trim = (throttle_min + throttle_max) / 2;
_parameters.trim[throttle_channel] = new_throttle_trim;
}