Skip to content

Commit 1ffb5c4

Browse files
author
Pascal Langer
committed
New protocol: Flyzone
Models compatible with TX FZ-410 Protocol 53 No sub protocol
1 parent ad29409 commit 1ffb5c4

7 files changed

Lines changed: 223 additions & 40 deletions

File tree

Multiprotocol/A7105_SPI.ino

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,20 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd)
183183
#endif
184184
break;
185185
case PROTO_BUGS:
186-
#ifdef FORCE_HUBSAN_TUNING
187-
offset=(int16_t)FORCE_HUBSAN_TUNING;
186+
#ifdef FORCE_BUGS_TUNING
187+
offset=(int16_t)FORCE_BUGS_TUNING;
188188
#endif
189189
break;
190190
case PROTO_FLYSKY:
191191
#ifdef FORCE_FLYSKY_TUNING
192192
offset=(int16_t)FORCE_FLYSKY_TUNING;
193193
#endif
194194
break;
195+
case PROTO_FLYZONE:
196+
#ifdef FORCE_FLYZONE_TUNING
197+
offset=(int16_t)FORCE_FLYZONE_TUNING;
198+
#endif
199+
break;
195200
case PROTO_AFHDS2A:
196201
#ifdef FORCE_AFHDS2A_TUNING
197202
offset=(int16_t)FORCE_AFHDS2A_TUNING;
@@ -247,22 +252,6 @@ static void __attribute__((unused)) A7105_SetVCOBand(uint8_t vb1, uint8_t vb2)
247252
A7105_WriteReg(A7105_25_VCO_SBCAL_I, vb2 | 0x08);
248253
}
249254

