Q2X2 protocol addition for Q222/Q242/Q282

Q2X2 protocol : 29
Sub-protocols:
- Q222 : 0
- Q242 : 1
- Q282 : 2
This commit is contained in:
pascallanger 2016-11-23 21:56:00 +01:00
parent 27b3a86155
commit c9de0b4cf2
5 changed files with 48 additions and 32 deletions

View File

@ -22,7 +22,7 @@
#define CX10_BIND_COUNT 4360 // 6 seconds #define CX10_BIND_COUNT 4360 // 6 seconds
#define CX10_PACKET_SIZE 15 #define CX10_PACKET_SIZE 15
#define CX10A_PACKET_SIZE 19 // CX10 blue board packets have 19-byte payload #define CX10A_PACKET_SIZE 19 // CX10 blue board packets have 19-byte payload
#define Q282_PACKET_SIZE 21 #define Q2X2_PACKET_SIZE 21
#define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec #define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec
#define CX10A_PACKET_PERIOD 6000 #define CX10A_PACKET_PERIOD 6000
@ -91,6 +91,7 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
break; break;
case Q282: case Q282:
case Q242: case Q242:
case Q222:
memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6); memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6);
//FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL //FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
flags2 = GET_FLAG(Servo_AUX1, 0x80) // Channel 5 - FLIP flags2 = GET_FLAG(Servo_AUX1, 0x80) // Channel 5 - FLIP
@ -111,7 +112,7 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
flags2 |= video_state flags2 |= video_state
|GET_FLAG(Servo_AUX3,0x10); // Channel 7 - picture |GET_FLAG(Servo_AUX3,0x10); // Channel 7 - picture
} }
else else if(sub_protocol==Q282)
{ {
flags=2; flags=2;
flags2|= GET_FLAG(Servo_AUX3,0x01) // Channel 7 - picture flags2|= GET_FLAG(Servo_AUX3,0x01) // Channel 7 - picture
@ -119,6 +120,12 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
packet[17]=0x00; packet[17]=0x00;
packet[18]=0x00; packet[18]=0x00;
} }
else
{ // Q222
flags=0;
packet[15]=0x0C;
packet[16]=0x07;
}
if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH
break; break;
case DM007: case DM007:
@ -233,28 +240,23 @@ uint16_t CX10_callback()
static void __attribute__((unused)) CX10_initialize_txid() static void __attribute__((unused)) CX10_initialize_txid()
{ {
rx_tx_addr[1]%= 0x30; rx_tx_addr[1]%= 0x30;
if(sub_protocol==Q282) if(sub_protocol&0x08) //Q2X2 protocols
{ {
hopping_frequency[0] = 0x46; uint8_t offset=0; //Q282
hopping_frequency[1] = 0x48; if(sub_protocol==Q242)
hopping_frequency[2] = 0x4a; offset=2;
hopping_frequency[3] = 0x4c; if(sub_protocol==Q222)
offset=3;
for(uint8_t i=0;i<4;i++)
hopping_frequency[i]=0x46+2*i+offset;
} }
else else
if(sub_protocol==Q242) {
{ hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F);
hopping_frequency[0] = 0x48; hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4);
hopping_frequency[1] = 0x4a; hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F);
hopping_frequency[2] = 0x4c; hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4);
hopping_frequency[3] = 0x4e; }
}
else
{
hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F);
hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4);
hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F);
hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4);
}
} }
uint16_t initCX10(void) uint16_t initCX10(void)
@ -272,8 +274,8 @@ uint16_t initCX10(void)
} }
else else
{ {
if(sub_protocol==Q282||sub_protocol==Q242) if(sub_protocol&0x08) //Q2X2 protocols
packet_length = Q282_PACKET_SIZE; packet_length = Q2X2_PACKET_SIZE;
else else
packet_length = CX10_PACKET_SIZE; packet_length = CX10_PACKET_SIZE;
packet_period = CX10_PACKET_PERIOD; packet_period = CX10_PACKET_PERIOD;

View File

@ -47,6 +47,7 @@ enum PROTOCOLS
MODE_HONTAI = 26, // =>NRF24L01 MODE_HONTAI = 26, // =>NRF24L01
MODE_OPENLRS = 27, // =>OpenLRS hardware MODE_OPENLRS = 27, // =>OpenLRS hardware
MODE_AFHDS2A = 28, // =>A7105 MODE_AFHDS2A = 28, // =>A7105
MODE_Q2X2 = 29, // =>NRF24L01, extension of CX-10 protocol
}; };
enum Flysky enum Flysky
@ -101,14 +102,18 @@ enum SLT
}; };
enum CX10 enum CX10
{ {
CX10_GREEN = 0, CX10_GREEN = 0,
CX10_BLUE = 1, // also compatible with CX10-A, CX12 CX10_BLUE = 1, // also compatible with CX10-A, CX12
DM007 = 2, DM007 = 2,
Q282 = 3,
JC3015_1 = 4, JC3015_1 = 4,
JC3015_2 = 5, JC3015_2 = 5,
MK33041 = 6, MK33041 = 6,
Q242 = 7 };
enum Q2X2
{
Q222 = 8,
Q242 = 9,
Q282 = 10,
}; };
enum CG023 enum CG023
{ {
@ -398,6 +403,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
HONTAI 26 HONTAI 26
OpenLRS 27 OpenLRS 27
AFHDS2A 28 AFHDS2A 28
Q2X2 29
BindBit=> 0x80 1=Bind/0=No BindBit=> 0x80 1=Bind/0=No
AutoBindBit=> 0x40 1=Yes /0=No AutoBindBit=> 0x40 1=Yes /0=No
RangeCheck=> 0x20 1=Yes /0=No RangeCheck=> 0x20 1=Yes /0=No
@ -434,11 +440,14 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
CX10_GREEN 0 CX10_GREEN 0
CX10_BLUE 1 // also compatible with CX10-A, CX12 CX10_BLUE 1 // also compatible with CX10-A, CX12
DM007 2 DM007 2
Q282 3 --- 3
JC3015_1 4 JC3015_1 4
JC3015_2 5 JC3015_2 5
MK33041 6 MK33041 6
Q242 7 sub_protocol==Q2X2
Q222 0
Q242 1
Q282 2
sub_protocol==SLT sub_protocol==SLT
SLT 0 SLT 0
VISTA 1 VISTA 1

View File

@ -761,6 +761,8 @@ static void protocol_init()
break; break;
#endif #endif
#if defined(CX10_NRF24L01_INO) #if defined(CX10_NRF24L01_INO)
case MODE_Q2X2:
sub_protocol|=0x08; // Increase the number of sub_protocols for CX-10
case MODE_CX10: case MODE_CX10:
next_callback=initCX10(); next_callback=initCX10();
remote_callback = CX10_callback; remote_callback = CX10_callback;

View File

@ -222,6 +222,7 @@ uint16_t initSLT()
if(sub_protocol == VISTA) if(sub_protocol == VISTA)
memcpy(hopping_frequency+6,"\x13\x0F\x0B\x10\x08\x16\x1D\x24\x06",9); memcpy(hopping_frequency+6,"\x13\x0F\x0B\x10\x08\x16\x1D\x24\x06",9);
SLT_init(); SLT_init();
SLT_build_packet();
phase = SLT_BIND; phase = SLT_BIND;
return 50000; return 50000;
} }

View File

@ -75,7 +75,7 @@
//The protocols below need a NRF24L01 to be installed //The protocols below need a NRF24L01 to be installed
#define BAYANG_NRF24L01_INO #define BAYANG_NRF24L01_INO
#define CG023_NRF24L01_INO #define CG023_NRF24L01_INO
#define CX10_NRF24L01_INO #define CX10_NRF24L01_INO // Include Q2X2 protocol
#define ESKY_NRF24L01_INO #define ESKY_NRF24L01_INO
#define HISKY_NRF24L01_INO #define HISKY_NRF24L01_INO
#define KN_NRF24L01_INO #define KN_NRF24L01_INO
@ -212,11 +212,13 @@ const PPM_Parameters PPM_prot[15]= {
CX10_GREEN CX10_GREEN
CX10_BLUE CX10_BLUE
DM007 DM007
Q282
JC3015_1 JC3015_1
JC3015_2 JC3015_2
MK33041 MK33041
MODE_Q2X2
Q222
Q242 Q242
Q282
MODE_SLT MODE_SLT
SLT SLT
VISTA VISTA