1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

Merge pull request #3479 from betaflight/cleanup-map-command

BF - Port cleaned-up map command from CF.
This commit is contained in:
Michael Keller 2017-07-09 23:25:02 +12:00 committed by GitHub
commit f32ab306dc

View file

@ -2097,31 +2097,41 @@ static void printMap(uint8_t dumpMask, const rxConfig_t *rxConfig, const rxConfi
cliDumpPrintLinef(dumpMask, equalsDefault, formatMap, buf); cliDumpPrintLinef(dumpMask, equalsDefault, formatMap, buf);
} }
static void cliMap(char *cmdline) static void cliMap(char *cmdline)
{ {
uint32_t len; uint32_t i;
char out[9]; char buf[RX_MAPPABLE_CHANNEL_COUNT + 1];
len = strlen(cmdline); uint32_t len = strlen(cmdline);
if (len == RX_MAPPABLE_CHANNEL_COUNT) {
if (len == 8) { for (i = 0; i < RX_MAPPABLE_CHANNEL_COUNT; i++) {
// uppercase it buf[i] = toupper((unsigned char)cmdline[i]);
for (uint32_t i = 0; i < 8; i++) }
cmdline[i] = toupper((unsigned char)cmdline[i]); buf[i] = '\0';
for (uint32_t i = 0; i < 8; i++) {
if (strchr(rcChannelLetters, cmdline[i]) && !strchr(cmdline + i + 1, cmdline[i])) for (i = 0; i < RX_MAPPABLE_CHANNEL_COUNT; i++) {
buf[i] = toupper((unsigned char)cmdline[i]);
if (strchr(rcChannelLetters, buf[i]) && !strchr(buf + i + 1, buf[i]))
continue; continue;
cliShowParseError(); cliShowParseError();
return; return;
} }
parseRcChannels(cmdline, rxConfigMutable()); parseRcChannels(buf, rxConfigMutable());
} else if (len > 0) {
cliShowParseError();
return;
} }
cliPrint("Map: ");
uint32_t i; for (i = 0; i < RX_MAPPABLE_CHANNEL_COUNT; i++) {
for (i = 0; i < 8; i++) buf[rxConfig()->rcmap[i]] = rcChannelLetters[i];
out[rxConfig()->rcmap[i]] = rcChannelLetters[i]; }
out[i] = '\0';
cliPrintLine(out); buf[i] = '\0';
cliPrintLinef("map %s", buf);
} }
static char *checkCommand(char *cmdLine, const char *command) static char *checkCommand(char *cmdLine, const char *command)