250-
#ifdef HUBSAN_A7105_INO
251-
const uint8_t PROGMEM HUBSAN_A7105_regs[] = {
252-
0xFF, 0x63, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x04, 0xFF, // 00 - 0f
253-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07, // 10 - 1f
254-
0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20 - 2f
255-
0xFF, 0xFF // 30 - 31
256-
};
257-
#endif
258-
#ifdef FLYSKY_A7105_INO
259-
const uint8_t PROGMEM FLYSKY_A7105_regs[] = {
260-
0xff, 0x42, 0x00, 0x14, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f
261-
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f
262-
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
263-
0x01, 0x0f // 30 - 31
264-
};
265-
#endif
266255
#ifdef AFHDS2A_A7105_INO
267256
const uint8_t PROGMEM AFHDS2A_A7105_regs[] = {
268257
0xFF, 0x42 | (1<<5), 0x00, 0x25, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c, 0x05, 0x00, 0x50, // 00 - 0f
@@ -279,6 +268,30 @@ const uint8_t PROGMEM BUGS_A7105_regs[] = {
279268
0x01, 0x0f // 30 - 31
280269
};
281270
#endif
271+
#ifdef FLYSKY_A7105_INO
272+
const uint8_t PROGMEM FLYSKY_A7105_regs[] = {
273+
0xff, 0x42, 0x00, 0x14, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f
274+
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f
275+
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
276+
0x01, 0x0f // 30 - 31
277+
};
278+
#endif
279+
#ifdef FLYZONE_A7105_INO
280+
const uint8_t PROGMEM FLYZONE_A7105_regs[] = {
281+
0xff, 0x42, 0x00, 0x07, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x01, 0x50, // 00 - 0f
282+
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x1f, // 10 - 1f
283+
0x12, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3a, 0x00, 0x3f, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
284+
0x01, 0x0f // 30 - 31
285+
};
286+
#endif
287+
#ifdef HUBSAN_A7105_INO
288+
const uint8_t PROGMEM HUBSAN_A7105_regs[] = {
289+
0xFF, 0x63, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x04, 0xFF, // 00 - 0f
290+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07, // 10 - 1f
291+
0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20 - 2f
292+
0xFF, 0xFF // 30 - 31
293+
};
294+
#endif
282295

283296
#define ID_NORMAL 0x55201041
284297
#define ID_PLUS 0xAA201041
@@ -287,6 +300,14 @@ void A7105_Init(void)
287300
uint8_t *A7105_Regs=0;
288301
uint8_t vco_calibration0, vco_calibration1;
289302

303+
#ifdef FLYZONE_A7105_INO
304+
if(protocol==PROTO_FLYZONE)
305+
{
306+
A7105_Regs=(uint8_t*)FLYZONE_A7105_regs;
307+
A7105_WriteID(0x25A53C45);
308+
}
309+
else
310+
#endif
290311
#ifdef BUGS_A7105_INO
291312
if(protocol==PROTO_BUGS)
292313
A7105_Regs=(uint8_t*)BUGS_A7105_regs;
@@ -360,7 +381,21 @@ void A7105_Init(void)
360381
A7105_SetVCOBand(vco_calibration0 & 0x07, vco_calibration1 & 0x07); // Set calibration band value to best match
361382
else
362383
if(protocol!=PROTO_HUBSAN)
363-
A7105_WriteReg(A7105_25_VCO_SBCAL_I,protocol==PROTO_FLYSKY?0x08:0x0A); //Reset VCO Band calibration
384+
{
385+
switch(protocol)
386+
{
387+
case PROTO_FLYSKY:
388+
vco_calibration1=0x08;
389+
break;
390+
case PROTO_FLYZONE:
391+
vco_calibration1=0x02;
392+
break;
393+
default:
394+
vco_calibration1=0x0A;
395+
break;
396+
}
397+
A7105_WriteReg(A7105_25_VCO_SBCAL_I,vco_calibration1); //Reset VCO Band calibration
398+
}
364399

365400
A7105_SetTxRxMode(TX_EN);
366401
A7105_SetPower();

Multiprotocol/Flyzone_a7105.ino

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
// Compatible with FZ-410 TX
16+
17+
#if defined(FLYZONE_A7105_INO)
18+
19+
#include "iface_a7105.h"
20+
21+
//#define FLYZONE_FORCEID
22+
23+
#define FLYZONE_BIND_COUNT 220 // 5 sec
24+
#define FLYZONE_BIND_CH 0x18 // TX, RX for bind end is 0x17
25+
26+
static void __attribute__((unused)) flyzone_build_packet()
27+
{
28+
packet[0] = 0xA5;
29+
packet[1] = rx_tx_addr[2];
30+
packet[2] = rx_tx_addr[3];
31+
packet[3] = convert_channel_8b(AILERON); //00..80..FF
32+
packet[4] = convert_channel_8b(ELEVATOR); //00..80..FF
33+
packet[5] = convert_channel_8b(THROTTLE); //00..FF
34+
packet[6] = convert_channel_8b(RUDDER); //00..80..FF
35+
packet[7] = 0xFF;
36+
}
37+
38+
uint16_t ReadFlyzone()
39+
{
40+
#ifndef FORCE_FLYZONE_TUNING
41+
A7105_AdjustLOBaseFreq(1);
42+
#endif
43+
if(IS_BIND_IN_PROGRESS)
44+
{
45+
packet[0] = 0x1B;
46+
packet[1] = rx_tx_addr[2];
47+
packet[2] = rx_tx_addr[3];
48+
A7105_WriteData(3, FLYZONE_BIND_CH);
49+
if (bind_counter--==0)
50+
BIND_DONE;
51+
return 22700;
52+
}
53+
else
54+
{
55+
if(phase>19)
56+
{
57+
phase=0;
58+
flyzone_build_packet();
59+
A7105_WriteData(8, hopping_frequency[0]);
60+
A7105_SetPower();
61+
}
62+
else
63+
{
64+
A7105_WriteReg(A7105_0F_PLL_I, hopping_frequency[(phase&0x02)>>1]);
65+
A7105_Strobe(A7105_TX);
66+
}
67+
phase++;
68+
}
69+
return 1500;
70+
}
71+
72+
uint16_t initFlyzone()
73+
{
74+
A7105_Init();
75+
76+
hopping_frequency[0]=((random(0xfefefefe) & 0x0F)+2)<<2;
77+
hopping_frequency[1]=hopping_frequency[0]+0x50;
78+
79+
#ifdef FLYZONE_FORCEID
80+
rx_tx_addr[2]=0x35;
81+
rx_tx_addr[3]=0xD0;
82+
hopping_frequency[0]=0x18;
83+
hopping_frequency[1]=0x68;
84+
#endif
85+
86+
phase=255;
87+
bind_counter = FLYZONE_BIND_COUNT;
88+
return 2400;
89+
}
90+
#endif
91+
// Normal packet is 8 bytes: 0xA5 0xAF 0x59 0x84 0x7A 0x00 0x80 0xFF
92+
// Protocol is using AETR channel order, 1 byte per channel 00..80..FF including trim. Channels are in packet [3,4,5,6].
93+
// packet[0,1,2,7] values are constant in normal mode.
94+
// packet[0]=0xA5 -> normal mode
95+
// packet[1,2] ->ID
96+
// packet[7]=0xFF -> ???
97+
// Channel values are updated every 30ms which is quite slow, slower than PPM...
98+
// Packets are sent every 1500µs on 2 different channels. 2 times on first channel, 2 times on second channel and restart. The channels are changing between the files 0x08, 0x58 and 0x18, 0x68.
99+
//
100+
// Bind is sending 3 bytes on channel 0x18: 0x1B 0x35 0xD0 every 22.7ms
101+
// packet[0]=0x1B -> bind mode
102+
// packet[1,2] ->ID
103+
// It listens for the model on channel 0x17 and recieves 0x1B 0x35 0xD0 when the plane accepts bind.

Multiprotocol/Multiprotocol.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_MAJOR 1
2020
#define VERSION_MINOR 2
2121
#define VERSION_REVISION 1
22-
#define VERSION_PATCH_LEVEL 70
22+
#define VERSION_PATCH_LEVEL 71
2323

2424
//******************
2525
// Protocols
@@ -79,6 +79,7 @@ enum PROTOCOLS
7979
PROTO_REDPINE = 50, // =>CC2500
8080
PROTO_POTENSIC = 51, // =>NRF24L01
8181
PROTO_ZSX = 52, // =>NRF24L01
82+
PROTO_FLYZONE = 53, // =>A7105
8283
PROTO_XN297DUMP = 63, // =>NRF24L01
8384
};
8485

