mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Remove BEEPER_CONFIRM_BEEP. Simplifies logic, reduces code size, and
ensures that the durations of one or more confirmation beeps can never get out of sync when the code is changed. Renamed queueConfirmationBeep to beeperConfirmationBeeps - nothing was actually queued.
This commit is contained in:
parent
064de090a0
commit
3974b02b3a
4 changed files with 25 additions and 30 deletions
|
@ -37,7 +37,7 @@ uint16_t enableFlightMode(flightModeFlags_e mask)
|
|||
|
||||
flightModeFlags |= (mask);
|
||||
if (flightModeFlags != oldVal)
|
||||
queueConfirmationBeep(1);
|
||||
beeperConfirmationBeeps(1);
|
||||
return flightModeFlags;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ uint16_t disableFlightMode(flightModeFlags_e mask)
|
|||
|
||||
flightModeFlags &= ~(mask);
|
||||
if (flightModeFlags != oldVal)
|
||||
queueConfirmationBeep(1);
|
||||
beeperConfirmationBeeps(1);
|
||||
return flightModeFlags;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,7 @@ static const uint8_t beep_lowBatteryBeep[] = {
|
|||
static const uint8_t beep_critBatteryBeep[] = {
|
||||
50, 2, BEEPER_COMMAND_STOP
|
||||
};
|
||||
// single confirmation beep
|
||||
static const uint8_t beep_confirmBeep[] = {
|
||||
2, 20, BEEPER_COMMAND_STOP
|
||||
};
|
||||
|
||||
// transmitter-signal-lost tone
|
||||
static const uint8_t beep_txLostBeep[] = {
|
||||
50, 50, BEEPER_COMMAND_STOP
|
||||
|
@ -112,6 +109,10 @@ static const uint8_t beep_3shortBeeps[] = {
|
|||
// array used for variable # of beeps (reporting GPS sat count, etc)
|
||||
static uint8_t beep_multiBeeps[MAX_MULTI_BEEPS + 2];
|
||||
|
||||
#define BEEPER_CONFIRMATION_BEEP_DURATION 2
|
||||
#define BEEPER_CONFIRMATION_BEEP_GAP_DURATION 20
|
||||
|
||||
|
||||
// Beeper off = 0 Beeper on = 1
|
||||
static uint8_t beeperIsOn = 0;
|
||||
|
||||
|
@ -144,9 +145,8 @@ static const beeperTableEntry_t const beeperTable[] = {
|
|||
{ BEEPER_ACC_CALIBRATION, 10, beep_2shortBeeps },
|
||||
{ BEEPER_ACC_CALIBRATION_FAIL, 11, beep_3shortBeeps },
|
||||
{ BEEPER_READY_BEEP, 12, beep_readyBeep },
|
||||
{ BEEPER_CONFIRM_BEEP, 13, beep_confirmBeep },
|
||||
{ BEEPER_MULTI_BEEPS, 14, beep_multiBeeps }, // FIXME having this listed makes no sense since the beep array will not be initialised.
|
||||
{ BEEPER_ARMED, 15, beep_armedBeep },
|
||||
{ BEEPER_MULTI_BEEPS, 13, beep_multiBeeps }, // FIXME having this listed makes no sense since the beep array will not be initialised.
|
||||
{ BEEPER_ARMED, 14, beep_armedBeep },
|
||||
};
|
||||
|
||||
static const beeperTableEntry_t *currentBeeperEntry = NULL;
|
||||
|
@ -207,25 +207,21 @@ void beeperSilence(void)
|
|||
* Emits the given number of 20ms beeps (with 200ms spacing).
|
||||
* This function returns immediately (does not block).
|
||||
*/
|
||||
void queueConfirmationBeep(uint8_t beepCount)
|
||||
void beeperConfirmationBeeps(uint8_t beepCount)
|
||||
{
|
||||
int i;
|
||||
int cLimit;
|
||||
|
||||
if(beepCount <= 1) //if single beep then
|
||||
beeper(BEEPER_CONFIRM_BEEP); //use dedicated array
|
||||
else {
|
||||
i = 0;
|
||||
cLimit = beepCount * 2;
|
||||
if(cLimit > MAX_MULTI_BEEPS)
|
||||
cLimit = MAX_MULTI_BEEPS; //stay within array size
|
||||
do {
|
||||
beep_multiBeeps[i++] = 2; //20ms beep
|
||||
beep_multiBeeps[i++] = 20; //200ms pause
|
||||
} while (i < cLimit);
|
||||
beep_multiBeeps[i] = BEEPER_COMMAND_STOP; //sequence end
|
||||
beeper(BEEPER_MULTI_BEEPS); //initiate sequence
|
||||
}
|
||||
i = 0;
|
||||
cLimit = beepCount * 2;
|
||||
if(cLimit > MAX_MULTI_BEEPS)
|
||||
cLimit = MAX_MULTI_BEEPS; //stay within array size
|
||||
do {
|
||||
beep_multiBeeps[i++] = BEEPER_CONFIRMATION_BEEP_DURATION; // 20ms beep
|
||||
beep_multiBeeps[i++] = BEEPER_CONFIRMATION_BEEP_GAP_DURATION; // 200ms pause
|
||||
} while (i < cLimit);
|
||||
beep_multiBeeps[i] = BEEPER_COMMAND_STOP; //sequence end
|
||||
beeper(BEEPER_MULTI_BEEPS); //initiate sequence
|
||||
}
|
||||
|
||||
void beeperGpsStatus(void)
|
||||
|
|
|
@ -34,13 +34,12 @@ typedef enum {
|
|||
BEEPER_ACC_CALIBRATION, // ACC inflight calibration completed confirmation
|
||||
BEEPER_ACC_CALIBRATION_FAIL, // ACC inflight calibration failed
|
||||
BEEPER_READY_BEEP, // Ring a tone when board is ready to flight (GPS ready).
|
||||
BEEPER_CONFIRM_BEEP, // Single short confirmation beep.
|
||||
BEEPER_MULTI_BEEPS, // Internal value used by 'queueConfirmationBeep()'.
|
||||
BEEPER_MULTI_BEEPS, // Internal value used by 'beeperConfirmationBeeps()'.
|
||||
BEEPER_ARMED, // Warning beeps when board is armed. (repeats until board is disarmed or throttle is increased)
|
||||
} beeperMode_e;
|
||||
|
||||
void beeper(beeperMode_e mode);
|
||||
void beeperSilence(void);
|
||||
void beeperUpdate(void);
|
||||
void queueConfirmationBeep(uint8_t beepCount);
|
||||
void beeperConfirmationBeeps(uint8_t beepCount);
|
||||
uint32_t getArmingBeepTimeMicros(void);
|
||||
|
|
|
@ -397,9 +397,9 @@ void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustm
|
|||
float newFloatValue;
|
||||
|
||||
if (delta > 0) {
|
||||
queueConfirmationBeep(2);
|
||||
beeperConfirmationBeeps(2);
|
||||
} else {
|
||||
queueConfirmationBeep(1);
|
||||
beeperConfirmationBeeps(1);
|
||||
}
|
||||
switch(adjustmentFunction) {
|
||||
case ADJUSTMENT_RC_RATE:
|
||||
|
@ -520,7 +520,7 @@ void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
|
|||
}
|
||||
|
||||
if (applied) {
|
||||
queueConfirmationBeep(position + 1);
|
||||
beeperConfirmationBeeps(position + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue