Plane: avoid doing radio trim if less than 20% of travel available

this prevents problems with awful trim on bootup due to RC TX being
off
This commit is contained in:
Andrew Tridgell 2013-04-12 12:47:59 +10:00
parent cdb532a594
commit c47bc09a3c
1 changed files with 13 additions and 0 deletions

View File

@ -173,6 +173,19 @@ static void control_failsafe(uint16_t pwm)
static void trim_control_surfaces()
{
read_radio();
int16_t trim_roll_range = (g.channel_roll.radio_max - g.channel_roll.radio_min)/5;
int16_t trim_pitch_range = (g.channel_pitch.radio_max - g.channel_pitch.radio_min)/5;
if (g.channel_roll.radio_in < g.channel_roll.radio_min+trim_roll_range ||
g.channel_roll.radio_in > g.channel_roll.radio_max-trim_roll_range ||
g.channel_pitch.radio_in < g.channel_pitch.radio_min+trim_pitch_range ||
g.channel_pitch.radio_in > g.channel_pitch.radio_max-trim_pitch_range) {
// don't trim for extreme values - if we attempt to trim so
// there is less than 20 percent range left then assume the
// sticks are not properly centered. This also prevents
// problems with starting APM with the TX off
return;
}
// Store control surface trim values
// ---------------------------------
if(g.mix_mode == 0) {