From 4facdf09320453f1db75e082a96f06c1ab92289a Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Mon, 22 Jan 2018 13:23:11 +0100 Subject: [PATCH] FIX OpenTX DSM autodetect --- Multiprotocol/Corona_cc2500.ino | 8 ++++---- Multiprotocol/Multiprotocol.h | 2 +- Multiprotocol/Multiprotocol.ino | 11 ++++++++--- Multiprotocol/Validate.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Multiprotocol/Corona_cc2500.ino b/Multiprotocol/Corona_cc2500.ino index dffef08..7c4de79 100644 --- a/Multiprotocol/Corona_cc2500.ino +++ b/Multiprotocol/Corona_cc2500.ino @@ -115,11 +115,9 @@ static void __attribute__((unused)) CORONA_build_packet() if(state==0 || sub_protocol==COR_V1) { // Build standard packet - // Set channel + // Set RF channel CC2500_WriteReg(CC2500_0A_CHANNR, hopping_frequency[hopping_frequency_no]); - hopping_frequency_no++; - hopping_frequency_no%=CORONA_RF_NUM_CHANNELS; - // Update power + // Update RF power CC2500_SetPower(); // Build packet @@ -155,6 +153,8 @@ static void __attribute__((unused)) CORONA_build_packet() packet[17] = 0x03; break; } + hopping_frequency_no++; + hopping_frequency_no%=CORONA_RF_NUM_CHANNELS; } else { // Send identifier packet for 2.65sec. This is how the RX learns the hopping table after a bind. Why it's not part of the bind like V1 is a mistery... diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index b45870c..7819f6c 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 12 +#define VERSION_PATCH_LEVEL 13 //****************** // Protocols //****************** diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 9d97a4a..66bb32e 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -789,6 +789,8 @@ static void protocol_init() PE1_on; //NRF24L01 antenna RF3 by default PE2_off; //NRF24L01 antenna RF3 by default + debugln("Protocol selected: %d, sub proto %d, rxnum %d, option %d", protocol, sub_protocol, RX_num, option); + switch(protocol) // Init the requested protocol { #ifdef A7105_INSTALLED @@ -1061,7 +1063,6 @@ static void protocol_init() #endif } } - debugln("Protocol selected: %d, sub proto %d, rxnum %d, option %d", protocol, sub_protocol, RX_num, option); #if defined(WAIT_FOR_BIND) && defined(ENABLE_BIND_CH) if( IS_AUTOBIND_FLAG_on && IS_BIND_CH_PREV_off && (cur_protocol[1]&0x80)==0 && mode_select == MODE_SERIAL) @@ -1144,12 +1145,16 @@ void update_serial_data() FAILSAFE_VALUES_on; //failsafe data has been received } #endif + #ifdef BONI + if(CH14_SW) + rx_ok_buff[2]=(rx_ok_buff[2]&0xF0)|((rx_ok_buff[2]+1)&0x0F); // Extremely dangerous, do not enable this!!! This is really for a special case... + #endif if( (rx_ok_buff[0] != cur_protocol[0]) || ((rx_ok_buff[1]&0x5F) != (cur_protocol[1]&0x5F)) || ( (rx_ok_buff[2]&0x7F) != (cur_protocol[2]&0x7F) ) ) { // New model has been selected CHANGE_PROTOCOL_FLAG_on; //change protocol WAIT_BIND_off; - if(IS_AUTOBIND_FLAG_on) - BIND_IN_PROGRESS; //launch bind right away if in autobind mode + if((rx_ok_buff[1]&0x80)!=0 || IS_AUTOBIND_FLAG_on) + BIND_IN_PROGRESS; //launch bind right away if in autobind mode or bind is set else BIND_DONE; protocol=(rx_ok_buff[0]==0x55?0:32) + (rx_ok_buff[1]&0x1F); //protocol no (0-63) bits 4-6 of buff[1] and bit 0 of buf[0] diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 7a02e82..0237f5b 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -47,7 +47,7 @@ // Error if CHECK_FOR_BOOTLOADER is enabled but the 'Flash from TX' bootloader or upload method isn't selected. #if (defined(ARDUINO_MULTI_NO_BOOT) || defined(ARDUINO_MULTI_STM32_NO_BOOT)) && defined(CHECK_FOR_BOOTLOADER) #if defined(STM32_BOARD) - #error "You have enabled CHECK_FOR_BOOTLOADER but not selected the 'Flash from TX' upload method." + #warning "You have enabled CHECK_FOR_BOOTLOADER but not selected the 'Flash from TX' upload method." #else #error "You have enabled CHECK_FOR_BOOTLOADER but not selected the 'Flash from TX' bootloader." #endif