Plane: don't change trims if radio_in is zero

This commit is contained in:
Andrew Tridgell 2013-01-25 14:27:44 +11:00
parent 9b4c75c66b
commit 9178022a73

View File

@ -176,23 +176,33 @@ static void trim_control_surfaces()
// Store control surface trim values // Store control surface trim values
// --------------------------------- // ---------------------------------
if(g.mix_mode == 0) { if(g.mix_mode == 0) {
if (g.channel_roll.radio_in != 0) {
g.channel_roll.radio_trim = g.channel_roll.radio_in; g.channel_roll.radio_trim = g.channel_roll.radio_in;
}
if (g.channel_pitch.radio_in != 0) {
g.channel_pitch.radio_trim = g.channel_pitch.radio_in; g.channel_pitch.radio_trim = g.channel_pitch.radio_in;
}
// the secondary aileron is trimmed only if it has a // the secondary aileron is trimmed only if it has a
// corresponding transmitter input channel, which k_aileron // corresponding transmitter input channel, which k_aileron
// doesn't have // doesn't have
RC_Channel_aux::set_radio_trim(RC_Channel_aux::k_aileron_with_input); RC_Channel_aux::set_radio_trim(RC_Channel_aux::k_aileron_with_input);
} else{ } else{
if (ch1_temp != 0) {
elevon1_trim = ch1_temp; elevon1_trim = ch1_temp;
}
if (ch2_temp != 0) {
elevon2_trim = ch2_temp; elevon2_trim = ch2_temp;
}
//Recompute values here using new values for elevon1_trim and elevon2_trim //Recompute values here using new values for elevon1_trim and elevon2_trim
//We cannot use radio_in[CH_ROLL] and radio_in[CH_PITCH] values from read_radio() because the elevon trim values have changed //We cannot use radio_in[CH_ROLL] and radio_in[CH_PITCH] values from read_radio() because the elevon trim values have changed
uint16_t center = 1500; uint16_t center = 1500;
g.channel_roll.radio_trim = center; g.channel_roll.radio_trim = center;
g.channel_pitch.radio_trim = center; g.channel_pitch.radio_trim = center;
} }
if (g.channel_rudder.radio_in != 0) {
g.channel_rudder.radio_trim = g.channel_rudder.radio_in; g.channel_rudder.radio_trim = g.channel_rudder.radio_in;
}
// save to eeprom // save to eeprom
g.channel_roll.save_eeprom(); g.channel_roll.save_eeprom();