AP_Tuning: added a small dead-zone on mid-point detection

thanks to Leonard for the suggestion
This commit is contained in:
Andrew Tridgell 2016-05-08 18:32:33 +10:00
parent aa38539ecb
commit d72df80968

View File

@ -177,8 +177,11 @@ void AP_Tuning::check_input(uint8_t flightmode)
//hal.console->printf("chan_value %.2f last_channel_value %.2f\n", chan_value, last_channel_value);
if (mid_point_wait) {
if ((chan_value > 0 && last_channel_value > 0) ||
(chan_value < 0 && last_channel_value < 0)) {
// see if we have crossed the mid-point. We use a small deadzone to make it easier
// to move to the "indent" portion of a slider to start tuning
const float dead_zone = 0.02;
if ((chan_value > dead_zone && last_channel_value > 0) ||
(chan_value < -dead_zone && last_channel_value < 0)) {
// still waiting
return;
}