Skip to content

Commit

Permalink
beeper - minor refactoring (#13610)
Browse files Browse the repository at this point in the history
  • Loading branch information
ledvinap committed May 17, 2024
1 parent 3094dd6 commit dac4939
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3332,12 +3332,12 @@ static void printBeeper(dumpFlags_t dumpMask, const uint32_t offFlags, const uin
headingStr = cliPrintSectionHeading(dumpMask, false, headingStr);
const uint8_t beeperCount = beeperTableEntryCount();
for (int32_t i = 0; i < beeperCount - 1; i++) {
if (beeperModeMaskForTableIndex(i) & allowedFlags) {
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
if (beeperModeMask & allowedFlags) {
const char *formatOff = "%s -%s";
const char *formatOn = "%s %s";
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
cliDefaultPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i));
const bool equalsDefault = ~(offFlags ^ offFlagsDefault) & beeperModeMask;
cliDefaultPrintLinef(dumpMask, equalsDefault, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i));
headingStr = cliPrintSectionHeading(dumpMask, !equalsDefault, headingStr);
cliDumpPrintLinef(dumpMask, equalsDefault, offFlags & beeperModeMask ? formatOff : formatOn, name, beeperNameForTableIndex(i));
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/beeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "common/time.h"
#include "common/utils.h"

#define BEEPER_GET_FLAG(mode) (1U << ((mode) - 1))

Expand Down Expand Up @@ -64,6 +65,7 @@ typedef enum {
// BEEPER_ALL must remain at the bottom of this enum
} beeperMode_e;

STATIC_ASSERT(BEEPER_ALL < sizeof(uint32_t) * 8, "BEEPER bits exhausted");

#define BEEPER_ALLOWED_MODES ( \
BEEPER_GET_FLAG(BEEPER_GYRO_CALIBRATED) \
Expand Down

0 comments on commit dac4939

Please sign in to comment.