Skip to content

Commit bfc8c2f

Browse files
committed
Kyosho2/KT-17: only 1 ID
1 parent ce6243d commit bfc8c2f

File tree

8 files changed

+169
-12
lines changed

8 files changed

+169
-12
lines changed

Lua_scripts/MultiChan.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,4 @@
204204
90,1,MouldKg,Digit,0
205205
91,0,Xerall,Tank,0,FlTa,TakLan,Rate,HLess,Photo,Video,TrimR,TrimE,TrimA
206206
92,0,MT99xx2,PA18,0,MODE,FLIP,RTH
207+
93,0,Kyosho2,KT-17,0

Multiprotocol/Kyosho2_nrf24l01.ino

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
16+
#if defined(KYOSHO2_NRF24L01_INO)
17+
18+
#include "iface_nrf24l01.h"
19+
20+
#define KYOSHO2_PACKET_PERIOD 1120 // 1600 for bind, let's see
21+
#define KYOSHO2_BIND_COUNT 2000 // about 3sec
22+
#define KYOSHO2_BIND_CHANNEL 0x50
23+
#define KYOSHO2_PAYLOAD_SIZE 28
24+
#define KYOSHO2_RF_CHANNELS 15
25+
#define KYOSHO2_START_RF_CHANNEL 0x13 // No idea where it comes from... ID or unknown bytes during the bind?
26+
#define KYOSHO2_NUM_CHANNEL 10 // Only 4 on the dumps but there is space for 10 channels in the payload...
27+
28+
#define FORCE_KYOSHO2_ID
29+
30+
bool KYOSHO2_resend;
31+
//
32+
static void __attribute__((unused)) KYOSHO2_send_packet()
33+
{
34+
if(KYOSHO2_resend == true)
35+
{
36+
NRF24L01_Strobe(NRF24L01_E3_REUSE_TX_PL);
37+
if(IS_BIND_DONE)
38+
KYOSHO2_resend = false;
39+
return;
40+
}
41+
42+
memset(packet,0x00,KYOSHO2_PAYLOAD_SIZE);
43+
44+
if(IS_BIND_IN_PROGRESS)
45+
{
46+
memcpy(packet, (uint8_t*)"\x01\x02\x05\x08\x1A\x2B\x3C\x4D", 8); // unknown bytes, parameters on how to build the rf channels?
47+
memcpy(&packet[8], rx_tx_addr, 4);
48+
}
49+
else
50+
{
51+
memcpy(packet, rx_tx_addr, 4);
52+
//Hopp
53+
packet[6] = hopping_frequency_no + KYOSHO2_START_RF_CHANNEL;
54+
packet[7] = hopping_frequency[hopping_frequency_no];
55+
NRF24L01_WriteReg(NRF24L01_05_RF_CH, packet[6+(rf_ch_num&0x01)]);
56+
rf_ch_num++;
57+
//Channels
58+
uint16_t temp;
59+
for (uint8_t i = 0; i< KYOSHO2_NUM_CHANNEL; i++)
60+
{
61+
temp=convert_channel_16b_limit(i,0,0x3FF);
62+
packet[8+i*2] = temp >> 8;
63+
packet[9+i*2] = temp;
64+
}
65+
}
66+
//Send
67+
NRF24L01_WriteReg(NRF24L01_07_STATUS, (_BV(NRF24L01_07_TX_DS) | _BV(NRF24L01_07_MAX_RT))); // Reset flags
68+
NRF24L01_FlushTx();
69+
NRF24L01_WritePayload(packet,KYOSHO2_PAYLOAD_SIZE);
70+
NRF24L01_SetPower();
71+
KYOSHO2_resend = true;
72+
73+
#if 0
74+
for(uint8_t i=0;i<KYOSHO2_PAYLOAD_SIZE;i++)
75+
debug("%02X ", packet[i]);
76+
debugln("");
77+
#endif
78+
}
79+
80+
static void __attribute__((unused)) KYOSHO2_RF_init()
81+
{
82+
NRF24L01_Initialize();
83+
NRF24L01_WriteReg(NRF24L01_05_RF_CH, KYOSHO2_BIND_CHANNEL);
84+
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t*)"\x69\x53\x10\xAC\xEF", 5);
85+
}
86+
87+
static void __attribute__((unused)) KYOSHO2_initialize_tx_id()
88+
{
89+
hopping_frequency_no = rx_tx_addr[3]%KYOSHO2_RF_CHANNELS;
90+
hopping_frequency[0] = 0x4A;
91+
#ifdef FORCE_KYOSHO2_ID
92+
memcpy(rx_tx_addr, (uint8_t*)"\x0A\xBD\x31\xDF", 4);
93+
hopping_frequency[0] = 0x4A; // No idea where it comes from... ID or unknown bytes during the bind?
94+
#endif
95+
for(uint8_t i=1;i<KYOSHO2_RF_CHANNELS;i++)
96+
{
97+
if(hopping_frequency[i-1]+5 < 0x50)
98+
hopping_frequency[i] = hopping_frequency[i-1]+5;
99+
else
100+
hopping_frequency[i] = hopping_frequency[i-1]-0x21;
101+
}
102+
#if 0
103+
for(uint8_t i=0;i<KYOSHO2_RF_CHANNELS;i++)
104+
debugln("1:%02X, 2: %02X", i + KYOSHO2_START_RF_CHANNEL, hopping_frequency[i]);
105+
debugln("Selected 1:%02X, 2: %02X", hopping_frequency_no + KYOSHO2_START_RF_CHANNEL, hopping_frequency[hopping_frequency_no]);
106+
#endif
107+
}
108+
109+
uint16_t KYOSHO2_callback()
110+
{
111+
#ifdef MULTI_SYNC
112+
telemetry_set_input_sync(KYOSHO2_PACKET_PERIOD);
113+
#endif
114+
if(bind_counter)
115+
if(--bind_counter==0)
116+
{
117+
BIND_DONE;
118+
KYOSHO2_resend = false;
119+
}
120+
KYOSHO2_send_packet();
121+
return KYOSHO2_PACKET_PERIOD;
122+
}
123+
124+
void KYOSHO2_init()
125+
{
126+
KYOSHO2_initialize_tx_id();
127+
KYOSHO2_RF_init();
128+
rf_ch_num = 0;
129+
130+
if(IS_BIND_IN_PROGRESS)
131+
bind_counter = KYOSHO2_BIND_COUNT;
132+
else
133+
bind_counter = 0;
134+
KYOSHO2_resend = false;
135+
}
136+
137+
#endif

