mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 11:59:58 +03:00
Merge pull request #5891 from mikeller/add_disable_rx_loss_dshot_beacon_option
Implemented 'beacon' command in CLI.
This commit is contained in:
commit
f37a8184d5
12 changed files with 129 additions and 137 deletions
|
@ -2432,46 +2432,45 @@ static void cliFeature(char *cmdline)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_BEEPER
|
||||
static void printBeeper(uint8_t dumpMask, const beeperConfig_t *beeperConfig, const beeperConfig_t *beeperConfigDefault)
|
||||
#if defined(USE_BEEPER)
|
||||
static void printBeeper(uint8_t dumpMask, const uint32_t offFlags, const uint32_t offFlagsDefault, const char *name)
|
||||
{
|
||||
const uint8_t beeperCount = beeperTableEntryCount();
|
||||
const uint32_t mask = beeperConfig->beeper_off_flags;
|
||||
const uint32_t defaultMask = beeperConfigDefault->beeper_off_flags;
|
||||
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
||||
const char *formatOff = "beeper -%s";
|
||||
const char *formatOn = "beeper %s";
|
||||
const char *formatOff = "%s -%s";
|
||||
const char *formatOn = "%s %s";
|
||||
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
|
||||
cliDefaultPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOn : formatOff, beeperNameForTableIndex(i));
|
||||
cliDumpPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOff : formatOn, beeperNameForTableIndex(i));
|
||||
cliDefaultPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i));
|
||||
cliDumpPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOff : formatOn, name, beeperNameForTableIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
static void cliBeeper(char *cmdline)
|
||||
static void processBeeperCommand(char *cmdline, uint32_t *offFlags, const uint32_t allowedFlags)
|
||||
{
|
||||
uint32_t len = strlen(cmdline);
|
||||
uint8_t beeperCount = beeperTableEntryCount();
|
||||
uint32_t mask = getBeeperOffMask();
|
||||
|
||||
if (len == 0) {
|
||||
cliPrintf("Disabled:");
|
||||
for (int32_t i = 0; ; i++) {
|
||||
if (i == beeperCount - 2) {
|
||||
if (mask == 0)
|
||||
if (i == beeperCount - 1) {
|
||||
if (*offFlags == 0)
|
||||
cliPrint(" none");
|
||||
break;
|
||||
}
|
||||
|
||||
if (mask & beeperModeMaskForTableIndex(i))
|
||||
if (beeperModeMaskForTableIndex(i) & *offFlags)
|
||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||
}
|
||||
cliPrintLinefeed();
|
||||
} else if (strncasecmp(cmdline, "list", len) == 0) {
|
||||
cliPrint("Available:");
|
||||
for (uint32_t i = 0; i < beeperCount; i++)
|
||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||
for (uint32_t i = 0; i < beeperCount; i++) {
|
||||
if (beeperModeMaskForTableIndex(i) & allowedFlags) {
|
||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||
}
|
||||
}
|
||||
cliPrintLinefeed();
|
||||
return;
|
||||
} else {
|
||||
bool remove = false;
|
||||
if (cmdline[0] == '-') {
|
||||
|
@ -2485,27 +2484,21 @@ static void cliBeeper(char *cmdline)
|
|||
cliPrintErrorLinef("Invalid name");
|
||||
break;
|
||||
}
|
||||
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0) {
|
||||
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0 && beeperModeMaskForTableIndex(i) & (allowedFlags | BEEPER_GET_FLAG(BEEPER_ALL))) {
|
||||
if (remove) { // beeper off
|
||||
if (i == BEEPER_ALL-1)
|
||||
beeperOffSetAll(beeperCount-2);
|
||||
else
|
||||
if (i == BEEPER_PREFERENCE-1)
|
||||
setBeeperOffMask(getPreferredBeeperOffMask());
|
||||
else {
|
||||
beeperOffSet(beeperModeMaskForTableIndex(i));
|
||||
}
|
||||
if (i == BEEPER_ALL - 1) {
|
||||
*offFlags = allowedFlags;
|
||||
} else {
|
||||
*offFlags |= beeperModeMaskForTableIndex(i);
|
||||
}
|
||||
cliPrint("Disabled");
|
||||
}
|
||||
else { // beeper on
|
||||
if (i == BEEPER_ALL-1)
|
||||
beeperOffClearAll();
|
||||
else
|
||||
if (i == BEEPER_PREFERENCE-1)
|
||||
setPreferredBeeperOffMask(getBeeperOffMask());
|
||||
else {
|
||||
beeperOffClear(beeperModeMaskForTableIndex(i));
|
||||
}
|
||||
if (i == BEEPER_ALL - 1) {
|
||||
*offFlags = 0;
|
||||
} else {
|
||||
*offFlags &= ~beeperModeMaskForTableIndex(i);
|
||||
}
|
||||
cliPrint("Enabled");
|
||||
}
|
||||
cliPrintLinef(" %s", beeperNameForTableIndex(i));
|
||||
|
@ -2514,6 +2507,18 @@ static void cliBeeper(char *cmdline)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(USE_DSHOT)
|
||||
static void cliBeacon(char *cmdline)
|
||||
{
|
||||
processBeeperCommand(cmdline, &(beeperConfigMutable()->dshotBeaconOffFlags), DSHOT_BEACON_ALLOWED_MODES);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cliBeeper(char *cmdline)
|
||||
{
|
||||
processBeeperCommand(cmdline, &(beeperConfigMutable()->beeper_off_flags), BEEPER_ALLOWED_MODES);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_RX_FRSKY_SPI
|
||||
|
@ -4149,10 +4154,15 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
cliPrintHashLine("feature");
|
||||
printFeature(dumpMask, &featureConfig_Copy, featureConfig());
|
||||
|
||||
#ifdef USE_BEEPER
|
||||
#if defined(USE_BEEPER)
|
||||
cliPrintHashLine("beeper");
|
||||
printBeeper(dumpMask, &beeperConfig_Copy, beeperConfig());
|
||||
printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper");
|
||||
|
||||
#if defined(USE_DSHOT)
|
||||
cliPrintHashLine("beacon");
|
||||
printBeeper(dumpMask, beeperConfig_Copy.dshotBeaconOffFlags, beeperConfig()->dshotBeaconOffFlags, "beacon");
|
||||
#endif
|
||||
#endif // USE_BEEPER
|
||||
|
||||
cliPrintHashLine("map");
|
||||
printMap(dumpMask, &rxConfig_Copy, rxConfig());
|
||||
|
@ -4307,10 +4317,14 @@ static void cliHelp(char *cmdline);
|
|||
const clicmd_t cmdTable[] = {
|
||||
CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL, cliAdjustmentRange),
|
||||
CLI_COMMAND_DEF("aux", "configure modes", "<index> <mode> <aux> <start> <end> <logic>", cliAux),
|
||||
#ifdef USE_BEEPER
|
||||
#if defined(USE_BEEPER)
|
||||
#if defined(USE_DSHOT)
|
||||
CLI_COMMAND_DEF("beacon", "turn on/off beeper", "list\r\n"
|
||||
"\t<+|->[name]", cliBeacon),
|
||||
#endif
|
||||
CLI_COMMAND_DEF("beeper", "turn on/off beeper", "list\r\n"
|
||||
"\t<+|->[name]", cliBeeper),
|
||||
#endif
|
||||
#endif // USE_BEEPER
|
||||
CLI_COMMAND_DEF("bl", "reboot into bootloader", NULL, cliBootloader),
|
||||
#if defined(USE_BOARD_INFO)
|
||||
CLI_COMMAND_DEF("board_name", "get / set the name of the board model", "[board name]", cliBoardName),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue