diff --git a/src/main/config/runtime_config.c b/src/main/config/runtime_config.c index 3c9d8aa2cf..90304c975c 100644 --- a/src/main/config/runtime_config.c +++ b/src/main/config/runtime_config.c @@ -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; } diff --git a/src/main/io/beeper.c b/src/main/io/beeper.c index 4ba29d9584..ac4ace363a 100644 --- a/src/main/io/beeper.c +++ b/src/main/io/beeper.c @@ -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) diff --git a/src/main/io/beeper.h b/src/main/io/beeper.h index 77779d2f74..2ffa1c5016 100644 --- a/src/main/io/beeper.h +++ b/src/main/io/beeper.h @@ -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); diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index 37e952f57d..4568142b2f 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -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); } }