Skip to content

Commit 53f58ce

Browse files
author
Pascal Langer
committed
JJRC345: update
1 parent eb8b5ea commit 53f58ce

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

Multiprotocol/JJRC345_nrf24l01.ino

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ enum JJRC345_FLAGS {
3737
static uint8_t __attribute__((unused)) JJRC345_convert_channel(uint8_t num)
3838
{
3939
uint8_t val=convert_channel_8b(num);
40-
// Should be 70..60..41..01, 80 center, 81..C1..E0..F0
41-
// Trying 7F..01, 80 center, 81..FF
40+
// 70..60..41..01, 80 center, 81..C1..E0..F0
4241
if(val<0x80)
4342
{
4443
val=0x80-val; // 80..01
45-
if(val==0x80)
46-
val--; // 7F..01
44+
if(val>0x70)
45+
val=0x70; // 70..01
4746
}
47+
else if(val>0xF0)
48+
val=0xF0; // 81..F0
4849
return val;
4950
}
5051

@@ -54,6 +55,7 @@ static void __attribute__((unused)) JJRC345_send_packet()
5455
packet[2] = 0x00;
5556
if (IS_BIND_IN_PROGRESS)
5657
{ //00 05 00 0A 46 4A 41 47 00 00 40 46 A5 4A F1 18
58+
debug("CH:%d,",JJRC345_RF_BIND_CHANNEL);
5759
packet[1] = JJRC345_RF_BIND_CHANNEL;
5860
packet[4] = hopping_frequency[0];
5961
packet[5] = hopping_frequency[1];
@@ -63,15 +65,29 @@ static void __attribute__((unused)) JJRC345_send_packet()
6365
}
6466
else
6567
{ //00 41 00 0A 00 80 80 80 00 00 40 46 00 49 F1 18
66-
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++]);
67-
if (hopping_frequency_no >= JJRC345_NUM_CHANNELS)
68-
hopping_frequency_no = 0;
68+
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]);
69+
debug("CH:%d,", hopping_frequency[hopping_frequency_no]);
70+
hopping_frequency_no++;
71+
hopping_frequency_no %= JJRC345_NUM_CHANNELS;
6972
packet[1] = hopping_frequency[hopping_frequency_no]; // next packet will be sent on this channel
7073

7174
packet[4] = convert_channel_8b(THROTTLE); // throttle: 00..FF
7275
packet[5] = JJRC345_convert_channel(RUDDER); // rudder: 70..60..41..01, 80 center, 81..C1..E0..F0
7376
packet[6] = JJRC345_convert_channel(ELEVATOR); // elevator: 70..60..41..01, 80 center, 81..C1..E0..F0
7477
packet[7] = JJRC345_convert_channel(AILERON); // aileron: 70..60..41..01, 80 center, 81..C1..E0..F0
78+
79+
if(CH5_SW) //Flip
80+
{
81+
if(packet[6]>90)
82+
packet[6]=0xFF;
83+
else if(packet[6]<80 && packet[6]>10)
84+
packet[6]=0x7F;
85+
else if(packet[7]>90)
86+
packet[7]=0xFF;
87+
else if(packet[7]<80 && packet[7]>10)
88+
packet[7]=0x7F;
89+
}
90+
7591
packet[12] = 0x02; // Rate: 00-01-02
7692
}
7793
packet[3] = (packet[4] >= 0xB7) ? 0x0e : 0x0a; // Some throttle flag. 0A when Thr <= B6, 0E when Thr >= B7, sometimes 06 when moving Ele/Ail
@@ -85,11 +101,17 @@ static void __attribute__((unused)) JJRC345_send_packet()
85101
// Checksum
86102
packet[13] = 0xf8;
87103
for (uint8_t i = 0; i < 13; i++)
104+
{
105+
debug(" %02X", packet[i]);
88106
packet[13] += packet[i];
89-
107+
}
108+
debug("%02X ", packet[13]);
109+
90110
// TX ID
91111
packet[14] = rx_tx_addr[2];
112+
debug(" %02X", packet[14]);
92113
packet[15] = rx_tx_addr[3];
114+
debugln(" %02X", packet[15]);
93115

94116
// Power on, TX mode
95117
XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP));

Protocols_Details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ Model: JJRC345
11031103

11041104
CH1|CH2|CH3|CH4|CH5|CH6
11051105
---|---|---|---|---|---
1106-
A|E|T|R||HEADLESS
1106+
A|E|T|R|FLIP|HEADLESS
11071107

11081108
## KF606 - *49*
11091109
Model: KF606

0 commit comments

Comments
 (0)