mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
sync order of beeperTable and beeperMode_e enum
add beeperModeMaskForTableIndex function and use it in CLI add change to unittest to make it compile
This commit is contained in:
parent
1e9b553392
commit
5d258d11f2
4 changed files with 23 additions and 8 deletions
|
@ -2035,8 +2035,9 @@ static void printBeeper(uint8_t dumpMask, const beeperConfig_t *beeperConfig, co
|
||||||
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
||||||
const char *formatOff = "beeper -%s";
|
const char *formatOff = "beeper -%s";
|
||||||
const char *formatOn = "beeper %s";
|
const char *formatOn = "beeper %s";
|
||||||
cliDefaultPrintLinef(dumpMask, ~(mask ^ defaultMask) & (1 << i), mask & (1 << i) ? formatOn : formatOff, beeperNameForTableIndex(i));
|
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
|
||||||
cliDumpPrintLinef(dumpMask, ~(mask ^ defaultMask) & (1 << i), mask & (1 << i) ? formatOff : formatOn, beeperNameForTableIndex(i));
|
cliDefaultPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOn : formatOff, beeperNameForTableIndex(i));
|
||||||
|
cliDumpPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOff : formatOn, beeperNameForTableIndex(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2054,7 +2055,8 @@ static void cliBeeper(char *cmdline)
|
||||||
cliPrint(" none");
|
cliPrint(" none");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mask & (1 << i))
|
|
||||||
|
if (mask & beeperModeMaskForTableIndex(i))
|
||||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||||
}
|
}
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
|
@ -2085,8 +2087,7 @@ static void cliBeeper(char *cmdline)
|
||||||
if (i == BEEPER_PREFERENCE-1)
|
if (i == BEEPER_PREFERENCE-1)
|
||||||
setBeeperOffMask(getPreferredBeeperOffMask());
|
setBeeperOffMask(getPreferredBeeperOffMask());
|
||||||
else {
|
else {
|
||||||
mask = 1 << i;
|
beeperOffSet(beeperModeMaskForTableIndex(i));
|
||||||
beeperOffSet(mask);
|
|
||||||
}
|
}
|
||||||
cliPrint("Disabled");
|
cliPrint("Disabled");
|
||||||
}
|
}
|
||||||
|
@ -2097,8 +2098,7 @@ static void cliBeeper(char *cmdline)
|
||||||
if (i == BEEPER_PREFERENCE-1)
|
if (i == BEEPER_PREFERENCE-1)
|
||||||
setPreferredBeeperOffMask(getBeeperOffMask());
|
setPreferredBeeperOffMask(getBeeperOffMask());
|
||||||
else {
|
else {
|
||||||
mask = 1 << i;
|
beeperOffClear(beeperModeMaskForTableIndex(i));
|
||||||
beeperOffClear(mask);
|
|
||||||
}
|
}
|
||||||
cliPrint("Enabled");
|
cliPrint("Enabled");
|
||||||
}
|
}
|
||||||
|
|
13
src/main/io/beeper.c
Normal file → Executable file
13
src/main/io/beeper.c
Normal file → Executable file
|
@ -431,6 +431,18 @@ beeperMode_e beeperModeForTableIndex(int idx)
|
||||||
return (idx >= 0 && idx < (int)BEEPER_TABLE_ENTRY_COUNT) ? beeperTable[idx].mode : BEEPER_SILENCE;
|
return (idx >= 0 && idx < (int)BEEPER_TABLE_ENTRY_COUNT) ? beeperTable[idx].mode : BEEPER_SILENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the binary mask for the 'beeperMode_e' value corresponding to a given
|
||||||
|
* beeper-table index, or 0 if the beeperMode is BEEPER_SILENCE.
|
||||||
|
*/
|
||||||
|
uint32_t beeperModeMaskForTableIndex(int idx)
|
||||||
|
{
|
||||||
|
beeperMode_e beeperMode = beeperModeForTableIndex(idx);
|
||||||
|
if (beeperMode == BEEPER_SILENCE)
|
||||||
|
return 0;
|
||||||
|
return 1 << (beeperMode - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the name for the given beeper-table index, or NULL if none.
|
* Returns the name for the given beeper-table index, or NULL if none.
|
||||||
*/
|
*/
|
||||||
|
@ -470,6 +482,7 @@ void beeperWarningBeeps(uint8_t beepCount) {UNUSED(beepCount);}
|
||||||
void beeperUpdate(timeUs_t currentTimeUs) {UNUSED(currentTimeUs);}
|
void beeperUpdate(timeUs_t currentTimeUs) {UNUSED(currentTimeUs);}
|
||||||
uint32_t getArmingBeepTimeMicros(void) {return 0;}
|
uint32_t getArmingBeepTimeMicros(void) {return 0;}
|
||||||
beeperMode_e beeperModeForTableIndex(int idx) {UNUSED(idx); return BEEPER_SILENCE;}
|
beeperMode_e beeperModeForTableIndex(int idx) {UNUSED(idx); return BEEPER_SILENCE;}
|
||||||
|
uint32_t beeperModeMaskForTableIndex(int idx) {UNUSED(idx); return 0;}
|
||||||
const char *beeperNameForTableIndex(int idx) {UNUSED(idx); return NULL;}
|
const char *beeperNameForTableIndex(int idx) {UNUSED(idx); return NULL;}
|
||||||
int beeperTableEntryCount(void) {return 0;}
|
int beeperTableEntryCount(void) {return 0;}
|
||||||
bool isBeeperOn(void) {return false;}
|
bool isBeeperOn(void) {return false;}
|
||||||
|
|
|
@ -34,11 +34,11 @@ typedef enum {
|
||||||
BEEPER_BAT_LOW, // Warning beeps when battery is getting low (repeats)
|
BEEPER_BAT_LOW, // Warning beeps when battery is getting low (repeats)
|
||||||
BEEPER_GPS_STATUS, // FIXME **** Disable beeper when connected to USB ****
|
BEEPER_GPS_STATUS, // FIXME **** Disable beeper when connected to USB ****
|
||||||
BEEPER_RX_SET, // Beeps when aux channel is set for beep or beep sequence how many satellites has found if GPS enabled
|
BEEPER_RX_SET, // Beeps when aux channel is set for beep or beep sequence how many satellites has found if GPS enabled
|
||||||
BEEPER_DISARM_REPEAT, // Beeps sounded while stick held in disarm position
|
|
||||||
BEEPER_ACC_CALIBRATION, // ACC inflight calibration completed confirmation
|
BEEPER_ACC_CALIBRATION, // ACC inflight calibration completed confirmation
|
||||||
BEEPER_ACC_CALIBRATION_FAIL, // ACC inflight calibration failed
|
BEEPER_ACC_CALIBRATION_FAIL, // ACC inflight calibration failed
|
||||||
BEEPER_READY_BEEP, // Ring a tone when GPS is locked and ready
|
BEEPER_READY_BEEP, // Ring a tone when GPS is locked and ready
|
||||||
BEEPER_MULTI_BEEPS, // Internal value used by 'beeperConfirmationBeeps()'.
|
BEEPER_MULTI_BEEPS, // Internal value used by 'beeperConfirmationBeeps()'.
|
||||||
|
BEEPER_DISARM_REPEAT, // Beeps sounded while stick held in disarm position
|
||||||
BEEPER_ARMED, // Warning beeps when board is armed (repeats until board is disarmed or throttle is increased)
|
BEEPER_ARMED, // Warning beeps when board is armed (repeats until board is disarmed or throttle is increased)
|
||||||
BEEPER_SYSTEM_INIT, // Initialisation beeps when board is powered on
|
BEEPER_SYSTEM_INIT, // Initialisation beeps when board is powered on
|
||||||
BEEPER_USB, // Some boards have beeper powered USB connected
|
BEEPER_USB, // Some boards have beeper powered USB connected
|
||||||
|
@ -65,6 +65,7 @@ void beeperConfirmationBeeps(uint8_t beepCount);
|
||||||
void beeperWarningBeeps(uint8_t beepCount);
|
void beeperWarningBeeps(uint8_t beepCount);
|
||||||
uint32_t getArmingBeepTimeMicros(void);
|
uint32_t getArmingBeepTimeMicros(void);
|
||||||
beeperMode_e beeperModeForTableIndex(int idx);
|
beeperMode_e beeperModeForTableIndex(int idx);
|
||||||
|
uint32_t beeperModeMaskForTableIndex(int idx);
|
||||||
const char *beeperNameForTableIndex(int idx);
|
const char *beeperNameForTableIndex(int idx);
|
||||||
int beeperTableEntryCount(void);
|
int beeperTableEntryCount(void);
|
||||||
bool isBeeperOn(void);
|
bool isBeeperOn(void);
|
||||||
|
|
|
@ -182,6 +182,7 @@ void beeperWarningBeeps(uint8_t) {}
|
||||||
void beeperUpdate(timeUs_t) {}
|
void beeperUpdate(timeUs_t) {}
|
||||||
uint32_t getArmingBeepTimeMicros(void) {return 0;}
|
uint32_t getArmingBeepTimeMicros(void) {return 0;}
|
||||||
beeperMode_e beeperModeForTableIndex(int) {return BEEPER_SILENCE;}
|
beeperMode_e beeperModeForTableIndex(int) {return BEEPER_SILENCE;}
|
||||||
|
uint32_t beeperModeMaskForTableIndex(int idx) {UNUSED(idx); return 0;}
|
||||||
const char *beeperNameForTableIndex(int) {return NULL;}
|
const char *beeperNameForTableIndex(int) {return NULL;}
|
||||||
int beeperTableEntryCount(void) {return 0;}
|
int beeperTableEntryCount(void) {return 0;}
|
||||||
bool isBeeperOn(void) {return false;}
|
bool isBeeperOn(void) {return false;}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue