From 3b20f876da52b478b7f6f516eff44fdae905bafd Mon Sep 17 00:00:00 2001 From: Woga65 Date: Wed, 22 Jun 2022 21:13:31 +0200 Subject: [PATCH 1/2] rework rc channel remapping --- src/main/fc/cli.c | 10 +++++----- src/main/rx/rx.c | 4 ++-- src/main/rx/rx.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 8beac13f17c..cb8a196eac6 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -2790,15 +2790,15 @@ static void printMap(uint8_t dumpMask, const rxConfig_t *rxConfig, const rxConfi static void cliMap(char *cmdline) { uint32_t len; - char out[5]; + char out[MAX_MAPPABLE_RX_INPUTS + 1]; len = strlen(cmdline); - if (len == 4) { + if (len == MAX_MAPPABLE_RX_INPUTS) { // uppercase it - for (uint32_t i = 0; i < 4; i++) + for (uint32_t i = 0; i < len; i++) cmdline[i] = sl_toupper((unsigned char)cmdline[i]); - for (uint32_t i = 0; i < 4; i++) { + for (uint32_t i = 0; i < len; i++) { if (strchr(rcChannelLetters, cmdline[i]) && !strchr(cmdline + i + 1, cmdline[i])) continue; cliShowParseError(); @@ -2809,7 +2809,7 @@ static void cliMap(char *cmdline) cliShowParseError(); cliPrint("Map: "); uint32_t i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MAPPABLE_RX_INPUTS; i++) out[rxConfig()->rcmap[i]] = rcChannelLetters[i]; out[i] = '\0'; cliPrintLinef("%s", out); diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index fd4e7834736..8a2a0a2deb4 100755 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -71,7 +71,7 @@ //#define DEBUG_RX_SIGNAL_LOSS -const char rcChannelLetters[] = "AERT"; +const char rcChannelLetters[] = "AERT1234"; static uint16_t rssi = 0; // range: [0;1023] static timeUs_t lastMspRssiUpdateUs = 0; @@ -124,7 +124,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(rxConfig_t, rxConfig, PG_RX_CONFIG, 10); #define RX_MIN_USEX 885 PG_RESET_TEMPLATE(rxConfig_t, rxConfig, .receiverType = DEFAULT_RX_TYPE, - .rcmap = {0, 1, 3, 2}, // Default to AETR map + .rcmap = {0, 1, 3, 2, 4, 5, 6, 7}, // Default to AETR1234 map .halfDuplex = SETTING_SERIALRX_HALFDUPLEX_DEFAULT, .serialrx_provider = SERIALRX_PROVIDER, #ifdef USE_RX_SPI diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index 665f6d6e600..05cf010f5db 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -95,7 +95,7 @@ typedef enum { extern const char rcChannelLetters[]; -#define MAX_MAPPABLE_RX_INPUTS 4 +#define MAX_MAPPABLE_RX_INPUTS 8 #define MAX_INVALID_RX_PULSE_TIME 300 From f620448e42c61bf435d8524ce0c174d5eb71fde4 Mon Sep 17 00:00:00 2001 From: Woga65 Date: Thu, 23 Jun 2022 12:35:39 +0200 Subject: [PATCH 2/2] channel remapping respect MAX_MAPPABLE_RX_INPUTS --- src/main/rx/rx.c | 9 ++++++++- src/main/rx/rx.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index 8a2a0a2deb4..d70c571dcfa 100755 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -70,8 +70,11 @@ #include "rx/mavlink.h" //#define DEBUG_RX_SIGNAL_LOSS - +#if (MAX_MAPPABLE_RX_INPUTS == 4) +const char rcChannelLetters[] = "AERT"; +#else const char rcChannelLetters[] = "AERT1234"; +#endif static uint16_t rssi = 0; // range: [0;1023] static timeUs_t lastMspRssiUpdateUs = 0; @@ -124,7 +127,11 @@ PG_REGISTER_WITH_RESET_TEMPLATE(rxConfig_t, rxConfig, PG_RX_CONFIG, 10); #define RX_MIN_USEX 885 PG_RESET_TEMPLATE(rxConfig_t, rxConfig, .receiverType = DEFAULT_RX_TYPE, +#if (MAX_MAPPABLE_RX_INPUTS == 4) + .rcmap = {0, 1, 3, 2}, // Default to AETR map +#else .rcmap = {0, 1, 3, 2, 4, 5, 6, 7}, // Default to AETR1234 map +#endif .halfDuplex = SETTING_SERIALRX_HALFDUPLEX_DEFAULT, .serialrx_provider = SERIALRX_PROVIDER, #ifdef USE_RX_SPI diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index 05cf010f5db..c9a12518107 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -95,7 +95,7 @@ typedef enum { extern const char rcChannelLetters[]; -#define MAX_MAPPABLE_RX_INPUTS 8 +#define MAX_MAPPABLE_RX_INPUTS 4 //either 4 or 8 #define MAX_INVALID_RX_PULSE_TIME 300