From 86d3d2627341914db8d6435d9d4bc70376b41c62 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 4 Feb 2016 13:35:16 +0100 Subject: [PATCH] New protocol MJXQ --- Multiprotocol/CG023_nrf24l01.ino | 49 +++--- Multiprotocol/CX10_nrf24l01.ino | 76 +++++---- Multiprotocol/KN_nrf24l01.ino | 8 +- Multiprotocol/MJXQ_nrf24l01.ino | 247 ++++++++++++++++++++++++++++++ Multiprotocol/MT99xx_nrf24l01.ino | 10 +- Multiprotocol/Multiprotocol.ino | 8 +- Multiprotocol/V2X2_nrf24l01.ino | 6 +- Multiprotocol/_Config.h | 36 +++-- Multiprotocol/multiprotocol.h | 14 ++ 9 files changed, 360 insertions(+), 94 deletions(-) create mode 100644 Multiprotocol/MJXQ_nrf24l01.ino diff --git a/Multiprotocol/CG023_nrf24l01.ino b/Multiprotocol/CG023_nrf24l01.ino index de31672..0e5c0ce 100644 --- a/Multiprotocol/CG023_nrf24l01.ino +++ b/Multiprotocol/CG023_nrf24l01.ino @@ -104,6 +104,8 @@ static void __attribute__((unused)) CG023_send_packet(uint8_t bind) packet[6] = 0x08; packet[7] = 0x03; packet[9] = throttle; + if(rudder==0x01) rudder=0; // Small deadband + if(rudder==0x81) rudder=0; // Small deadband packet[10] = rudder; packet[11] = elevator; packet[12] = aileron; @@ -112,15 +114,11 @@ static void __attribute__((unused)) CG023_send_packet(uint8_t bind) packet[14] = 0x20; packet[15] = 0x20; packet[16] = 0x20; - packet[17] = H8_3D_FLAG_RATE_HIGH; - if(Servo_AUX1) - packet[17] |= H8_3D_FLAG_FLIP; - if(Servo_AUX2) - packet[17] |= H8_3D_FLAG_LIGTH; //H22 light - if(Servo_AUX3) - packet[17] |= H8_3D_FLAG_HEADLESS; - if(Servo_AUX4) - packet[17] |= H8_3D_FLAG_RTH; // 180/360 flip mode on H8 3D + packet[17] = H8_3D_FLAG_RATE_HIGH + | GET_FLAG(Servo_AUX1,H8_3D_FLAG_FLIP) + | GET_FLAG(Servo_AUX2,H8_3D_FLAG_LIGTH) //H22 light + | GET_FLAG(Servo_AUX3,H8_3D_FLAG_HEADLESS) + | GET_FLAG(Servo_AUX4,H8_3D_FLAG_RTH); // 180/360 flip mode on H8 3D if(Servo_AUX5) packet[18] = H8_3D_FLAG_CALIBRATE; } @@ -152,32 +150,21 @@ static void __attribute__((unused)) CG023_send_packet(uint8_t bind) if(sub_protocol==CG023) { // rate - packet[13] = CG023_FLAG_RATE_HIGH; - // flags - if(Servo_AUX1) - packet[13] |= CG023_FLAG_FLIP; - if(Servo_AUX2) - packet[13] |= CG023_FLAG_LED_OFF; - if(Servo_AUX3) - packet[13] |= CG023_FLAG_STILL; - if(Servo_AUX4) - packet[13] |= CG023_FLAG_VIDEO; - if(Servo_AUX5) - packet[13] |= CG023_FLAG_EASY; + packet[13] = CG023_FLAG_RATE_HIGH + | GET_FLAG(Servo_AUX1,CG023_FLAG_FLIP) + | GET_FLAG(Servo_AUX2,CG023_FLAG_LED_OFF) + | GET_FLAG(Servo_AUX3,CG023_FLAG_STILL) + | GET_FLAG(Servo_AUX4,CG023_FLAG_VIDEO) + | GET_FLAG(Servo_AUX5,CG023_FLAG_EASY); } else {// YD829 // rate - packet[13] = YD829_FLAG_RATE_HIGH; - // flags - if(Servo_AUX1) - packet[13] |= YD829_FLAG_FLIP; - if(Servo_AUX3) - packet[13] |= YD829_FLAG_STILL; - if(Servo_AUX4) - packet[13] |= YD829_FLAG_VIDEO; - if(Servo_AUX5) - packet[13] |= YD829_FLAG_HEADLESS; + packet[13] = YD829_FLAG_RATE_HIGH + | GET_FLAG(Servo_AUX1,YD829_FLAG_FLIP) + | GET_FLAG(Servo_AUX3,YD829_FLAG_STILL) + | GET_FLAG(Servo_AUX4,YD829_FLAG_VIDEO) + | GET_FLAG(Servo_AUX5,YD829_FLAG_HEADLESS); } packet[14] = 0; } diff --git a/Multiprotocol/CX10_nrf24l01.ino b/Multiprotocol/CX10_nrf24l01.ino index bf62c44..6722fcd 100644 --- a/Multiprotocol/CX10_nrf24l01.ino +++ b/Multiprotocol/CX10_nrf24l01.ino @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with Multiprotocol. If not, see . */ -// compatible with Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, CX-Stars +// compatible with Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, JXD 509 (Q282) // Last sync with hexfet new_protocols/cx10_nrf24l01.c dated 2015-11-26 #if defined(CX10_NRF24L01_INO) @@ -27,7 +27,7 @@ #define CX10A_PACKET_PERIOD 6000 #define CX10A_BIND_COUNT 400 // 2 seconds -#define INITIAL_WAIT 500 +#define CX10_INITIAL_WAIT 500 // flags #define CX10_FLAG_FLIP 0x10 // goes to rudder channel @@ -38,8 +38,8 @@ #define CX10_FLAG_SNAPSHOT 0x04 // frequency channel management -#define RF_BIND_CHANNEL 0x02 -#define NUM_RF_CHANNELS 4 +#define CX10_RF_BIND_CHANNEL 0x02 +#define CX10_NUM_RF_CHANNELS 4 enum { CX10_BIND1 = 0, @@ -87,63 +87,61 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind) switch(sub_protocol) { case CX10_BLUE: - if(Servo_AUX3) flags |= 0x10; // Channel 7 - picture - if(Servo_AUX4) flags |= 0x08; // Channel 8 - video + flags |= GET_FLAG(!Servo_AUX3, 0x10) // Channel 7 - picture + |GET_FLAG( Servo_AUX4, 0x08); // Channel 8 - video break; case Q282: case Q242: memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6); //FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL - if(Servo_AUX1) flags2 =0x80; // Channel 5 - FLIP - if(Servo_AUX2) flags2|=0x40; // Channel 6 - LED - - if(Servo_AUX5) flags2|=0x08; // Channel 9 - HEADLESS + flags2 = GET_FLAG(Servo_AUX1, 0x80) // Channel 5 - FLIP + |GET_FLAG(Servo_AUX2, 0x40) // Channel 6 - LED + |GET_FLAG(Servo_AUX5, 0x08) // Channel 9 - HEADLESS + |GET_FLAG(Servo_AUX7, 0x04) // Channel 11 - XCAL + |GET_FLAG(Servo_AUX8, 0x02); // Channel 12 - YCAL or Start/Stop motors on JXD 509 + if(sub_protocol==Q282) { - if(Servo_AUX3) flags2|=0x10; // Channel 7 - picture - if(Servo_AUX4) // Channel 8 - video + flags=3; + if(Servo_AUX4) // Channel 8 - video { if (!(video_state & 0x20)) video_state ^= 0x21; } else if (video_state & 0x20) video_state &= 0x01; - flags2 |= video_state; - flags=3; + flags2 |= video_state + |GET_FLAG(Servo_AUX3,0x10); // Channel 7 - picture } else { - if(Servo_AUX3) flags2|=0x01; // Channel 7 - picture - if(Servo_AUX4) flags2|=0x10; // Channel 8 - video flags=2; + flags2|= GET_FLAG(Servo_AUX3,0x01) // Channel 7 - picture + |GET_FLAG(Servo_AUX4,0x10); // Channel 8 - video packet[17]=0x00; packet[18]=0x00; } - if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH - if(Servo_AUX7) flags2|=0x04; // Channel 11 - XCAL - if(Servo_AUX8) flags2|=0x02; // Channel 12 - YCAL + if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH break; case DM007: //FLIP|MODE|PICTURE|VIDEO|HEADLESS - if(Servo_AUX3) flags2 = CX10_FLAG_SNAPSHOT; // Channel 7 - picture - if(Servo_AUX4) flags2|= CX10_FLAG_VIDEO; // Channel 8 - video - if(Servo_AUX5) flags |= CX10_FLAG_HEADLESS; // Channel 9 - headless - break; - case JC3015_1: - //FLIP|MODE|PICTURE|VIDEO - if(Servo_AUX3) flags2 = _BV(3); // Channel 7 - picture - if(Servo_AUX4) flags2|= _BV(4); // Channel 8 - video + flags2= GET_FLAG(Servo_AUX3,CX10_FLAG_SNAPSHOT) // Channel 7 - picture + |GET_FLAG(Servo_AUX4,CX10_FLAG_VIDEO); // Channel 8 - video + if(Servo_AUX5) flags |= CX10_FLAG_HEADLESS; // Channel 9 - headless break; case JC3015_2: //FLIP|MODE|LED|DFLIP - if(Servo_AUX3) flags2 = _BV(3); // Channel 7 - LED - if(Servo_AUX4) flags2|= _BV(4); // Channel 8 - DFLIP + if(Servo_AUX4) packet[12] &= ~CX10_FLAG_FLIP; + case JC3015_1: + //FLIP|MODE|PICTURE|VIDEO + flags2= GET_FLAG(Servo_AUX3,_BV(3)) // Channel 7 + |GET_FLAG(Servo_AUX4,_BV(4)); // Channel 8 break; case MK33041: //FLIP|MODE|PICTURE|VIDEO|HEADLESS|RTH - if(Servo_AUX3) flags |= _BV(7); // Channel 7 - picture - if(Servo_AUX4) flags2 = _BV(0); // Channel 8 - video - if(Servo_AUX5) flags2|= _BV(5); // Channel 9 - headless - if(Servo_AUX6) flags |= _BV(2); // Channel 10 - rth + flags|=GET_FLAG(Servo_AUX3,_BV(7)) // Channel 7 - picture + |GET_FLAG(Servo_AUX6,_BV(2)); // Channel 10 - rth + flags2=GET_FLAG(Servo_AUX4,_BV(0)) // Channel 8 - video + |GET_FLAG(Servo_AUX5,_BV(5)); // Channel 9 - headless break; } packet[13+offset]=flags; @@ -153,11 +151,11 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind) // Why CRC0? xn297 does not interpret it - either 16-bit CRC or nothing XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP)); if (bind) - NRF24L01_WriteReg(NRF24L01_05_RF_CH, RF_BIND_CHANNEL); + NRF24L01_WriteReg(NRF24L01_05_RF_CH, CX10_RF_BIND_CHANNEL); else { NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++]); - hopping_frequency_no %= NUM_RF_CHANNELS; + hopping_frequency_no %= CX10_NUM_RF_CHANNELS; } // clear packet status bits and TX FIFO NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); @@ -179,7 +177,7 @@ static void __attribute__((unused)) CX10_init() NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowledgment on all data pipes NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, packet_length); // rx pipe 0 (used only for blue board) - NRF24L01_WriteReg(NRF24L01_05_RF_CH, RF_BIND_CHANNEL); + NRF24L01_WriteReg(NRF24L01_05_RF_CH, CX10_RF_BIND_CHANNEL); NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps NRF24L01_SetPower(); } @@ -236,7 +234,7 @@ uint16_t CX10_callback() { return packet_period; } -static void __attribute__((unused)) initialize_txid() +static void __attribute__((unused)) CX10_initialize_txid() { rx_tx_addr[1]%= 0x30; if(sub_protocol==Q282) @@ -287,10 +285,10 @@ uint16_t initCX10(void) phase = CX10_BIND1; bind_counter = CX10_BIND_COUNT; } - initialize_txid(); + CX10_initialize_txid(); CX10_init(); BIND_IN_PROGRESS; // autobind protocol - return INITIAL_WAIT+packet_period; + return CX10_INITIAL_WAIT+packet_period; } #endif diff --git a/Multiprotocol/KN_nrf24l01.ino b/Multiprotocol/KN_nrf24l01.ino index 53e902d..9e0775b 100644 --- a/Multiprotocol/KN_nrf24l01.ino +++ b/Multiprotocol/KN_nrf24l01.ino @@ -144,13 +144,13 @@ static void __attribute__((unused)) kn_update_packet_control_data() packet[11] = 0x64; // R flags=0; - if (Servo_data[AUX1] > PPM_SWITCH) + if (Servo_AUX1) flags = KN_FLAG_DR; - if (Servo_data[AUX2] > PPM_SWITCH) + if (Servo_AUX2) flags |= KN_FLAG_TH; - if (Servo_data[AUX3] > PPM_SWITCH) + if (Servo_AUX3) flags |= KN_FLAG_IDLEUP; - if (Servo_data[AUX4] > PPM_SWITCH) + if (Servo_AUX4) flags |= KN_FLAG_GYRO3; packet[12] = flags; diff --git a/Multiprotocol/MJXQ_nrf24l01.ino b/Multiprotocol/MJXQ_nrf24l01.ino new file mode 100644 index 0000000..484e798 --- /dev/null +++ b/Multiprotocol/MJXQ_nrf24l01.ino @@ -0,0 +1,247 @@ +/* + 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 MJX WLH08, X600, X800, H26D +// Last sync with hexfet new_protocols/mjxq_nrf24l01.c dated 2016-01-17 + +#if defined(MJXQ_NRF24L01_INO) + +#include "iface_nrf24l01.h" + +#define MJXQ_BIND_COUNT 150 +#define MJXQ_PACKET_PERIOD 4000 // Timeout for callback in uSec +#define MJXQ_INITIAL_WAIT 500 +#define MJXQ_PACKET_SIZE 16 +#define MJXQ_RF_NUM_CHANNELS 4 +#define MJXQ_ADDRESS_LENGTH 5 + +#define MJXQ_PAN_TILT_COUNT 16 // for H26D - match stock tx timing +#define MJXQ_PAN_DOWN 0x08 +#define MJXQ_PAN_UP 0x04 +#define MJXQ_TILT_DOWN 0x20 +#define MJXQ_TILT_UP 0x10 +static uint8_t __attribute__((unused)) MJXQ_pan_tilt_value() +{ +// Servo_AUX8 PAN // H26D +// Servo_AUX9 TILT + uint8_t pan = 0; + packet_count++; + if(packet_count & MJXQ_PAN_TILT_COUNT) + { + if(Servo_AUX8) + pan=MJXQ_PAN_UP; + if(Servo_data[AUX8]PPM_MIN_COMMAND) + pan=MJXQ_TILT_UP; + if(Servo_data[AUX9]> 1) +static void __attribute__((unused)) MJXQ_send_packet(uint8_t bind) +{ + packet[0] = convert_channel_8b(THROTTLE); + packet[1] = convert_channel_s8b(RUDDER); + packet[4] = 0x40; // rudder does not work well with dyntrim + packet[2] = convert_channel_s8b(ELEVATOR); + packet[5] = MJXQ_CHAN2TRIM(packet[2]); // trim elevator + packet[3] = convert_channel_s8b(AILERON); + packet[6] = MJXQ_CHAN2TRIM(packet[3]); // trim aileron + packet[7] = rx_tx_addr[0]; + packet[8] = rx_tx_addr[1]; + packet[9] = rx_tx_addr[2]; + + packet[10] = 0x00; // overwritten below for feature bits + packet[11] = 0x00; // overwritten below for X600 + packet[12] = 0x00; + packet[13] = 0x00; + + packet[14] = 0xC0; // bind value + +// Servo_AUX1 FLIP +// Servo_AUX2 LED +// Servo_AUX3 PICTURE +// Servo_AUX4 VIDEO +// Servo_AUX5 HEADLESS +// Servo_AUX6 RTH +// Servo_AUX7 AUTOFLIP // X800, X600 + switch(sub_protocol) + { + case H26D: + packet[10]=MJXQ_pan_tilt_value(); + // fall through on purpose - no break + case WLH08: + packet[10] += GET_FLAG(Servo_AUX6, 0x02) //RTH + | GET_FLAG(Servo_AUX5, 0x01); //HEADLESS + if (!bind) + { + packet[14] = 0x04 + | GET_FLAG(Servo_AUX1, 0x01) //FLIP + | GET_FLAG(Servo_AUX3, 0x08) //PICTURE + | GET_FLAG(Servo_AUX4, 0x10) //VIDEO + | GET_FLAG(!Servo_AUX2, 0x20); // air/ground mode + } + break; + case X600: + if(Servo_AUX5) //HEADLESS + { // driven trims cause issues when headless is enabled + packet[5] = 0x40; + packet[6] = 0x40; + } + packet[10] = GET_FLAG(!Servo_AUX2, 0x02); //LED + packet[11] = GET_FLAG(Servo_AUX6, 0x01); //RTH + if (!bind) + { + packet[14] = 0x02 // always high rates by bit2 = 1 + | GET_FLAG(Servo_AUX1, 0x04) //FLIP + | GET_FLAG(Servo_AUX7, 0x10) //AUTOFLIP + | GET_FLAG(Servo_AUX5, 0x20); //HEADLESS + } + break; + case X800: + default: + packet[10] = 0x10 + | GET_FLAG(!Servo_AUX2, 0x02) //LED + | GET_FLAG(Servo_AUX7, 0x01); //AUTOFLIP + if (!bind) + { + packet[14] = 0x02 // always high rates by bit2 = 1 + | GET_FLAG(Servo_AUX1, 0x04) //FLIP + | GET_FLAG(Servo_AUX3, 0x08) //PICTURE + | GET_FLAG(Servo_AUX4, 0x10); //VIDEO + } + break; + } + + uint8_t sum = packet[0]; + for (uint8_t i=1; i < MJXQ_PACKET_SIZE-1; i++) sum += packet[i]; + packet[15] = sum; + + // Power on, TX mode, 2byte CRC + if (sub_protocol == H26D) + NRF24L01_SetTxRxMode(TX_EN); + else + XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP)); + + NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++ / 2]); + hopping_frequency_no %= 2 * MJXQ_RF_NUM_CHANNELS; // channels repeated + + NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); + NRF24L01_FlushTx(); + + if (sub_protocol == H26D) + NRF24L01_WritePayload(packet, MJXQ_PACKET_SIZE); + else + XN297_WritePayload(packet, MJXQ_PACKET_SIZE); + + NRF24L01_SetPower(); +} + +static void __attribute__((unused)) MJXQ_init() +{ + uint8_t addr[MJXQ_ADDRESS_LENGTH]; + memcpy(addr, "\x6d\x6a\x77\x77\x77", MJXQ_ADDRESS_LENGTH); + if (sub_protocol == WLH08) + memcpy(hopping_frequency, "\x12\x22\x32\x42", MJXQ_RF_NUM_CHANNELS); + else + if (sub_protocol == H26D) + memcpy(hopping_frequency, "\x36\x3e\x46\x2e", MJXQ_RF_NUM_CHANNELS); + else + { + memcpy(hopping_frequency, "\x0a\x35\x42\x3d", MJXQ_RF_NUM_CHANNELS); + memcpy(addr, "\x6d\x6a\x73\x73\x73", MJXQ_RF_NUM_CHANNELS); + } + + + NRF24L01_Initialize(); + NRF24L01_SetTxRxMode(TX_EN); + + if (sub_protocol == H26D) + NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, addr, MJXQ_ADDRESS_LENGTH); + else + XN297_SetTXAddr(addr, MJXQ_ADDRESS_LENGTH); + + NRF24L01_FlushTx(); + NRF24L01_FlushRx(); + NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit + NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowledgment on all data pipes + NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only + NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // no retransmits + NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, MJXQ_PACKET_SIZE); // rx pipe 0 (used only for blue board) + NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps + NRF24L01_SetPower(); +} + +static void __attribute__((unused)) MJXQ_init2() +{ + // haven't figured out txid<-->rf channel mapping for MJX models + static const uint8_t rf_map[][4] = { + {0x0A, 0x46, 0x3A, 0x42}, + {0x0A, 0x3C, 0x36, 0x3F}, + {0x0A, 0x43, 0x36, 0x3F} }; + if (sub_protocol == H26D) + memcpy(hopping_frequency, "\x32\x3e\x42\x4e", MJXQ_RF_NUM_CHANNELS); + else + if (sub_protocol == WLH08) + memcpy(hopping_frequency, rf_map[rx_tx_addr[0]%3], MJXQ_RF_NUM_CHANNELS); +} + +static void __attribute__((unused)) MJXQ_initialize_txid() +{ + // haven't figured out txid<-->rf channel mapping for MJX models + static const uint8_t tx_map[][3]={ + {0xF8, 0x4F, 0x1C}, + {0xC8, 0x6E, 0x02}, + {0x48, 0x6A, 0x40} }; + if (sub_protocol == WLH08) + rx_tx_addr[0]&=0xF8; // txid must be multiple of 8 + else + memcpy(rx_tx_addr,tx_map[rx_tx_addr[0]%3],3); +} + +uint16_t MJXQ_callback() +{ + if(IS_BIND_DONE_on) + MJXQ_send_packet(0); + else + { + if (bind_counter == 0) + { + MJXQ_init2(); + BIND_DONE; + } + else + { + bind_counter--; + MJXQ_send_packet(1); + } + } + + return MJXQ_PACKET_PERIOD; +} + +uint16_t initMJXQ(void) +{ + BIND_IN_PROGRESS; // autobind protocol + bind_counter = MJXQ_BIND_COUNT; + MJXQ_initialize_txid(); + MJXQ_init(); + packet_count=0; + return MJXQ_INITIAL_WAIT+MJXQ_PACKET_PERIOD; +} + +#endif diff --git a/Multiprotocol/MT99xx_nrf24l01.ino b/Multiprotocol/MT99xx_nrf24l01.ino index b9909a9..ab4c825 100644 --- a/Multiprotocol/MT99xx_nrf24l01.ino +++ b/Multiprotocol/MT99xx_nrf24l01.ino @@ -90,8 +90,8 @@ static void __attribute__((unused)) MT99XX_send_packet() { // YZ packet[0] = convert_channel_8b_scale(THROTTLE,0x00,0x64); // throttle packet[1] = convert_channel_8b_scale(RUDDER ,0x00,0x64); // rudder - packet[2] = convert_channel_8b_scale(AILERON ,0x00,0x64); // aileron - packet[3] = convert_channel_8b_scale(ELEVATOR,0x00,0x64); // elevator + packet[2] = convert_channel_8b_scale(ELEVATOR,0x00,0x64); // elevator + packet[3] = convert_channel_8b_scale(AILERON ,0x00,0x64); // aileron if(packet_count++ >= 23) { yz_seq_num ++; @@ -99,8 +99,8 @@ static void __attribute__((unused)) MT99XX_send_packet() yz_seq_num = 0; packet_count=0; } - packet[4]= yz_p4_seq[yz_seq_num]; - packet[5]= 0x02; // expert ? (0=unarmed, 1=normal) + packet[4] = yz_p4_seq[yz_seq_num]; + packet[5] = 0x02; // expert ? (0=unarmed, 1=normal) packet[6] = 0x80; packet[7] = packet[0]; for(uint8_t idx = 1; idx < MT99XX_PACKET_SIZE-2; idx++) @@ -127,7 +127,6 @@ static void __attribute__((unused)) MT99XX_init() { NRF24L01_Initialize(); NRF24L01_SetTxRxMode(TX_EN); - XN297_SetTXAddr((uint8_t *)"\0xCC\0xCC\0xCC\0xCC\0xCC", 5); NRF24L01_FlushTx(); NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowldgement on all data pipes @@ -139,6 +138,7 @@ static void __attribute__((unused)) MT99XX_init() else NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps NRF24L01_SetPower(); + XN297_SetTXAddr((uint8_t *)"\0xCC\0xCC\0xCC\0xCC\0xCC", 5); } static void __attribute__((unused)) MT99XX_initialize_txid() diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 44a4bcf..b76d74f 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -420,6 +420,12 @@ static void protocol_init() next_callback=initMT99XX(); remote_callback = MT99XX_callback; break; +#endif +#if defined(MJXQ_NRF24L01_INO) + case MODE_MJXQ: + next_callback=initMJXQ(); + remote_callback = MJXQ_callback; + break; #endif } @@ -502,7 +508,7 @@ static void module_reset() case MODE_DEVO: CYRF_Reset(); break; - default: // MODE_HISKY, MODE_V2X2, MODE_YD717, MODE_KN, MODE_SYMAX, MODE_SLT, MODE_CX10, MODE_CG023, MODE_BAYANG, MODE_ESKY, MODE_MT99XX + default: // MODE_HISKY, MODE_V2X2, MODE_YD717, MODE_KN, MODE_SYMAX, MODE_SLT, MODE_CX10, MODE_CG023, MODE_BAYANG, MODE_ESKY, MODE_MT99XX, MODE_MJXQ NRF24L01_Reset(); break; } diff --git a/Multiprotocol/V2X2_nrf24l01.ino b/Multiprotocol/V2X2_nrf24l01.ino index d761c57..887e60e 100644 --- a/Multiprotocol/V2X2_nrf24l01.ino +++ b/Multiprotocol/V2X2_nrf24l01.ino @@ -180,13 +180,13 @@ static void __attribute__((unused)) V2X2_send_packet(uint8_t bind) //Flags2 // Channel 9 - if (Servo_data[AUX5] > PPM_SWITCH) + if (Servo_AUX5) flags2 = V2X2_FLAG_HEADLESS; // Channel 10 - if (Servo_data[AUX6] > PPM_SWITCH) + if (Servo_AUX6) flags2 |= V2X2_FLAG_MAG_CAL_X; // Channel 11 - if (Servo_data[AUX7] > PPM_SWITCH) + if (Servo_AUX7) flags2 |= V2X2_FLAG_MAG_CAL_Y; } // TX id diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 3558c99..f76d79e 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -26,23 +26,28 @@ #define HUB_TELEMETRY //Comment a protocol to exclude it from compilation +//A7105 protocols +#define FLYSKY_A7105_INO +#define HUBSAN_A7105_INO +//CYRF6936 protocols +#define DEVO_CYRF6936_INO +#define DSM2_CYRF6936_INO +//CC2500 protocols +#define FRSKY_CC2500_INO +//#define FRSKYX_CC2500_INO +//NFR24L01 protocols #define BAYANG_NRF24L01_INO #define CG023_NRF24L01_INO #define CX10_NRF24L01_INO -#define DEVO_CYRF6936_INO -#define DSM2_CYRF6936_INO #define ESKY_NRF24L01_INO -#define FLYSKY_A7105_INO -#define FRSKY_CC2500_INO #define HISKY_NRF24L01_INO -#define HUBSAN_A7105_INO #define KN_NRF24L01_INO #define SLT_NRF24L01_INO #define SYMAX_NRF24L01_INO #define V2X2_NRF24L01_INO #define YD717_NRF24L01_INO -//#define FRSKYX_CC2500_INO #define MT99XX_NRF24L01_INO +#define MJXQ_NRF24L01_INO //Update this table to set which protocol and all associated settings are called for the corresponding dial number static const PPM_Parameters PPM_prot[15]= @@ -121,6 +126,11 @@ static const PPM_Parameters PPM_prot[15]= MT99 H7 YZ + MODE_MJXQ + WLH08 + X600 + X800 + H26D RX_Num value between 0 and 15 @@ -152,7 +162,8 @@ enum chan_order{ AUX5, AUX6, AUX7, - AUX8 + AUX8, + AUX9 }; #endif @@ -174,7 +185,8 @@ enum chan_order{ AUX5, AUX6, AUX7, - AUX8 + AUX8, + AUX9 }; #endif @@ -196,7 +208,8 @@ enum chan_order{ AUX5, AUX6, AUX7, - AUX8 + AUX8, + AUX9 }; #endif @@ -218,10 +231,11 @@ enum chan_order{ AUX5, AUX6, AUX7, - AUX8 + AUX8, + AUX9 }; #endif #define PPM_MIN_COMMAND 1250 -#define PPM_SWITCH 1550 +#define PPM_SWITCH 1550 #define PPM_MAX_COMMAND 1750 diff --git a/Multiprotocol/multiprotocol.h b/Multiprotocol/multiprotocol.h index c1b3f35..3f735e5 100644 --- a/Multiprotocol/multiprotocol.h +++ b/Multiprotocol/multiprotocol.h @@ -44,6 +44,7 @@ enum PROTOCOLS MODE_FRSKYX = 15, // =>CC2500 MODE_ESKY = 16, // =>NRF24L01 MODE_MT99XX=17, // =>NRF24L01 + MODE_MJXQ=18 // =>NRF24L01 }; enum Flysky @@ -103,6 +104,13 @@ enum MT99XX H7 = 1, YZ = 2 }; +enum MJXQ +{ + WLH08 = 0, + X600 = 1, + X800 = 2, + H26D = 3 +}; #define NONE 0 #define P_HIGH 1 @@ -411,6 +419,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- FrskyX 15 ESky 16 MT99XX 17 + MJXQ 18 BindBit=> 0x80 1=Bind/0=No AutoBindBit=> 0x40 1=Yes /0=No RangeCheck=> 0x20 1=Yes /0=No @@ -457,6 +466,11 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- MT99 0 H7 1 YZ 2 + sub_protocol==MJXQ + WLH08 0 + X600 1 + X800 2 + H26D 3 Power value => 0x80 0=High/1=Low Stream[3] = option_protocol; option_protocol value is -127..127