Multiprotocol/Multi.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@
8888
89,Losi
8989
90,MouldKg,Analog,Digit
9090
91,Xerall
91-
92,MT99xx,PA18
91+
92,MT99xx,PA18
92+
93,Kyosho2,KT-17

Multiprotocol/Multi_Protos.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const char STR_FRSKYR9[] ="FrSkyR9";
8888
const char STR_PROPEL[] ="Propel";
8989
const char STR_SKYARTEC[] ="Skyartc";
9090
const char STR_KYOSHO[] ="Kyosho";
91+
const char STR_KYOSHO2[] ="Kyosho2";
9192
const char STR_RLINK[] ="RadLink";
9293
const char STR_REALACC[] ="Realacc";
9394
const char STR_OMP[] ="OMP";
@@ -158,6 +159,7 @@ const char STR_SUBTYPE_V761[] = "\x03""3ch""4ch";
158159
const char STR_SUBTYPE_RLINK[] = "\x07""Surface""Air\0 ""DumboRC";
159160
const char STR_SUBTYPE_REALACC[] = "\x03""R11";
160161
const char STR_SUBTYPE_KYOSHO[] = "\x04""FHSS""Hype";
162+
const char STR_SUBTYPE_KYOSHO2[] = "\x05""KT-17";
161163
const char STR_SUBTYPE_FUTABA[] = "\x05""SFHSS";
162164
const char STR_SUBTYPE_JJRC345[] = "\x08""JJRC345\0""SkyTmblr";
163165
const char STR_SUBTYPE_MOULKG[] = "\x06""Analog""Digit\0";
@@ -358,6 +360,9 @@ const mm_protocol_definition multi_protocols[] = {
358360
#if defined(KYOSHO_A7105_INO)
359361
{PROTO_KYOSHO, STR_KYOSHO, STR_SUBTYPE_KYOSHO, 2, OPTION_NONE, 0, 1, SW_A7105, KYOSHO_init, KYOSHO_callback },
360362
#endif
363+
#if defined(KYOSHO2_NRF24L01_INO)
364+
{PROTO_KYOSHO2, STR_KYOSHO2, STR_SUBTYPE_KYOSHO2, 1, OPTION_NONE, 0, 0, SW_NRF, KYOSHO2_init, KYOSHO2_callback },
365+
#endif
361366
#if defined(LOLI_NRF24L01_INO)
362367
{PROTO_LOLI, STR_LOLI, NO_SUBTYPE, 0, OPTION_NONE, 1, 0, SW_NRF, LOLI_init, LOLI_callback },
363368
#endif

Multiprotocol/Multiprotocol.h

Lines changed: 2 additions & 1 deletion
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 3
22-
#define VERSION_PATCH_LEVEL 18
22+
#define VERSION_PATCH_LEVEL 19
2323

2424
#define MODE_SERIAL 0
2525

@@ -120,6 +120,7 @@ enum PROTOCOLS
120120
PROTO_MOULDKG = 90, // =>NRF24L01
121121
PROTO_XERALL = 91, // =>NRF24L01
122122
PROTO_MT99XX2 = 92, // =>NRF24L01, extension of MT99XX protocol
123+
PROTO_KYOSHO2 = 93, // =>NRF24L01
123124

124125
PROTO_NANORF = 126, // =>NRF24L01
125126
PROTO_TEST = 127, // =>CC2500

Multiprotocol/Validate.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,16 @@
242242

243243
//Make sure protocols are selected correctly
244244
#ifndef A7105_INSTALLED
245-
#undef AFHDS2A_A7105_INO
246-
#undef AFHDS2A_RX_A7105_INO
247-
#undef BUGS_A7105_INO
248-
#undef FLYSKY_A7105_INO
249-
#undef HEIGHT_A7105_INO
250-
#undef HUBSAN_A7105_INO
251-
#undef JOYSWAY_A7105_INO
252-
#undef KYOSHO_A7105_INO
253-
#undef PELIKAN_A7105_INO
254-
#undef WFLY2_A7105_INO
245+
#undef AFHDS2A_A7105_INO
246+
#undef AFHDS2A_RX_A7105_INO
247+
#undef BUGS_A7105_INO
248+
#undef FLYSKY_A7105_INO
249+
#undef HEIGHT_A7105_INO
250+
#undef HUBSAN_A7105_INO
251+
#undef JOYSWAY_A7105_INO
252+
#undef KYOSHO_A7105_INO
253+
#undef PELIKAN_A7105_INO
254+
#undef WFLY2_A7105_INO
255255
#endif
256256
#ifndef CYRF6936_INSTALLED
257257
#undef DEVO_CYRF6936_INO
@@ -307,6 +307,7 @@
307307
#undef HONTAI_NRF24L01_INO
308308
#undef JJRC345_NRF24L01_INO
309309
#undef KN_NRF24L01_INO
310+
#undef KYOSHO2_NRF24L01_INO
310311
#undef LOLI_NRF24L01_INO
311312
#undef MOULDKG_NRF24L01_INO
312313
#undef NCC1701_NRF24L01_INO

Multiprotocol/_Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
#define H8_3D_NRF24L01_INO
238238
#define JJRC345_NRF24L01_INO
239239
#define KN_NRF24L01_INO
240+
#define KYOSHO2_NRF24L01_INO
240241
#define LOLI_NRF24L01_INO
241242
//#define MOULDKG_NRF24L01_INO
242243
#define NCC1701_NRF24L01_INO
@@ -722,6 +723,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
722723
PROTO_KYOSHO
723724
KYOSHO_FHSS
724725
KYOSHO_HYPE
726+
PROTO_KYOSHO2
727+
NONE
725728
PROTO_LOLI
726729
NONE
727730
PROTO_LOSI

Protocols_Details.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ CFlie|38|CFlie||||||||NRF24L01|
113113
[KF606](Protocols_Details.md#KF606---49)|49|KF606|MIG320|||||||NRF24L01|XN297
114114
[KN](Protocols_Details.md#KN---9)|9|WLTOYS|FEILUN|||||||NRF24L01|
115115
[Kyosho](Protocols_Details.md#Kyosho---73)|73|FHSS|Hype|||||||A7105|
116+
[Kyosho2](Protocols_Details.md#Kyosho2---93)|93|KT-17||||||||NRF24L01|
116117
[LOLI](Protocols_Details.md#LOLI---82)|82|||||||||NRF24L01|
117118
[Losi](Protocols_Details.md#Losi---89)|89|||||||||CYRF6936|
118119
[MJXq](Protocols_Details.md#MJXQ---18)|18|WLH08|X600|X800|H26D|E010*|H26WH|PHOENIX*||NRF24L01|XN297
@@ -1731,6 +1732,13 @@ Model: DF-Models SkyTumbler
17311732

17321733
RTH not supported
17331734

1735+
## KYOSHO2 - *93*
1736+
Model: TX KT-17, Minium Edge 540, Minium Citabria
1737+
1738+
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10
1739+
---|---|---|---|---|---|---|---|---|----
1740+
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10
1741+
17341742
## LOLI - *82*
17351743
LOLI3 receivers: https://github.com/wooddoor/Loli3
17361744

0 commit comments

Comments
 (0)