@@ -90,6 +91,10 @@ enum Flysky
9091
V912 = 3,
9192
CX20 = 4,
9293
};
94+
enum Flyzone
95+
{
96+
FZ410 = 0,
97+
};
9398
enum Hubsan
9499
{
95100
H107 = 0,
@@ -630,6 +635,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
630635
REDPINE 50
631636
POTENSIC 51
632637
ZSX 52
638+
FLYZONE 53
633639
BindBit=> 0x80 1=Bind/0=No
634640
AutoBindBit=> 0x40 1=Yes /0=No
635641
RangeCheck=> 0x20 1=Yes /0=No

Multiprotocol/Multiprotocol.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,13 @@ static void protocol_init()
933933
remote_callback = ReadBUGS;
934934
break;
935935
#endif
936+
#if defined(FLYZONE_A7105_INO)
937+
case PROTO_FLYZONE:
938+
PE1_off; //antenna RF1
939+
next_callback = initFlyzone();
940+
remote_callback = ReadFlyzone;
941+
break;
942+
#endif
936943
#endif
937944
#ifdef CC2500_INSTALLED
938945
#if defined(FRSKYD_CC2500_INO)

Multiprotocol/Validate.h

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
#endif
6363

6464
// Check forced tuning values are valid
65+
//CC2500
66+
#ifdef FORCE_CORONA_TUNING
67+
#if ( FORCE_CORONA_TUNING < -127 ) || ( FORCE_CORONA_TUNING > 127 )
68+
#error "The CORONA forced frequency tuning value is outside of the range -127..127."
69+
#endif
70+
#endif
6571
#ifdef FORCE_FRSKYD_TUNING
6672
#if ( FORCE_FRSKYD_TUNING < -127 ) || ( FORCE_FRSKYD_TUNING > 127 )
6773
#error "The FrSkyD forced frequency tuning value is outside of the range -127..127."
@@ -77,45 +83,58 @@
7783
#error "The FrSkyX forced frequency tuning value is outside of the range -127..127."
7884
#endif
7985
#endif
80-
#ifdef FORCE_SFHSS_TUNING
81-
#if ( FORCE_SFHSS_TUNING < -127 ) || ( FORCE_SFHSS_TUNING > 127 )
82-
#error "The SFHSS forced frequency tuning value is outside of the range -127..127."
83-
#endif
84-
#endif
85-
#ifdef FORCE_CORONA_TUNING
86-
#if ( FORCE_CORONA_TUNING < -127 ) || ( FORCE_CORONA_TUNING > 127 )
87-
#error "The CORONA forced frequency tuning value is outside of the range -127..127."
86+
#ifdef FORCE_HITEC_TUNING
87+
#if ( FORCE_HITEC_TUNING < -127 ) || ( FORCE_HITEC_TUNING > 127 )
88+
#error "The HITEC forced frequency tuning value is outside of the range -127..127."
8889
#endif
8990
#endif
9091
#ifdef FORCE_REDPINE_TUNING
9192
#if ( FORCE_REDPINE_TUNING < -127 ) || ( FORCE_REDPINE_TUNING > 127 )
9293
#error "The REDPINE forced frequency tuning value is outside of the range -127..127."
9394
#endif
9495
#endif
95-
#ifdef FORCE_HITEC_TUNING
96-
#if ( FORCE_HITEC_TUNING < -127 ) || ( FORCE_HITEC_TUNING > 127 )
97-
#error "The HITEC forced frequency tuning value is outside of the range -127..127."
96+
#ifdef FORCE_SFHSS_TUNING
97+
#if ( FORCE_SFHSS_TUNING < -127 ) || ( FORCE_SFHSS_TUNING > 127 )
98+
#error "The SFHSS forced frequency tuning value is outside of the range -127..127."
99+
#endif
100+
#endif
101+
//A7105
102+
#ifdef FORCE_AFHDS2A_TUNING
103+
#if ( FORCE_AFHDS2A_TUNING < -300 ) || ( FORCE_AFHDS2A_TUNING > 300 )
104+
#error "The AFHDS2A forced frequency tuning value is outside of the range -300..300."
105+
#endif
106+
#endif
107+
#ifdef FORCE_BUGS_TUNING
108+
#if ( FORCE_BUGS_TUNING < -300 ) || ( FORCE_BUGS_TUNING > 300 )
109+
#error "The BUGS forced frequency tuning value is outside of the range -300..300."
98110
#endif
99111
#endif
100112
#ifdef FORCE_FLYSKY_TUNING
101113
#if ( FORCE_FLYSKY_TUNING < -300 ) || ( FORCE_FLYSKY_TUNING > 300 )
102114
#error "The Flysky forced frequency tuning value is outside of the range -300..300."
103115
#endif
104116
#endif
117+
#ifdef FORCE_FLYZONE_TUNING
118+
#if ( FORCE_FLYZONE_TUNING < -300 ) || ( FORCE_FLYZONE_TUNING > 300 )
119+
#error "The Flyzone forced frequency tuning value is outside of the range -300..300."
120+
#endif
121+
#endif
105122
#ifdef FORCE_HUBSAN_TUNING
106123
#if ( FORCE_HUBSAN_TUNING < -300 ) || ( FORCE_HUBSAN_TUNING > 300 )
107124
#error "The Hubsan forced frequency tuning value is outside of the range -300..300."
108125
#endif
109126
#endif
110-
#ifdef FORCE_AFHDS2A_TUNING
111-
#if ( FORCE_AFHDS2A_TUNING < -300 ) || ( FORCE_AFHDS2A_TUNING > 300 )
112-
#error "The AFHDS2A forced frequency tuning value is outside of the range -300..300."
113-
#endif
114-
#endif
127+
115128
#ifndef USE_A7105_CH15_TUNING
129+
#ifndef FORCE_BUGS_TUNING
130+
#define FORCE_BUGS_TUNING 0
131+
#endif
116132
#ifndef FORCE_FLYSKY_TUNING
117133
#define FORCE_FLYSKY_TUNING 0
118134
#endif
135+
#ifndef FORCE_FLYZONE_TUNING
136+
#define FORCE_FLYZONE_TUNING 0
137+
#endif
119138
#ifndef FORCE_HUBSAN_TUNING
120139
#define FORCE_HUBSAN_TUNING 0
121140
#endif
@@ -148,6 +167,7 @@
148167
#undef HUBSAN_A7105_INO
149168
#undef AFHDS2A_A7105_INO
150169
#undef BUGS_A7105_INO
170+
#undef FLYZONE_A7105_INO
151171
#endif
152172
#ifndef CYRF6936_INSTALLED
153173
#undef DEVO_CYRF6936_INO

0 commit comments

Comments
 (0)