diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index 8a0a956..f368d98 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -124,7 +124,8 @@ 17,2,MT99XX,YZ,1,Flip,LED,Pict,Video,HLess 17,3,MT99XX,LS,1,Flip,Invert,Pict,Video,HLess 17,4,MT99XX,FY805,1,Flip,n-a,n-a,n-a,HLess -17,5,MT99XX,A180,1,3D_6G +17,5,MT99XX,A180,0,3D_6G +17,6,MT99XX,Dragon,0,Mode,RTH 44,0,NCC1701,Std,1,Warp 77,0,OMP,M2,0,THold,IdleUp,6G_3D 60,0,Pelikan,PRO_V4,0,CH5,CH6,CH7,CH8 diff --git a/Multiprotocol/MT99xx_nrf24l01.ino b/Multiprotocol/MT99xx_nrf24l01.ino index 3175956..f5dc587 100644 --- a/Multiprotocol/MT99xx_nrf24l01.ino +++ b/Multiprotocol/MT99xx_nrf24l01.ino @@ -24,10 +24,12 @@ #define MT99XX_PACKET_PERIOD_MT 2625 #define MT99XX_PACKET_PERIOD_YZ 3125 #define MT99XX_PACKET_PERIOD_A180 3400 // timing changes between the packets 2 x 27220 then 1x 26080, it seems that it is only on the first RF channel which jitters by 1.14ms but hard to pinpoint with XN297dump +#define MT99XX_PACKET_PERIOD_DRAGON 1038 // there is a pause of 2x1038 between the packets 3 and 4 from what XN297dump detects which I think are used for telemetry #define MT99XX_INITIAL_WAIT 500 #define MT99XX_PACKET_SIZE 9 //#define FORCE_A180_ID +//#define FORCE_DRAGON_ID enum{ // flags going to packet[6] (MT99xx, H7) @@ -59,6 +61,13 @@ enum{ FLAG_A180_RATE = 0x02, }; +enum{ + // flags going to packet[6] (DRAGON) + FLAG_DRAGON_RATE = 0x01, + FLAG_DRAGON_RTH = 0x80, + FLAG_DRAGON_UNK = 0x04, +}; + enum { MT99XX_INIT = 0, MT99XX_BIND, @@ -108,7 +117,7 @@ static void __attribute__((unused)) MT99XX_send_packet() break; case A180: packet_period = MT99XX_PACKET_PERIOD_A180; - default: // MT99 & H7 & A180 + default: // MT99 & H7 & A180 & DRAGON packet[1] = 0x14; packet[2] = 0x03; packet[3] = 0x25; @@ -123,7 +132,7 @@ static void __attribute__((unused)) MT99XX_send_packet() else { if(sub_protocol != YZ) - { // MT99XX & H7 & LS & FY805 & A180 + { // MT99XX & H7 & LS & FY805 & A180 & DRAGON packet[0] = convert_channel_16b_limit(THROTTLE,0xE1,0x00); // throttle packet[1] = convert_channel_16b_limit(RUDDER ,0x00,0xE1); // rudder packet[2] = convert_channel_16b_limit(AILERON ,0xE1,0x00); // aileron @@ -167,6 +176,17 @@ static void __attribute__((unused)) MT99XX_send_packet() | GET_FLAG( CH5_SW, FLAG_A180_3D6G ); packet[7] = 0x00; break; + case DRAGON: + if(CH5_SW) // Advanced mode + packet[5] |= 0x80; + else + if(Channel_data[CH5] < CHANNEL_MIN_COMMAND) // Beginner mode + packet[5] |= 0x40; + packet[6] = FLAG_DRAGON_RATE + | GET_FLAG( CH6_SW, FLAG_DRAGON_RTH ); + //packet[6] |= 0x04; // On the 1st rf channel, 1x4, 11x0, 2x4, 11x0, 2x4, 10x0, 2x4, 11x0, 2x4, 11x0, 2x4, 10x0, 2x4, 11x0, 2x4, 11x0 and restart... Not sure what's on the other channels + packet[7] = 0x20; // On the 1st rf channel, seq: 20 80 20 60 20 80 20 60... Not sure what's on the other channels + break; } uint8_t result=crc8; for(uint8_t i=0; i<8; i++) @@ -186,7 +206,7 @@ static void __attribute__((unused)) MT99XX_send_packet() seq_num = 0; packet_count=0; } - packet[4] = yz_p4_seq[seq_num]; + packet[4] = yz_p4_seq[seq_num]; packet[5] = 0x02 // expert ? (0=unarmed, 1=normal) | GET_FLAG(CH8_SW, 0x10) //VIDEO | GET_FLAG(CH5_SW, 0x80) //FLIP @@ -205,15 +225,23 @@ static void __attribute__((unused)) MT99XX_send_packet() else if(sub_protocol==FY805) NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x4B); // FY805 always transmits on the same channel - else // MT99 & H7 & YZ & A180 + else // MT99 & H7 & YZ & A180 & DRAGON NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]); NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); NRF24L01_FlushTx(); XN297_WritePayload(packet, MT99XX_PACKET_SIZE); + if(sub_protocol == DRAGON) + { + if(hopping_frequency_no == 6) + packet_period = 3 * MT99XX_PACKET_PERIOD_DRAGON; // hole probably for the telemetry + else + packet_period = MT99XX_PACKET_PERIOD_DRAGON; + } + hopping_frequency_no++; - if(sub_protocol == YZ || sub_protocol == A180) + if(sub_protocol == YZ || sub_protocol == A180 || sub_protocol == DRAGON ) hopping_frequency_no++; // skip every other channel if(hopping_frequency_no > 15) @@ -272,7 +300,16 @@ static void __attribute__((unused)) MT99XX_initialize_txid() //channel_offset = 0x03; break; #endif - default: //MT99 & H7 & A180 + #ifdef FORCE_DRAGON_ID + case DRAGON: + rx_tx_addr[0] = 0x6C; // Laurie ID + rx_tx_addr[1] = 0x00; + rx_tx_addr[2] = 0x22; + //crc8 = 0x + //channel_offset = 0x + break; + #endif + default: //MT99 & H7 & A180 & DRAGON rx_tx_addr[2] = 0x00; break; } @@ -317,7 +354,7 @@ uint16_t MT99XX_callback() void MT99XX_init(void) { - if(sub_protocol != A180) + if(sub_protocol != A180 && sub_protocol != DRAGON) BIND_IN_PROGRESS; // autobind protocol bind_counter = MT99XX_BIND_COUNT; diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index a326354..3e1f769 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -14,7 +14,7 @@ 14,Bayang,Bayang,H8S3D,X16_AH,IRDRONE,DHD_D4,QX100 15,FrskyX,CH_16,CH_8,EU_16,EU_8,Cloned,Clon_8 16,ESky,Std,ET4 -17,MT99xx,MT,H7,YZ,LS,FY805,A180 +17,MT99xx,MT,H7,YZ,LS,FY805,A180,Dragon 18,MJXq,WLH08,X600,X800,H26D,E010,H26WH,PHOENIX 19,Shenqi 20,FY326,FY326,FY319 diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index 30a6da6..f55004d 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -112,7 +112,7 @@ const char STR_SUBTYPE_SLT[] = "\x06""V1_6ch""V2_8ch""Q100\0 ""Q200\0 ""M const char STR_SUBTYPE_CX10[] = "\x07""Green\0 ""Blue\0 ""DM007\0 ""-\0 ""JC3015a""JC3015b""MK33041"; const char STR_SUBTYPE_CG023[] = "\x05""Std\0 ""YD829"; const char STR_SUBTYPE_BAYANG[] = "\x07""Std\0 ""H8S3D\0 ""X16 AH\0""IRDrone""DHD D4\0""QX100\0 "; -const char STR_SUBTYPE_MT99[] = "\x05""MT99\0""H7\0 ""YZ\0 ""LS\0 ""FY805""A180\0"; +const char STR_SUBTYPE_MT99[] = "\x06""MT99\0 ""H7\0 ""YZ\0 ""LS\0 ""FY805\0""A180\0 ""Dragon"; const char STR_SUBTYPE_MJXQ[] = "\x07""WLH08\0 ""X600\0 ""X800\0 ""H26D\0 ""E010\0 ""H26WH\0 ""Phoenix"; const char STR_SUBTYPE_FY326[] = "\x05""Std\0 ""FY319"; const char STR_SUBTYPE_HONTAI[] = "\x07""Std\0 ""JJRC X1""X5C1\0 ""FQ_951"; @@ -329,7 +329,7 @@ const mm_protocol_definition multi_protocols[] = { {PROTO_MLINK, STR_MLINK, NO_SUBTYPE, 0, OPTION_NONE, 1, 0, SW_CYRF, MLINK_init, MLINK_callback }, #endif #if defined(MT99XX_NRF24L01_INO) - {PROTO_MT99XX, STR_MT99XX, STR_SUBTYPE_MT99, 6, OPTION_NONE, 0, 0, SW_NRF, MT99XX_init, MT99XX_callback }, + {PROTO_MT99XX, STR_MT99XX, STR_SUBTYPE_MT99, 7, OPTION_NONE, 0, 0, SW_NRF, MT99XX_init, MT99XX_callback }, #endif #if defined(NCC1701_NRF24L01_INO) {PROTO_NCC1701, STR_NCC1701, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, NCC_init, NCC_callback }, diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 97275f4..e420b41 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 33 +#define VERSION_PATCH_LEVEL 34 //****************** // Protocols @@ -220,6 +220,7 @@ enum MT99XX LS = 3, FY805 = 4, A180 = 5, + DRAGON = 6, }; enum MJXQ { diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 183a87c..684d79f 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -1172,9 +1172,9 @@ static void protocol_init() for(uint8_t j=0;j