WFLY2: add switch from PPM <-> WBUS

This commit is contained in:
Pascal Langer 2020-12-16 18:40:46 +01:00
parent 5ac41fdd15
commit a2559a65d3
2 changed files with 46 additions and 30 deletions

View File

@ -387,7 +387,7 @@ const mm_protocol_definition multi_protocols[] = {
{PROTO_WFLY, STR_WFLY, 1, STR_SUBTYPE_WFLY, OPTION_NONE },
#endif
#if defined(WFLY2_A7105_INO)
{PROTO_WFLY2, STR_WFLY2, 1, STR_SUBTYPE_WFLY2, OPTION_NONE },
{PROTO_WFLY2, STR_WFLY2, 1, STR_SUBTYPE_WFLY2, OPTION_OPTION },
#endif
#if defined(XK_NRF24L01_INO)
{PROTO_XK, STR_XK , 2, STR_SUBTYPE_XK, OPTION_RFTUNE },

View File

@ -32,7 +32,6 @@ enum{
static void __attribute__((unused)) WFLY2_build_packet()
{
static uint16_t pseudo=0;
uint8_t offset=0;
//End bind
if(IS_BIND_IN_PROGRESS && bind_counter)
@ -72,18 +71,6 @@ static void __attribute__((unused)) WFLY2_build_packet()
}
else
{
//Header
//packet[0] = 0x00; // Normal packet
#ifdef FAILSAFE_ENABLE
if(IS_FAILSAFE_VALUES_on)
{
packet[0] = 0x01; //Failsafe packet
packet[5] = 0x58; // unknown, values are counting 58,59,5A,5B and rollover
packet[6] = 0x55; // unknown and constant
offset=2;
}
#endif
//Pseudo
uint16_t high_bit=(pseudo & 0x8000) ^ 0x8000; // toggle 0x8000 every other line
pseudo <<= 1; // *2
@ -111,6 +98,33 @@ static void __attribute__((unused)) WFLY2_build_packet()
packet[3] = rx_tx_addr[3];
packet[4] = rx_tx_addr[2] & 0x03;
//Header
if(prev_option!=option)
{//Set the RX PPM/WBUS on change
packet[0] = 0x05; //PPM/WBUS packet
packet[5] = 0x01;
if(option)
packet[6] = 0x00; // WBUS
else
packet[6] = 0x01; // PPM
prev_option = option;
}
else
{//Normal or Failsafe packets
uint8_t offset=0;
//packet[0] = 0x00; // Normal packet
#ifdef FAILSAFE_ENABLE
if(IS_FAILSAFE_VALUES_on)
{//Failsafe packet
packet[0] = 0x01; //Failsafe packet
packet[5] = 0x58; // unknown, values are counting 58,59,5A,5B and rollover
packet[6] = 0x55; // unknown and constant
offset=2;
}
#endif
//10 channels -100%=0x2C1...0%=0x800...+100%=0xD3F
for(uint8_t i = 0; i < 5; i++)
{
@ -128,6 +142,7 @@ static void __attribute__((unused)) WFLY2_build_packet()
FAILSAFE_VALUES_off;
#endif
}
}
//Debug
#if 0
@ -289,6 +304,7 @@ uint16_t initWFLY2()
rf_ch_num = 0;
bind_counter = WFLY2_BIND_COUNT;
phase = WFLY2_DATA;
prev_option = option;
#ifdef WFLY2_HUB_TELEMETRY
packet_count = 0;
telemetry_lost = 1;