From 45574c0b1aeac07dc5dbb98a5e3cb32eeb3d47ad Mon Sep 17 00:00:00 2001 From: Jason Short Date: Sat, 11 Aug 2012 22:27:04 -0700 Subject: [PATCH] ACM : CH_7 multimode option added --- ArduCopter/control_modes.pde | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ArduCopter/control_modes.pde b/ArduCopter/control_modes.pde index 2a9064fbf7..139034b98d 100644 --- a/ArduCopter/control_modes.pde +++ b/ArduCopter/control_modes.pde @@ -45,18 +45,24 @@ static void reset_control_switch() // set this to your trainer switch static void read_trim_switch() { - /* - // this is the normal operation set by the mission planner - if (g.rc_6.radio_in < CH_6_PWM_TRIGGER){ - g.ch7_option = CH7_FLIP; - }else{ - g.ch7_option = CH7_SAVE_WP; - }*/ + int8_t option; - if(g.ch7_option == CH7_SIMPLE_MODE){ + if(g.ch7_option == CH7_MULTI_MODE){ + if (g.rc_6.radio_in < CH_6_PWM_TRIGGER_LOW){ + option = CH7_FLIP; + }else if (g.rc_6.radio_in > CH_6_PWM_TRIGGER_HIGH){ + option = CH7_SAVE_WP; + }else{ + option = CH7_RTL; + } + }else{ + option = g.ch7_option; + } + + if(option == CH7_SIMPLE_MODE){ do_simple = (g.rc_7.radio_in > CH_7_PWM_TRIGGER); - }else if (g.ch7_option == CH7_FLIP){ + }else if (option == CH7_FLIP){ if (CH7_flag == false && g.rc_7.radio_in > CH_7_PWM_TRIGGER){ CH7_flag = true; @@ -69,7 +75,7 @@ static void read_trim_switch() CH7_flag = false; } - }else if (g.ch7_option == CH7_RTL){ + }else if (option == CH7_RTL){ if (CH7_flag == false && g.rc_7.radio_in > CH_7_PWM_TRIGGER){ CH7_flag = true; set_mode(RTL); @@ -82,7 +88,7 @@ static void read_trim_switch() } } - }else if (g.ch7_option == CH7_SAVE_WP){ + }else if (option == CH7_SAVE_WP){ if (g.rc_7.radio_in > CH_7_PWM_TRIGGER){ // switch is engaged CH7_flag = true; @@ -141,7 +147,7 @@ static void read_trim_switch() // 3 = command total } } - }else if (g.ch7_option == CH7_AUTO_TRIM){ + }else if (option == CH7_AUTO_TRIM){ if (g.rc_7.radio_in > CH_7_PWM_TRIGGER){ auto_level_counter = 10; }