From 0d0acb9d10e4817de3095e984c0b081a44ddd0d0 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Mon, 2 Jan 2017 17:04:50 +0100 Subject: [PATCH] Bind function on channel 16 Toggling channel 16 (-100%->+100%->-100%) will execute a bind only if the loaded protocol is an autobind protocol or autobind is set AND throttle is low (below -95%). --- Multiprotocol/Multiprotocol.h | 5 +++++ Multiprotocol/Multiprotocol.ino | 21 +++++++++++++++------ Multiprotocol/_Config.h | 11 ++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index caf3745..d852b14 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -265,6 +265,11 @@ enum MultiPacketTypes { #define INPUT_SIGNAL_on protocol_flags2 |= _BV(5) #define IS_INPUT_SIGNAL_on ( ( protocol_flags2 & _BV(5) ) !=0 ) #define IS_INPUT_SIGNAL_off ( ( protocol_flags2 & _BV(5) ) ==0 ) +//CH16 +#define CH16_PREV_off protocol_flags2 &= ~_BV(6) +#define CH16_PREV_on protocol_flags2 |= _BV(6) +#define IS_CH16_PREV_on ( ( protocol_flags2 & _BV(6) ) !=0 ) +#define IS_CH16_PREV_off ( ( protocol_flags2 & _BV(6) ) ==0 ) //******************** //*** Blink timing *** diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 02f8d06..285d29f 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -460,12 +460,6 @@ void Update_All() if(mode_select==MODE_SERIAL && IS_RX_FLAG_on) // Serial mode and something has been received { update_serial_data(); // Update protocol and data - if(IS_CHANGE_PROTOCOL_FLAG_on) - { // Protocol needs to be changed - LED_off; //led off during protocol init - modules_reset(); //reset all modules - protocol_init(); //init new protocol - } INPUT_SIGNAL_on; //valid signal received last_signal=millis(); } @@ -488,6 +482,21 @@ void Update_All() last_signal=millis(); } #endif //ENABLE_PPM + #ifdef ENABLE_BIND_CH16 + if(IS_AUTOBIND_FLAG_on && IS_CH16_PREV_off && Servo_data[15]>PPM_MAX_COMMAND && Servo_data[THROTTLE]<(servo_min_100+25)) + { // Autobind is on and CH16 went up and Throttle is low + CHANGE_PROTOCOL_FLAG_on; //reload protocol to rebind + CH16_PREV_on; + } + if(IS_CH16_PREV_on && Servo_data[15]