Skip to content

Commit 756af87

Browse files
committed
SGF22 Flags trial
1 parent e5810a2 commit 756af87

6 files changed

+202
-16
lines changed

Multiprotocol/FX_nrf24l01.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void __attribute__((unused)) FX_send_packet()
9090
// QIDI-550=>0:3D, 1:6G, 2:Torque
9191
| (Channel_data[CH6] < CHANNEL_MIN_COMMAND ? 0x00 : (Channel_data[CH6] > CHANNEL_MAX_COMMAND ? 0x04 : 0x02));
9292
if(sub_protocol == FX_Q560)
93-
packet[5] |= GET_FLAG(CH7_SW, 0x18); // Q560 LED flag 0x10 conflicting with trim_ch...
93+
packet[5] |= GET_FLAG(CH7_SW, 0x18); // Q560 LED flag 0x10 conflicting with trim_ch... Corrected on new boards using 0x08 instead
9494
}
9595
else // FX816 and FX620
9696
{

Multiprotocol/Multi_Protos.ino

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const char STR_SGF22[] ="SGF22";
112112
const char STR_EAZYRC[] ="EazyRC";
113113
const char STR_KYOSHO3[] ="Kyosho3";
114114
const char STR_YUXIANG[] ="YuXiang";
115+
const char STR_PINECONE[] ="PineCone";
115116

116117
const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
117118
const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501";
@@ -425,6 +426,9 @@ const mm_protocol_definition multi_protocols[] = {
425426
#if defined(PELIKAN_A7105_INO)
426427
{PROTO_PELIKAN, STR_PELIKAN, STR_SUBTYPE_PELIKAN, 3, OPTION_NONE, 0, 1, SW_A7105, PELIKAN_init, PELIKAN_callback },
427428
#endif
429+
#if defined(PINECONE_CCNRF_INO)
430+
{PROTO_PINECONE, STR_PINECONE, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, PINECONE_init, PINECONE_callback },
431+
#endif
428432
#if defined(POTENSIC_NRF24L01_INO)
429433
{PROTO_POTENSIC, STR_POTENSIC, STR_SUBTYPE_POTENSIC, 1, OPTION_NONE, 0, 0, SW_NRF, POTENSIC_init, POTENSIC_callback },
430434
#endif

Multiprotocol/Multiprotocol.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_MAJOR 1
2020
#define VERSION_MINOR 3
2121
#define VERSION_REVISION 4
22-
#define VERSION_PATCH_LEVEL 21
22+
#define VERSION_PATCH_LEVEL 22
2323

2424
#define MODE_SERIAL 0
2525

@@ -75,7 +75,7 @@ enum PROTOCOLS
7575
PROTO_NCC1701 = 44, // =>NRF24L01
7676
PROTO_E01X = 45, // =>CYRF6936
7777
PROTO_V911S = 46, // =>NRF24L01
78-
PROTO_GD00X = 47, // =>NRF24L01
78+
PROTO_GD00X = 47, // =>CC2500 & NRF24L01
7979
PROTO_V761 = 48, // =>NRF24L01
8080
PROTO_KF606 = 49, // =>NRF24L01
8181
PROTO_REDPINE = 50, // =>CC2500
@@ -128,6 +128,7 @@ enum PROTOCOLS
128128
PROTO_KYOSHO3 = 98, // =>CYRF6936
129129
PROTO_XK2 = 99, // =>CC2500 & NRF24L01
130130
PROTO_YUXIANG = 100, // =>NRF24L01
131+
PROTO_PINECONE = 101, // =>CC2500 & NRF24L01
131132

132133
PROTO_NANORF = 126, // =>NRF24L01
133134
PROTO_TEST = 127, // =>CC2500

Multiprotocol/Pinecone_ccnrf.ino

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
This project is free software: you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation, either version 3 of the License, or
5+
(at your option) any later version.
6+
7+
Multiprotocol is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
14+
*/
15+
#if defined(PINECONE_CCNRF_INO)
16+
17+
#include "iface_xn297.h"
18+
19+
#define FORCE_PINECONE_ORIGINAL_ID
20+
21+
#define PINECONE_PAYLOAD_SIZE 15
22+
#define PINECONE_RF_NUM_CHANNELS 4
23+
#define PINECONE_PACKET_PERIOD 9000
24+
#define PINECONE_BIND_COUNT 2000
25+
#define PINECONE_WRITE_TIME 1500
26+
27+
enum {
28+
PINECONE_DATA=0,
29+
PINECONE_RX,
30+
};
31+
32+
static void __attribute__((unused)) PINECONE_send_packet()
33+
{
34+
if(rf_ch_num==0)
35+
{
36+
XN297_Hopping(hopping_frequency_no);
37+
debug("H %d ",hopping_frequency_no);
38+
hopping_frequency_no++;
39+
hopping_frequency_no &= 3;
40+
}
41+
42+
if(bind_counter==0) bind_counter=2;
43+
memset(&packet[3], 0x00, 12);
44+
if(bind_counter)
45+
{//Bind in progress
46+
bind_counter--;
47+
if(bind_counter)
48+
{//Bind
49+
packet[0] = 0x01;
50+
memcpy(&packet[1],rx_tx_addr,5);
51+
}
52+
else
53+
{//Switch to normal
54+
XN297_SetTXAddr(rx_tx_addr, 5);
55+
XN297_SetRXAddr(rx_tx_addr, PINECONE_PAYLOAD_SIZE);
56+
}
57+
}
58+
if(!bind_counter)
59+
{//Normal
60+
packet[0] = 0x08;
61+
packet[1] = convert_channel_16b_limit(AILERON,0,200); //ST
62+
packet[2] = convert_channel_16b_limit(THROTTLE,0,200); //TH
63+
packet[3] = convert_channel_16b_limit(ELEVATOR,0,200); //CH4
64+
packet[4] = convert_channel_16b_limit(RUDDER,0,200); //CH3
65+
}
66+
//packet[5/6..8] = 00 unknown
67+
packet[9] = convert_channel_16b_limit(CH5,0,200); //ESP
68+
packet[10] = convert_channel_16b_limit(CH6,0,200); //ST_TRIM
69+
packet[11] = convert_channel_16b_limit(CH7,0,200); //ST_DR
70+
packet[12] = GET_FLAG(CH8_SW, 0x40) //TH.REV
71+
|GET_FLAG(CH9_SW, 0x80); //ST.REV
72+
//packet[13] = 00 unknown
73+
for(uint8_t i=0;i<PINECONE_PAYLOAD_SIZE-1;i++)
74+
packet[14] += packet[i];
75+
// Send
76+
XN297_SetPower();
77+
XN297_SetTxRxMode(TX_EN);
78+
XN297_WriteEnhancedPayload(packet, PINECONE_PAYLOAD_SIZE,false);
79+
#ifdef DEBUG_SERIAL
80+
for(uint8_t i=0; i < PINECONE_PAYLOAD_SIZE; i++)
81+
debug("%02X ", packet[i]);
82+
debugln();
83+
#endif
84+
}
85+
86+
static void __attribute__((unused)) PINECONE_initialize_txid()
87+
{
88+
#ifdef FORCE_PINECONE_ORIGINAL_ID
89+
rx_tx_addr[0] = 0xD0;
90+
rx_tx_addr[1] = 0x06;
91+
rx_tx_addr[2] = 0x00;
92+
rx_tx_addr[3] = 0x00;
93+
rx_tx_addr[4] = 0x81;
94+
hopping_frequency[0] = 45;
95+
hopping_frequency[1] = 59;
96+
hopping_frequency[2] = 52;
97+
hopping_frequency[3] = 67;
98+
#endif
99+
}
100+
101+
static void __attribute__((unused)) PINECONE_RF_init()
102+
{
103+
XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_250K);
104+
//Bind address
105+
XN297_SetTXAddr((uint8_t*)"\x01\x03\x05\x07\x09", 5);
106+
XN297_SetRXAddr((uint8_t*)"\x01\x03\x05\x07\x09", PINECONE_PAYLOAD_SIZE);
107+
XN297_HoppingCalib(PINECONE_RF_NUM_CHANNELS);
108+
}
109+
110+
uint16_t PINECONE_callback()
111+
{
112+
bool rx;
113+
switch(phase)
114+
{
115+
case PINECONE_DATA:
116+
rx = XN297_IsRX();
117+
XN297_SetTxRxMode(TXRX_OFF);
118+
#ifdef MULTI_SYNC
119+
telemetry_set_input_sync(PINECONE_PACKET_PERIOD);
120+
#endif
121+
PINECONE_send_packet();
122+
if(rx)
123+
{
124+
uint8_t val=XN297_ReadEnhancedPayload(packet_in, PINECONE_PAYLOAD_SIZE);
125+
debug("RX %d ",val);
126+
if(val==0)
127+
rf_ch_num = 1;
128+
else
129+
{
130+
#ifdef DEBUG_SERIAL
131+
for(uint8_t i=0; i < PINECONE_PAYLOAD_SIZE; i++)
132+
debug("%02X ", packet_in[i]);
133+
debugln();
134+
#endif
135+
//could check the validity of the packet by looking at the sum...
136+
}
137+
//else
138+
// debug("NOK");
139+
debugln("");
140+
}
141+
phase++;
142+
return PINECONE_WRITE_TIME;
143+
default: //PINECONE_RX
144+
//Wait for the packet transmission to finish
145+
while(XN297_IsPacketSent()==false);
146+
//Switch to RX
147+
XN297_SetTxRxMode(TXRX_OFF);
148+
XN297_SetTxRxMode(RX_EN);
149+
phase = PINECONE_DATA;
150+
return PINECONE_PACKET_PERIOD - PINECONE_WRITE_TIME;
151+
}
152+
return 0;
153+
}
154+
155+
void PINECONE_init()
156+
{
157+
PINECONE_initialize_txid();
158+
PINECONE_RF_init();
159+
160+
bind_counter = IS_BIND_IN_PROGRESS ? PINECONE_BIND_COUNT : 1;
161+
phase = PINECONE_DATA;
162+
hopping_frequency_no = 0;
163+
rf_ch_num=0;
164+
bind_counter = 2000;
165+
}
166+
167+
#endif

Multiprotocol/SGF22_nrf24l01.ino

+27-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Multiprotocol is distributed in the hope that it will be useful,
3030

3131
//packet[8]
3232
#define SGF22_FLAG_3D 0x00
33-
#define SGF22_FLAG_ROLL 0x08
3433
#define SGF22_FLAG_LIGHT 0x04
34+
#define SGF22_FLAG_ROLL 0x08
3535
#define SGF22_FLAG_VIDEO 0x10
3636
#define SGF22_FLAG_6G 0x40
3737
#define SGF22_FLAG_VERTICAL 0xC0
@@ -40,8 +40,8 @@ Multiprotocol is distributed in the hope that it will be useful,
4040
//#define SGF22_J20_FLAG_SPEED 0x01 // Up/Down trim, not implemented
4141

4242
//packet[9]
43-
#define SGF22_FLAG_PHOTO 0x40 // #define SGF22_J20_FLAG_INVERT 0x40
4443
#define SGF22_FLAG_TRIMRESET 0x04
44+
#define SGF22_FLAG_PHOTO 0x40 // #define SGF22_J20_FLAG_INVERT 0x40
4545
#define SGF22_J20_FLAG_FIXHEIGHT 0x80
4646

4747
static void __attribute__((unused)) SGF22_send_packet()
@@ -66,16 +66,31 @@ static void __attribute__((unused)) SGF22_send_packet()
6666
packet_sent = 0;
6767
//packet
6868
packet[0] = 0x1B;
69-
packet[8] = SGF22_FLAG_3D // CH5 -100%, F22 & F22S - 3D mode, J20 - Gyro off
70-
| GET_FLAG(CH6_SW, SGF22_FLAG_ROLL) // roll
71-
| GET_FLAG(CH7_SW, SGF22_FLAG_LIGHT) // push up throttle trim for light in the stock TX
72-
| GET_FLAG(CH9_SW, SGF22_FLAG_VIDEO); // push down throttle trim for video in the stock TX
73-
if(Channel_data[CH5] > CHANNEL_MAX_COMMAND)
74-
packet[8] |= SGF22_FLAG_VERTICAL; // CH5 100%, vertical mode (torque)
75-
else if(Channel_data[CH5] > CHANNEL_MIN_COMMAND )
76-
packet[8] |= ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_HORIZONTAL : SGF22_FLAG_6G ); // CH5 0%, F22 & F22S - 6G mode, J20 - Horizontal mode
77-
packet[9] = GET_FLAG(CH8_SW, SGF22_FLAG_PHOTO) // F22: photo, press in throttle trim in the stock TX, J20: invert flight
78-
| GET_FLAG(CH10_SW, ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_FIXHEIGHT : SGF22_FLAG_TRIMRESET )) ; // F22: Both sticks down inwards in the stock TX, J20: Altitude hold
69+
packet[8] = SGF22_FLAG_3D // CH5 -100%, F22 & F22S - 3D mode, J20 - Gyro off
70+
| GET_FLAG(CH6_SW, SGF22_FLAG_ROLL) // roll
71+
| GET_FLAG(CH7_SW, SGF22_FLAG_LIGHT) // push up throttle trim for light in the stock TX
72+
| GET_FLAG(CH9_SW, SGF22_FLAG_VIDEO); // push down throttle trim for video in the stock TX
73+
if(Channel_data[CH5] > CHANNEL_MAX_COMMAND)
74+
packet[8] |= SGF22_FLAG_VERTICAL; // CH5 100%, vertical mode (torque)
75+
else if(Channel_data[CH5] > CHANNEL_MIN_COMMAND )
76+
packet[8] |= ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_HORIZONTAL : SGF22_FLAG_6G ); // CH5 0%, F22 & F22S - 6G mode, J20 - Horizontal mode
77+
packet[9] = GET_FLAG(CH8_SW, SGF22_FLAG_PHOTO) // F22: photo, press in throttle trim in the stock TX, J20: invert flight
78+
| GET_FLAG(CH10_SW, ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_FIXHEIGHT : SGF22_FLAG_TRIMRESET )) ; // F22: Both sticks down inwards in the stock TX, J20: Altitude hold
79+
80+
//Trial for FLYBear FX922
81+
if(sub_protocol==SGF22_F22)
82+
{
83+
packet[8] = GET_FLAG(CH11_SW, 0x01)
84+
| GET_FLAG(CH12_SW, 0x02)
85+
| GET_FLAG(CH13_SW, 0x20)
86+
| GET_FLAG(CH14_SW, 0x80);
87+
packet[9] = GET_FLAG(CH15_SW, 0x01)
88+
| GET_FLAG(CH16_SW, 0x02);
89+
// | GET_FLAG(CH13_SW, 0x08)
90+
// | GET_FLAG(CH13_SW, 0x10)
91+
// | GET_FLAG(CH13_SW, 0x20)
92+
// | GET_FLAG(CH13_SW, 0x80)
93+
}
7994
packet[10] = 0x42; // no fine tune
8095
packet[11] = 0x10; // no fine tune
8196
}

Multiprotocol/XN297_EMU.ino

-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ static uint8_t __attribute__((unused)) XN297_ReadEnhancedPayload(uint8_t* msg, u
440440

441441
// Read payload
442442
XN297_ReceivePayload(buffer, len+2); // Read pcf + payload + CRC
443-
444443
// Decode payload
445444
pcf_size = buffer[0];
446445
if(xn297_scramble_enabled)

0 commit comments

Comments
 (0)