diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index 85a5cf7..c2a0f30 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -227,3 +227,4 @@ 98,0,Kyosho3,ASF,0 100,0,YuXiang,Std,0,Lock,Rate,Land,Manual,Flip,Mode,Pitch 102,0,JIABAILE,Std,1,Speed,Light,Flash +103,0,H36,Std,1,Flip,HLess,RTH diff --git a/Multiprotocol/H36_nrf24l01.ino b/Multiprotocol/H36_nrf24l01.ino new file mode 100644 index 0000000..8c71337 --- /dev/null +++ b/Multiprotocol/H36_nrf24l01.ino @@ -0,0 +1,129 @@ +/* + 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 . + */ +#if defined(H36_NRF24L01_INO) + +#include "iface_xn297.h" + +#define FORCE_H36_ORIGINAL_ID + +#define H36_PAYLOAD_SIZE 13 +#define H36_RF_NUM_CHANNELS 4 +#define H36_BIND_PACKET_PERIOD 10285 +#define H36_BIND_COUNT 648 //3sec + +enum { + H36_DATA1=0, + H36_DATA2, + H36_DATA3, + H36_DATA4, +}; + +static void __attribute__((unused)) H36_send_packet() +{ + if(IS_BIND_DONE && phase == H36_DATA1) + { + hopping_frequency_no++; + hopping_frequency_no&=3; + XN297_Hopping(hopping_frequency_no); + } + + packet[0] = 0x2E; // constant? + memcpy(&packet[2],rx_tx_addr,3); + if(IS_BIND_IN_PROGRESS) + {//Bind + memcpy(&packet[5],hopping_frequency,4); + memset(&packet[9], 0x00, 3); + packet[12] = 0xED; // constant? + bind_counter--; + if(bind_counter == 0) + BIND_DONE; + } + else + {//Normal + packet[5] = convert_channel_8b(THROTTLE); + packet[6] = convert_channel_8b(RUDDER); + packet[7] = convert_channel_8b(ELEVATOR); + packet[8] = convert_channel_8b(AILERON); + packet[9] = GET_FLAG(CH6_SW, 0x02) //Headless + |GET_FLAG(CH7_SW, 0x04); //RTH(temporary) + packet[10] = 0x20; //Trim A centered(0x20) + packet[11] = CH5_SW?0x60:0x20; //Flip(0x40)|Trim E centered(0x20) + packet[12] = 0xA0; //High(0x80)/Low(0x40) rates|Trim R centered(0x20)? + } + //crc + packet[1]=0xAA; + for(uint8_t i=5;i<12;i++) + packet[1] ^= packet[i]; + //Send + XN297_SetPower(); + XN297_SetTxRxMode(TX_EN); + XN297_WritePayload(packet, H36_PAYLOAD_SIZE); + #ifdef DEBUG_SERIAL + debug("H%d P",hopping_frequency_no); + for(uint8_t i=0; i < H36_PAYLOAD_SIZE; i++) + debug(" %02X", packet[i]); + debugln(); + #endif +} + +static void __attribute__((unused)) H36_initialize_txid() +{ + rx_tx_addr[0] = rx_tx_addr[3]; + calc_fh_channels(4); + #ifdef FORCE_H36_ORIGINAL_ID + memcpy(rx_tx_addr,(uint8_t *)"\x00\x11\x00",3); + memcpy(hopping_frequency,(uint8_t *)"\x36\x3A\x31\x2B",4); //54, 58, 49, 43 + #endif +} + +static void __attribute__((unused)) H36_RF_init() +{ + XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M); + XN297_SetTXAddr((uint8_t*)"\xCC\x6C\x47\x90\x53", 5); + XN297_RFChannel(50); //Bind channel +} + +uint16_t H36_callback() +{ + H36_send_packet(); + switch(phase) + { + case H36_DATA1: + phase++; + return 1830; + case H36_DATA2: + case H36_DATA3: + phase++; + return 3085; + default://DATA4 + #ifdef MULTI_SYNC + telemetry_set_input_sync(18500); + #endif + phase = H36_DATA1; + break; + } + return 10500; +} + +void H36_init() +{ + BIND_IN_PROGRESS; // Autobind protocol + H36_initialize_txid(); + H36_RF_init(); + phase = H36_DATA1; + hopping_frequency_no = 0; + bind_counter = H36_BIND_COUNT; +} +#endif diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index c090d0e..fb61de0 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -98,3 +98,4 @@ 99,XK2 100,YuXiang 102,JIABAILE +103,H36 \ No newline at end of file diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index 417092a..5a4d0dc 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -55,6 +55,7 @@ const char STR_DM002[] ="DM002"; const char STR_CABELL[] ="Cabell"; const char STR_ESKY150[] ="Esky150"; const char STR_ESKY150V2[] ="EskyV2"; +const char STR_H36[] ="H36"; const char STR_H8_3D[] ="H8 3D"; const char STR_CORONA[] ="Corona"; const char STR_CFLIE[] ="CFlie"; @@ -349,6 +350,9 @@ const mm_protocol_definition multi_protocols[] = { #if defined(GW008_NRF24L01_INO) {PROTO_GW008, STR_GW008, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, GW008_init, GW008_callback }, #endif + #if defined(H36_NRF24L01_INO) + {PROTO_H36, STR_H36, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, H36_init, H36_callback }, + #endif #if defined(H8_3D_NRF24L01_INO) {PROTO_H8_3D, STR_H8_3D, STR_SUBTYPE_H83D, 4, OPTION_NONE, 0, 0, SW_NRF, H8_3D_init, H8_3D_callback }, #endif diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 0b18679..96fc4ec 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 4 -#define VERSION_PATCH_LEVEL 24 +#define VERSION_PATCH_LEVEL 25 #define MODE_SERIAL 0 @@ -130,6 +130,7 @@ enum PROTOCOLS PROTO_YUXIANG = 100, // =>NRF24L01 PROTO_PINECONE = 101, // =>CC2500 & NRF24L01 PROTO_JIABAILE = 102, // =>NRF24L01 + PROTO_H36 = 103, // =>NRF24L01 PROTO_NANORF = 126, // =>NRF24L01 PROTO_TEST = 127, // =>CC2500 diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 441c151..fa6dbbe 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -321,6 +321,7 @@ #undef FY326_NRF24L01_INO #undef GW008_NRF24L01_INO #undef H8_3D_NRF24L01_INO + #undef H36_NRF24L01_INO #undef HISKY_NRF24L01_INO #undef HONTAI_NRF24L01_INO #undef JIABAILE_NRF24L01_INO @@ -423,6 +424,7 @@ #undef GW008_NRF24L01_INO #undef HONTAI_NRF24L01_INO #undef H8_3D_NRF24L01_INO + #undef H36_NRF24L01_INO #undef JJRC345_NRF24L01_INO #undef KN_NRF24L01_INO #undef LOLI_NRF24L01_INO diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 0088d7e..794fdb8 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -240,9 +240,10 @@ #define FX_NRF24L01_INO #define FY326_NRF24L01_INO #define GW008_NRF24L01_INO +#define H36_NRF24L01_INO +#define H8_3D_NRF24L01_INO #define HISKY_NRF24L01_INO #define HONTAI_NRF24L01_INO -#define H8_3D_NRF24L01_INO #define JIABAILE_NRF24L01_INO #define JJRC345_NRF24L01_INO #define KN_NRF24L01_INO @@ -702,6 +703,7 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { GD_V2 PROTO_GW008 NONE + PROTO_H36 PROTO_H8_3D H8_3D H20H diff --git a/Protocols_Details.md b/Protocols_Details.md index 75f2c51..3508fe0 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -103,6 +103,7 @@ CFlie|38|CFlie||||||||NRF24L01| [FY326](Protocols_Details.md#FY326---20)|20|FY326|FY319|||||||NRF24L01| [GD00X](Protocols_Details.md#GD00X---47)|47|GD_V1*|GD_V2*|||||||NRF24L01|XN297L [GW008](Protocols_Details.md#GW008---32)|32|||||||||NRF24L01|XN297 +[H36](Protocols_Details.md#H36---103)|H36|||||||||NRF24L01|XN297 [H8_3D](Protocols_Details.md#H8_3D---36)|36|H8_3D|H20H|H20Mini|H30Mini|||||NRF24L01|XN297 [Height](Protocols_Details.md#HEIGHT---53)|53|5ch|8ch|||||||A7105| [Hisky](Protocols_Details.md#HISKY---4)|4|Hisky|HK310|||||||NRF24L01| @@ -1839,15 +1840,24 @@ CH1|CH2|CH3|CH4|CH5 ---|---|---|---|--- A|E|T|R|FLIP +## H36 - *103* +Autobind protocol + +Model: JJRC H36 (JR-NH010R9 board) + +CH1|CH2|CH3|CH4|CH5|CH6|CH7 +---|---|---|---|---|---|--- +A|E|T|R|FLIP|HEADLESS|RTH + ## H8_3D - *36* Autobind protocol ### Sub_protocol H8_3D - *0* Models: Eachine H8 mini 3D,Eachine E10, JJRC H20/H22/H11D -CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13 ----|---|---|---|---|---|---|---|--- -FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL +CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13 +---|---|---|---|---|---|---|---|---|---|---|---|--- +A|E|T|R|FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL JJRC H20: OPT1=Headless, OPT2=RTH