From 20e32c4cb0a939e8a90e49c376f28810297d746b Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Mon, 30 Nov 2020 13:36:29 +0100 Subject: [PATCH] Fix XK450 twitching? --- Multiprotocol/Multiprotocol.h | 4 +++- Multiprotocol/XK_nrf24l01.ino | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index f6ea988..64d23d6 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 1 -#define VERSION_PATCH_LEVEL 77 +#define VERSION_PATCH_LEVEL 78 //****************** // Protocols @@ -103,6 +103,7 @@ enum PROTOCOLS PROTO_RLINK = 74, // =>CC2500 PROTO_REALACC = 76, // =>NRF24L01 PROTO_OMP = 77, // =>CC2500 & NRF24L01 + PROTO_MLINK = 78, // =>CYRF6936 PROTO_NANORF = 126, // =>NRF24L01 PROTO_TEST = 127, // =>CC2500 @@ -834,6 +835,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- RLINK 74 REALACC 76 OMP 77 + MLINK 78 BindBit=> 0x80 1=Bind/0=No AutoBindBit=> 0x40 1=Yes /0=No RangeCheck=> 0x20 1=Yes /0=No diff --git a/Multiprotocol/XK_nrf24l01.ino b/Multiprotocol/XK_nrf24l01.ino index d47df04..5b21608 100644 --- a/Multiprotocol/XK_nrf24l01.ino +++ b/Multiprotocol/XK_nrf24l01.ino @@ -29,7 +29,16 @@ Multiprotocol is distributed in the hope that it will be useful, static uint16_t __attribute__((unused)) XK_convert_channel(uint8_t num) { - uint16_t val=convert_channel_10b(num); + uint16_t val; + if(num==RUDDER) + {// introduce deadband on rudder to prevent twitching + //debug("RUD:%d",val); + val=convert_channel_8b_limit_deadband(RUDDER,0x00,0x80, 0xFF, 40)<<2; + //debugln(",%d",val); + } + else + val=convert_channel_10b(num); + // 1FF..01=left, 00=center, 200..3FF=right if(val==0x200) val=0; // 0 @@ -58,16 +67,16 @@ static void __attribute__((unused)) XK_send_packet() { uint16_t val=convert_channel_10b(THROTTLE); packet[0] = val>>2; // 0..255 - //packet[12] |= val & 2; + packet[12] |= val & 2; val=XK_convert_channel(RUDDER); packet[1] = val>>2; - //packet[12] |= (val & 2)<<2; + packet[12] |= (val & 2)<<2; val=XK_convert_channel(ELEVATOR); packet[2] = val>>2; - //packet[13] |= val & 2; + packet[13] |= val & 2; val=XK_convert_channel(AILERON); packet[3] = val>>2; - //packet[13] |= (val & 2)<<2; + packet[13] |= (val & 2)<<2; memset(&packet[4],0x40,3); // Trims @@ -84,6 +93,7 @@ static void __attribute__((unused)) XK_send_packet() |GET_FLAG(CH6_SW,0x40); // Take off momentary switch packet[14] = GET_FLAG(CH9_SW,0x01) // Photo momentary switch |GET_FLAG(CH10_SW,0x2); // Video momentary switch + //debugln("P1:%02X,P12:%02X",packet[1],packet[12]); } crc=packet[0];