From 98d8d7fb5f2cb7e1f5c2c4d0271f3f8b0c16d145 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Mon, 11 Jul 2022 09:03:31 +0200 Subject: [PATCH] FX/FX620 new protocol --- Lua_scripts/MultiChan.txt | 3 +- Multiprotocol/FX816_nrf24l01.ino | 100 ----------------- Multiprotocol/FX_nrf24l01.ino | 177 +++++++++++++++++++++++++++++++ Multiprotocol/Multi.txt | 2 +- Multiprotocol/Multi_Protos.ino | 8 +- Multiprotocol/Multiprotocol.h | 21 ++-- Multiprotocol/Validate.h | 2 +- Multiprotocol/_Config.h | 7 +- 8 files changed, 196 insertions(+), 124 deletions(-) delete mode 100644 Multiprotocol/FX816_nrf24l01.ino create mode 100644 Multiprotocol/FX_nrf24l01.ino diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index e286974..8f29dce 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -86,7 +86,8 @@ 55,1,FrSkyRX,CloneTX,0 55,2,FrSkyRX,EraseTX,0 55,3,FrSkyRX,CPPM,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16 -58,0,FX816,Std,1 +58,0,FX,816,1 +58,1,FX,620,1 20,0,FY326,FY326,1,Flip,RTH,HLess,Expert,Calib 20,1,FY326,FY319,1,Flip,RTH,HLess,Expert,Calib 23,0,FY326,FY326,1,Flip,RTH,HLess,Expert diff --git a/Multiprotocol/FX816_nrf24l01.ino b/Multiprotocol/FX816_nrf24l01.ino deleted file mode 100644 index eac739f..0000000 --- a/Multiprotocol/FX816_nrf24l01.ino +++ /dev/null @@ -1,100 +0,0 @@ -/* - This project is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - -Multiprotocol is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Multiprotocol. If not, see . - */ -// Compatible with FEI XIONG P38 plane. - -#if defined(FX816_NRF24L01_INO) - -#include "iface_xn297.h" - -#define FX816_INITIAL_WAIT 500 -#define FX816_PACKET_PERIOD 10000 -#define FX816_RF_BIND_CHANNEL 0x28 //40 -#define FX816_RF_NUM_CHANNELS 4 -#define FX816_PAYLOAD_SIZE 6 -#define FX816_BIND_COUNT 300 //3sec - -static void __attribute__((unused)) FX816_send_packet() -{ - if(IS_BIND_IN_PROGRESS) - packet[0] = 0x55; - else - { - XN297_Hopping(hopping_frequency_no++); - hopping_frequency_no%=FX816_RF_NUM_CHANNELS; - packet[0] = 0xAA; - } - packet[1] = rx_tx_addr[0]; - packet[2] = rx_tx_addr[1]; - uint8_t val=convert_channel_8b(AILERON); - #define FX816_SWITCH 20 - if(val>127+FX816_SWITCH) - packet[3] = 1; - else if(val<127-FX816_SWITCH) - packet[3] = 2; - else - packet[3] = 0; - packet[4] = convert_channel_16b_limit(THROTTLE,0,100); - val=0; - for(uint8_t i=0;i. + */ +// Compatible with FEI XIONG P38 plane. + +#if defined(FX_NRF24L01_INO) + +#include "iface_xn297.h" + +#define FX_INITIAL_WAIT 500 +#define FX_BIND_COUNT 300 //3sec +#define FX_SWITCH 20 + +#define FX816_PACKET_PERIOD 10000 +#define FX816_BIND_CHANNEL 40 +#define FX816_NUM_CHANNELS 4 +#define FX816_PAYLOAD_SIZE 6 + +#define FX620_PACKET_PERIOD 3250 +#define FX620_BIND_CHANNEL 18 +#define FX620_PAYLOAD_SIZE 7 +#define FX620_NUM_CHANNELS 6 + +#define FORCE_FX620_ID + +static void __attribute__((unused)) FX_send_packet() +{ + //Hopp + if(IS_BIND_DONE) + { + XN297_Hopping(hopping_frequency_no++); + hopping_frequency_no %= sub_protocol == FX816 ? FX816_NUM_CHANNELS:FX620_NUM_CHANNELS; + } + + memset(packet,0x00,packet_length); + + //Channels + uint8_t offset=sub_protocol == FX816 ? 3:1; + uint8_t val=convert_channel_8b(AILERON); // Can FX620 have a proportional value, the original radio does not but... + if(val>127+FX_SWITCH) + packet[offset] = sub_protocol == FX816 ? 1:0xFF; + else if(val<127-FX_SWITCH) + packet[offset] = sub_protocol == FX816 ? 2:0x00; + else + packet[offset] = sub_protocol == FX816 ? 0:0x7F; + packet[offset+1] = convert_channel_16b_limit(THROTTLE,0,100); + + //Bind and specifics + if(sub_protocol == FX816) + { + if(IS_BIND_IN_PROGRESS) + packet[0] = 0x55; + else + packet[0] = 0xAA; + packet[1] = rx_tx_addr[0]; + packet[2] = rx_tx_addr[1]; + } + else //FX620 + { + if(IS_BIND_IN_PROGRESS) + { + memcpy(packet,rx_tx_addr,3); + packet[3] = hopping_frequency[0]; + } + else + { + packet[0] = 0x1F; // Is it based on ID?? + packet[5] = 0xAB; // Is it based on ID?? + } + } + + //Check + val=0; + for(uint8_t i=0;iCC2500 PROTO_AFHDS2A_RX= 56, // =>A7105 PROTO_HOTT = 57, // =>CC2500 - PROTO_FX816 = 58, // =>NRF24L01 + PROTO_FX = 58, // =>NRF24L01 PROTO_BAYANG_RX = 59, // =>NRF24L01 PROTO_PELIKAN = 60, // =>A7105 PROTO_TIGER = 61, // =>NRF24L01 @@ -390,7 +390,6 @@ enum ESKY ESKY_STD = 0, ESKY_ET4 = 1, }; - enum FRSKY_RX { FRSKY_RX = 0, @@ -398,74 +397,68 @@ enum FRSKY_RX FRSKY_ERASE = 2, FRSKY_CPPM = 3, }; - enum FRSKYL { LR12 = 0, LR12_6CH = 1, }; - enum HOTT { HOTT_SYNC = 0, HOTT_NO_SYNC= 1, }; - enum PELIKAN { PELIKAN_PRO = 0, PELIKAN_LITE= 1, PELIKAN_SCX24=2, }; - enum V761 { V761_3CH = 0, V761_4CH = 1, }; - enum HEIGHT { HEIGHT_5CH = 0, HEIGHT_8CH = 1, }; - enum KYOSHO { KYOSHO_FHSS = 0, KYOSHO_HYPE = 1, }; - enum JJRC345 { JJRC345 = 0, SKYTMBLR = 1, }; - enum RLINK { RLINK_SURFACE = 0, RLINK_AIR = 1, RLINK_DUMBORC = 2, }; - enum MOULDKG { MOULDKG_ANALOG = 0, MOULDKG_DIGIT = 1, }; - enum KF606 { KF606_KF606 = 0, KF606_MIG320 = 1, }; - enum E129 { E129_E129 = 0, E129_C186 = 1, }; +enum FX +{ + FX816 = 0, + FX620 = 1, +}; #define NONE 0 #define P_HIGH 1 @@ -911,7 +904,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- FRSKY_RX 55 AFHDS2A_RX 56 HOTT 57 - FX816 58 + FX 58 BAYANG_RX 59 PELIKAN 60 TIGER 61 diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 08d9763..1cee078 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -299,7 +299,7 @@ #undef ESKY_NRF24L01_INO #undef ESKY150_NRF24L01_INO #undef FQ777_NRF24L01_INO - #undef FX816_NRF24L01_INO + #undef FX_NRF24L01_INO #undef FY326_NRF24L01_INO #undef GW008_NRF24L01_INO #undef H8_3D_NRF24L01_INO diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 1732c39..9200981 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -229,7 +229,7 @@ #define ESKY_NRF24L01_INO #define ESKY150_NRF24L01_INO #define FQ777_NRF24L01_INO -#define FX816_NRF24L01_INO +#define FX_NRF24L01_INO #define FY326_NRF24L01_INO #define GW008_NRF24L01_INO #define HISKY_NRF24L01_INO @@ -666,8 +666,9 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { PROTO_FRSKY_RX FRSKY_RX FRSKY_CLONE - PROTO_FX816 - NONE + PROTO_FX + FX816 + FX620 PROTO_FY326 FY326 FY319