mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-01 18:27:53 +00:00
V761: code cleanup
This commit is contained in:
parent
ffe4ac68fd
commit
13197840c2
@ -50,7 +50,6 @@ static void __attribute__((unused)) V761_set_checksum()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void __attribute__((unused)) V761_send_packet()
|
static void __attribute__((unused)) V761_send_packet()
|
||||||
{
|
{
|
||||||
static bool calib=false, prev_ch6=false;
|
static bool calib=false, prev_ch6=false;
|
||||||
@ -68,6 +67,15 @@ static void __attribute__((unused)) V761_send_packet()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
XN297_Hopping(hopping_frequency_no++);
|
||||||
|
if(hopping_frequency_no >= V761_RF_NUM_CHANNELS)
|
||||||
|
{
|
||||||
|
hopping_frequency_no = 0;
|
||||||
|
packet_count++;
|
||||||
|
if(packet_count >= 4)
|
||||||
|
packet_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
packet[0] = convert_channel_8b(THROTTLE); // Throttle
|
packet[0] = convert_channel_8b(THROTTLE); // Throttle
|
||||||
packet[2] = convert_channel_8b(ELEVATOR)>>1; // Elevator
|
packet[2] = convert_channel_8b(ELEVATOR)>>1; // Elevator
|
||||||
|
|
||||||
@ -82,8 +90,8 @@ static void __attribute__((unused)) V761_send_packet()
|
|||||||
packet[3] = convert_channel_8b(RUDDER)>>1; // Rudder
|
packet[3] = convert_channel_8b(RUDDER)>>1; // Rudder
|
||||||
}
|
}
|
||||||
|
|
||||||
packet[5] = (packet_count++ / 3)<<6;
|
packet[5] = packet_count<<6; // 0X, 4X, 8X, CX
|
||||||
packet[4] = (packet[5] == 0x40) ? 0x1a : 0x20; // ?
|
packet[4] = 0x20; // Trims 00..20..40, 0X->20 4X->TrAil 8X->TrEle CX->TrRud
|
||||||
|
|
||||||
if(CH5_SW) // Mode Expert Gyro off
|
if(CH5_SW) // Mode Expert Gyro off
|
||||||
flags = 0x0c;
|
flags = 0x0c;
|
||||||
@ -105,17 +113,16 @@ static void __attribute__((unused)) V761_send_packet()
|
|||||||
|GET_FLAG(CH8_SW, 0x08) // RTH activation
|
|GET_FLAG(CH8_SW, 0x08) // RTH activation
|
||||||
|GET_FLAG(CH9_SW, 0x10); // RTH on/off
|
|GET_FLAG(CH9_SW, 0x10); // RTH on/off
|
||||||
if(sub_protocol==V761_3CH)
|
if(sub_protocol==V761_3CH)
|
||||||
packet[6] |= 0x80; // unknown, set on original V761-1 dump but not on eachine dumps, keeping for compatibility
|
packet[6] |= 0x80; // Unknown, set on original V761-1 dump but not on eachine dumps, keeping for compatibility
|
||||||
|
|
||||||
//packet counter
|
|
||||||
if(packet_count >= 12)
|
|
||||||
packet_count = 0;
|
|
||||||
XN297_Hopping(hopping_frequency_no++);
|
|
||||||
if(hopping_frequency_no >= V761_RF_NUM_CHANNELS)
|
|
||||||
hopping_frequency_no = 0;
|
|
||||||
}
|
}
|
||||||
V761_set_checksum();
|
V761_set_checksum();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
debug("H:%02X P:",hopping_frequency_no);
|
||||||
|
for(uint8_t i=0;i<V761_PACKET_SIZE;i++)
|
||||||
|
debug(" %02X",packet[i]);
|
||||||
|
debugln("");
|
||||||
|
#endif
|
||||||
// Send
|
// Send
|
||||||
XN297_SetPower();
|
XN297_SetPower();
|
||||||
XN297_SetTxRxMode(TX_EN);
|
XN297_SetTxRxMode(TX_EN);
|
||||||
@ -191,8 +198,9 @@ uint16_t V761_callback()
|
|||||||
V761_send_packet();
|
V761_send_packet();
|
||||||
if(bind_counter == 0)
|
if(bind_counter == 0)
|
||||||
{
|
{
|
||||||
phase = V761_DATA;
|
packet_count = 0;
|
||||||
BIND_DONE;
|
BIND_DONE;
|
||||||
|
phase = V761_DATA;
|
||||||
}
|
}
|
||||||
else if(packet_count >= 20)
|
else if(packet_count >= 20)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user