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_PACKET_SIZE 15
#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 CX10A_PACKET_PERIOD 6000
@ -91,6 +91,7 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
break;
case Q282:
case Q242:
case Q222:
memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6);
//FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
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
|GET_FLAG(Servo_AUX3,0x10); // Channel 7 - picture
}
else
else if(sub_protocol==Q282)
{
flags=2;
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[18]=0x00;
}
else
{ // Q222
flags=0;
packet[15]=0x0C;
packet[16]=0x07;
}
if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH
break;
case DM007:
@ -233,20 +240,15 @@ uint16_t CX10_callback()
static void __attribute__((unused)) CX10_initialize_txid()
{
rx_tx_addr[1]%= 0x30;
if(sub_protocol==Q282)
if(sub_protocol&0x08) //Q2X2 protocols
{
hopping_frequency[0] = 0x46;
hopping_frequency[1] = 0x48;
hopping_frequency[2] = 0x4a;
hopping_frequency[3] = 0x4c;
}
else
uint8_t offset=0; //Q282
if(sub_protocol==Q242)
{
hopping_frequency[0] = 0x48;
hopping_frequency[1] = 0x4a;
hopping_frequency[2] = 0x4c;
hopping_frequency[3] = 0x4e;
offset=2;
if(sub_protocol==Q222)
offset=3;
for(uint8_t i=0;i<4;i++)
hopping_frequency[i]=0x46+2*i+offset;
}
else
{
@ -272,8 +274,8 @@ uint16_t initCX10(void)
}
else
{
if(sub_protocol==Q282||sub_protocol==Q242)
packet_length = Q282_PACKET_SIZE;
if(sub_protocol&0x08) //Q2X2 protocols
packet_length = Q2X2_PACKET_SIZE;
else
packet_length = CX10_PACKET_SIZE;
packet_period = CX10_PACKET_PERIOD;

View File

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

View File

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

View File

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

View File

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