Browse Source

Plane: move support for inverted flight to rc-aux-switch

Functional change here; if someone de-configures the rc aux switch in
flight they will remain inverted
master
Peter Barker 7 years ago committed by Andrew Tridgell
parent
commit
b574f4c1fc
  1. 7
      ArduPlane/Parameters.cpp
  2. 3
      ArduPlane/Parameters.h
  3. 4
      ArduPlane/RC_Channel.cpp
  4. 4
      ArduPlane/config.h
  5. 13
      ArduPlane/control_modes.cpp

7
ArduPlane/Parameters.cpp

@ -821,13 +821,6 @@ const AP_Param::Info Plane::var_info[] = { @@ -821,13 +821,6 @@ const AP_Param::Info Plane::var_info[] = {
GSCALAR(override_safety, "OVERRIDE_SAFETY", 1),
#endif
// @Param: INVERTEDFLT_CH
// @DisplayName: Inverted flight channel
// @Description: A RC input channel number to enable inverted flight. If this is non-zero then the APM will monitor the corresponding RC input channel and will enable inverted flight when the channel goes above 1750.
// @Values: 0:Disabled,1:Channel1,2:Channel2,3:Channel3,4:Channel4,5:Channel5,6:Channel6,7:Channel7,8:Channel8
// @User: Standard
GSCALAR(inverted_flight_ch, "INVERTEDFLT_CH", 0),
#if HIL_SUPPORT
// @Param: HIL_MODE
// @DisplayName: HIL mode enable

3
ArduPlane/Parameters.h

@ -215,7 +215,7 @@ public: @@ -215,7 +215,7 @@ public:
k_param_pitch_limit_min_cd,
k_param_airspeed_cruise_cm,
k_param_RTL_altitude_cm,
k_param_inverted_flight_ch,
k_param_inverted_flight_ch_unused, // unused
k_param_min_gndspeed_cm,
k_param_crosstrack_use_wind, // unused
@ -467,7 +467,6 @@ public: @@ -467,7 +467,6 @@ public:
AP_Int8 flap_2_percent;
AP_Int8 flap_2_speed;
AP_Int8 takeoff_flap_percent;
AP_Int8 inverted_flight_ch; // 0=disabled, 1-8 is channel for inverted flight trigger
AP_Int8 stick_mixing;
AP_Float takeoff_throttle_min_speed;
AP_Float takeoff_throttle_min_accel;

4
ArduPlane/RC_Channel.cpp

@ -33,6 +33,7 @@ void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option, @@ -33,6 +33,7 @@ void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
switch(ch_option) {
// the following functions do not need to be initialised:
case ARMDISARM:
case INVERTED:
break;
default:
RC_Channel::init_aux_function(ch_option, ch_flag);
@ -58,6 +59,9 @@ void RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const aux_swi @@ -58,6 +59,9 @@ void RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const aux_swi
break;
}
break;
case INVERTED:
plane.inverted_flight = (ch_flag == HIGH);
break;
default:
RC_Channel::do_aux_function(ch_option, ch_flag);
break;

4
ArduPlane/config.h

@ -292,10 +292,6 @@ @@ -292,10 +292,6 @@
# define USE_CURRENT_ALT FALSE
#endif
#ifndef INVERTED_FLIGHT_PWM
# define INVERTED_FLIGHT_PWM 1750
#endif
#ifndef PX4IO_OVERRIDE_PWM
# define PX4IO_OVERRIDE_PWM 1750
#endif

13
ArduPlane/control_modes.cpp

@ -52,12 +52,6 @@ void Plane::read_control_switch() @@ -52,12 +52,6 @@ void Plane::read_control_switch()
switch_debouncer = false;
if (g.inverted_flight_ch != 0) {
// if the user has configured an inverted flight channel, then
// fly upside down when that channel goes above INVERTED_FLIGHT_PWM
inverted_flight = (control_mode != MANUAL && RC_Channels::get_radio_in(g.inverted_flight_ch-1) > INVERTED_FLIGHT_PWM);
}
#if PARACHUTE == ENABLED
if (g.parachute_channel > 0) {
if (RC_Channels::get_radio_in(g.parachute_channel-1) >= 1700) {
@ -151,8 +145,11 @@ void Plane::autotune_enable(bool enable) @@ -151,8 +145,11 @@ void Plane::autotune_enable(bool enable)
*/
bool Plane::fly_inverted(void)
{
if (g.inverted_flight_ch != 0 && inverted_flight) {
// controlled with INVERTED_FLIGHT_CH
if (control_mode == MANUAL) {
return false;
}
if (inverted_flight) {
// controlled with aux switch
return true;
}
if (control_mode == AUTO && auto_state.inverted_flight) {

Loading…
Cancel
Save