From 39410c290b0b7d2994a6ca845220048cd5ad1821 Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Fri, 16 Apr 2021 14:50:53 +0200 Subject: [PATCH] Pelikan/SCX24: new sub protocol --- Lua_scripts/MultiChan.txt | 1 + Lua_scripts/MultiChannelsUpdater.lua | 8 +- Multiprotocol/A7105_SPI.ino | 5 + Multiprotocol/Multi.txt | 2 +- Multiprotocol/Multi_Protos.ino | 4 +- Multiprotocol/Multiprotocol.h | 4 +- Multiprotocol/Pelikan_a7105.ino | 207 +++++++++++++++++++-------- Multiprotocol/_Config.h | 1 + Protocols_Details.md | 9 ++ 9 files changed, 173 insertions(+), 68 deletions(-) diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index ac5dcef..a80961b 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -134,6 +134,7 @@ 77,0,OMP,M2,0,THold,IdleUp,6G_3D 60,0,Pelikan,PRO_V4,0,CH5,CH6,CH7,CH8 60,1,Pelikan,LITE_V4,0,CH5,CH6,CH7,CH8 +60,2,Pelikan,SCX24,0 51,0,Potensic,A20,1,TakLan,Emerg,Mode,HLess 66,0,Propel,74-Z,1,LEDs,RollCW,RolCCW,Fire,Weapon,Calib,AltHol,TakeOf,Land,Train 29,0,Q2x2,Q222,1,Flip,LED,Mod2,Mod1,HLess,RTH,XCal,YCal diff --git a/Lua_scripts/MultiChannelsUpdater.lua b/Lua_scripts/MultiChannelsUpdater.lua index 3e62d8d..039d166 100644 --- a/Lua_scripts/MultiChannelsUpdater.lua +++ b/Lua_scripts/MultiChannelsUpdater.lua @@ -280,11 +280,15 @@ local function Multi_Init() end --Exceptions on first 4 channels... - if ( protocol == 73 or (protocol == 74 and sub_protocol == 0) ) then -- Kyosho or RadioLink Surface + if ( protocol == 73 or (protocol == 74 and sub_protocol == 0) or (protocol == 60 and sub_protocol == 2) ) then -- Kyosho or RadioLink Surface or Pelikan/SCX24 channel_names[1] = "ST" channel_names[2] = "THR" channel_names[3] = "CH3" - channel_names[4] = "CH4" + if(protocol == 60 and sub_protocol == 2) then + channel_names[4] = "n-a" + else + channel_names[4] = "CH4" + end end if ( protocol == 6 and sub_protocol == 5 ) then -- DSMR channel_names[1] = "ST" diff --git a/Multiprotocol/A7105_SPI.ino b/Multiprotocol/A7105_SPI.ino index df41b18..be324f2 100644 --- a/Multiprotocol/A7105_SPI.ino +++ b/Multiprotocol/A7105_SPI.ino @@ -499,6 +499,11 @@ void A7105_Init(void) vco_calibration1=0x02; break; case PROTO_PELIKAN: + if(sub_protocol == PELIKAN_SCX24) + { + vco_calibration1=0x0A; + break; + } case PROTO_KYOSHO: //sub_protocol Hype vco_calibration1=0x0C; break; diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index 8478705..517328e 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -57,7 +57,7 @@ 57,HoTT,Sync,No_Sync 58,FX816,P38 59,Bayang_RX,Multi,CPPM -60,Pelikan,Pro,Lite +60,Pelikan,Pro,Lite,SCX24 61,Tiger 62,XK,X450,X420 63,XN_DUMP,250K,1M,2M,AUTO diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index e704e4a..6930394 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -148,7 +148,7 @@ const char STR_SUBTYPE_FRSKYL[] = "\x08""LR12\0 ""LR12 6ch"; const char STR_SUBTYPE_WFLY[] = "\x05""WFR0x"; const char STR_SUBTYPE_WFLY2[] = "\x05""RF20x"; const char STR_SUBTYPE_HOTT[] = "\x07""Sync\0 ""No_Sync"; -const char STR_SUBTYPE_PELIKAN[] = "\x04""Pro\0""Lite"; +const char STR_SUBTYPE_PELIKAN[] = "\x05""Pro\0 ""Lite\0""SCX24"; const char STR_SUBTYPE_V761[] = "\x03""3ch""4ch"; const char STR_SUBTYPE_RLINK[] = "\x07""Surface""Air\0 ""DumboRC"; const char STR_SUBTYPE_REALACC[] = "\x03""R11"; @@ -367,7 +367,7 @@ const mm_protocol_definition multi_protocols[] = { {PROTO_OMP, STR_OMP, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, OMP_init, OMP_callback }, #endif #if defined(PELIKAN_A7105_INO) - {PROTO_PELIKAN, STR_PELIKAN, STR_SUBTYPE_PELIKAN, 2, OPTION_NONE, 0, 1, SW_A7105, PELIKAN_init, PELIKAN_callback }, + {PROTO_PELIKAN, STR_PELIKAN, STR_SUBTYPE_PELIKAN, 3, OPTION_NONE, 0, 1, SW_A7105, PELIKAN_init, PELIKAN_callback }, #endif #if defined(POTENSIC_NRF24L01_INO) {PROTO_POTENSIC, STR_POTENSIC, STR_SUBTYPE_POTENSIC, 1, OPTION_NONE, 0, 0, SW_NRF, POTENSIC_init, POTENSIC_callback }, diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 0442842..84ef76c 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 2 -#define VERSION_PATCH_LEVEL 72 +#define VERSION_PATCH_LEVEL 73 #define MODE_SERIAL 0 @@ -400,6 +400,7 @@ enum PELIKAN { PELIKAN_PRO = 0, PELIKAN_LITE= 1, + PELIKAN_SCX24=2, }; enum V761 @@ -1086,6 +1087,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- sub_protocol==PELIKAN PELIKAN_PRO 0 PELIKAN_LITE 1 + PELIKAN_SCX24 2 sub_protocol==V761 V761_3CH 0 V761_4CH 1 diff --git a/Multiprotocol/Pelikan_a7105.ino b/Multiprotocol/Pelikan_a7105.ino index 6354161..20187cd 100644 --- a/Multiprotocol/Pelikan_a7105.ino +++ b/Multiprotocol/Pelikan_a7105.ino @@ -21,29 +21,48 @@ //#define PELIKAN_FORCE_ID //#define PELIKAN_LITE_FORCE_ID #define PELIKAN_LITE_FORCE_HOP +#define PELIKAN_SCX24_FORCE_ID +#define PELIKAN_SCX24_FORCE_HOP #define PELIKAN_BIND_COUNT 400 #define PELIKAN_BIND_RF 0x3C #define PELIKAN_NUM_RF_CHAN 0x1D #define PELIKAN_PACKET_PERIOD 7980 #define PELIKAN_LITE_PACKET_PERIOD 18000 +#define PELIKAN_SCX24_PACKET_PERIOD 15069 static void __attribute__((unused)) pelikan_build_packet() { static boolean upper=false; - packet[0] = 0x15; + uint8_t sum; + uint16_t channel; + + if(sub_protocol == PELIKAN_SCX24) + packet[0] = 0x11; + else //PELIKAN_PRO & PELIKAN_LITE + packet[0] = 0x15; if(IS_BIND_IN_PROGRESS) { - packet[1] = 0x04; //version?? packet[2] = rx_tx_addr[0]; packet[3] = rx_tx_addr[1]; packet[4] = rx_tx_addr[2]; packet[5] = rx_tx_addr[3]; - if(sub_protocol==PELIKAN_PRO) - packet[6] = 0x05; //sub version?? - else //PELIKAN_LITE - packet[6] = 0x03; //sub version?? - packet[7] = 0x00; //?? + + if(sub_protocol == PELIKAN_SCX24) + { + packet[1] = 0x65; + packet[6] = 0x55; + packet[7] = 0xAA; + } + else + {//PELIKAN_PRO & PELIKAN_LITE + packet[1] = 0x04; //version?? + if(sub_protocol==PELIKAN_PRO) + packet[6] = 0x05; //sub version?? + else //PELIKAN_LITE + packet[6] = 0x03; //sub version?? + packet[7] = 0x00; //?? + } packet[8] = 0x55; //?? packet_length = 10; } @@ -51,60 +70,87 @@ static void __attribute__((unused)) pelikan_build_packet() { //ID packet[1] = rx_tx_addr[0]; - packet[7] = rx_tx_addr[1]; - packet[12] = rx_tx_addr[2]; - packet[13] = rx_tx_addr[3]; - //Channels - uint8_t offset=upper?4:0; - uint16_t channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); - uint8_t top=(channel>>2) & 0xC0; - packet[2] = channel; - channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); - top|=(channel>>4) & 0x30; - packet[3] = channel; - channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); - top|=(channel>>6) & 0x0C; - packet[4] = channel; - channel=convert_channel_16b_nolimit(CH_AETR[offset], 153, 871,false); - top|=(channel>>8) & 0x03; - packet[5] = channel; - packet[6] = top; - //Check - crc8=0x15; - for(uint8_t i=1;i<8;i++) - crc8+=packet[i]; - packet[8]=crc8; - //Low/Up channel flag - packet[9]=upper?0xAA:0x00; - upper=!upper; - //Hopping counters - if(sub_protocol==PELIKAN_LITE || ++packet_count>4) + if(sub_protocol == PELIKAN_SCX24) { - packet_count=0; - if(++hopping_frequency_no>=PELIKAN_NUM_RF_CHAN) - hopping_frequency_no=0; + //ID + packet[4] = rx_tx_addr[1]; + //Channels + channel = Channel_data[0]; //STEERING: 1B1..23B..2C5 ??? + packet[2] = channel >> 9; + packet[3] = channel >> 1; + channel = Channel_data[1]; //THROTTLE: 0DB..1FF..30E + packet[5] = channel >> 9; + packet[6] = channel >> 1; + channel = Channel_data[2]; //CH3: 055..3AA + packet[7] = channel >> 9; + packet[8] = channel >> 1; + //Hopping counters + if(++packet_count>2) + { + packet_count=0; + if(++hopping_frequency_no>=PELIKAN_NUM_RF_CHAN) + hopping_frequency_no=0; + } + //Length + packet_length = 14; } - packet[10]=hopping_frequency_no; - packet[11]=packet_count; - - packet_length = 15; + else + {//PELIKAN_PRO & PELIKAN_LITE + //ID + packet[7] = rx_tx_addr[1]; + //Channels + uint8_t offset=upper?4:0; + channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); + uint8_t top=(channel>>2) & 0xC0; + packet[2] = channel; + channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); + top|=(channel>>4) & 0x30; + packet[3] = channel; + channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false); + top|=(channel>>6) & 0x0C; + packet[4] = channel; + channel=convert_channel_16b_nolimit(CH_AETR[offset], 153, 871,false); + top|=(channel>>8) & 0x03; + packet[5] = channel; + packet[6] = top; + //Check + sum=0x00; + for(uint8_t i=0;i<8;i++) + sum+=packet[i]; + packet[8]=sum; + //Low/Up channel flag + packet[9]=upper?0xAA:0x00; + upper=!upper; + //Hopping counters + if(sub_protocol==PELIKAN_LITE || ++packet_count>4) + { + packet_count=0; + if(++hopping_frequency_no>=PELIKAN_NUM_RF_CHAN) + hopping_frequency_no=0; + } + //Length + packet_length = 15; + } + //Hopping + packet[packet_length-5] = hopping_frequency_no; + packet[packet_length-4] = packet_count; + //ID + packet[packet_length-3] = rx_tx_addr[2]; + packet[packet_length-2] = rx_tx_addr[3]; } //Check - crc8=0x15; - for(uint8_t i=1; i