mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Improved arming disabled reason beeps.
This commit is contained in:
parent
9df87ea4ba
commit
655c5fabc9
3 changed files with 49 additions and 22 deletions
|
@ -20,12 +20,13 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#include "light_led.h"
|
||||
#include "sound_beeper.h"
|
||||
#include "drivers/nvic.h"
|
||||
#include "build/atomic.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/light_led.h"
|
||||
#include "drivers/nvic.h"
|
||||
#include "drivers/sound_beeper.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
// cycles per microsecond
|
||||
static uint32_t usTicks = 0;
|
||||
|
@ -160,10 +161,6 @@ void delay(uint32_t ms)
|
|||
delayMicroseconds(1000);
|
||||
}
|
||||
|
||||
#define SHORT_FLASH_DURATION 50
|
||||
#define SHORT_FLASH_COUNT 5
|
||||
#define CODE_FLASH_DURATION 250
|
||||
|
||||
static void indicate(uint8_t count, uint16_t duration)
|
||||
{
|
||||
if (count) {
|
||||
|
@ -187,11 +184,11 @@ static void indicate(uint8_t count, uint16_t duration)
|
|||
void indicateFailure(failureMode_e mode, int codeRepeatsRemaining)
|
||||
{
|
||||
while (codeRepeatsRemaining--) {
|
||||
indicate(SHORT_FLASH_COUNT, SHORT_FLASH_DURATION);
|
||||
indicate(WARNING_FLASH_COUNT, WARNING_FLASH_DURATION_MS);
|
||||
|
||||
delay(500);
|
||||
delay(WARNING_PAUSE_DURATION_MS);
|
||||
|
||||
indicate(mode + 1, CODE_FLASH_DURATION);
|
||||
indicate(mode + 1, WARNING_CODE_DURATION_LONG_MS);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@ typedef enum {
|
|||
FAILURE_GYRO_INIT_FAILED
|
||||
} failureMode_e;
|
||||
|
||||
#define WARNING_FLASH_DURATION_MS 50
|
||||
#define WARNING_FLASH_COUNT 5
|
||||
#define WARNING_PAUSE_DURATION_MS 500
|
||||
#define WARNING_CODE_DURATION_LONG_MS 250
|
||||
#define WARNING_CODE_DURATION_SHORT_MS 50
|
||||
|
||||
// failure
|
||||
void indicateFailure(failureMode_e mode, int repeatCount);
|
||||
void failureMode(failureMode_e mode);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "drivers/io.h"
|
||||
#include "drivers/pwm_output.h"
|
||||
#include "drivers/sound_beeper.h"
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/time.h"
|
||||
|
||||
#include "flight/mixer.h"
|
||||
|
@ -34,7 +35,6 @@
|
|||
#include "fc/config.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/statusindicator.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
|
@ -47,6 +47,8 @@
|
|||
#include "sensors/battery.h"
|
||||
#include "sensors/sensors.h"
|
||||
|
||||
#include "beeper.h"
|
||||
|
||||
#ifdef BEEPER_INVERTED
|
||||
#define IS_OPEN_DRAIN false
|
||||
#define IS_INVERTED true
|
||||
|
@ -157,6 +159,8 @@ static uint8_t beep_multiBeeps[MAX_MULTI_BEEPS + 1];
|
|||
#define BEEPER_CONFIRMATION_BEEP_DURATION 2
|
||||
#define BEEPER_CONFIRMATION_BEEP_GAP_DURATION 20
|
||||
|
||||
#define BEEPER_WARNING_LONG_BEEP_MULTIPLIER 5
|
||||
|
||||
#define BEEPER_WARNING_BEEP_1_DURATION 20
|
||||
#define BEEPER_WARNING_BEEP_2_DURATION 5
|
||||
#define BEEPER_WARNING_BEEP_GAP_DURATION 10
|
||||
|
@ -301,17 +305,37 @@ void beeperConfirmationBeeps(uint8_t beepCount)
|
|||
|
||||
void beeperWarningBeeps(uint8_t beepCount)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t cLimit = beepCount * 4;
|
||||
if (cLimit >= MAX_MULTI_BEEPS) {
|
||||
cLimit = MAX_MULTI_BEEPS;
|
||||
uint8_t longBeepCount = beepCount / BEEPER_WARNING_LONG_BEEP_MULTIPLIER;
|
||||
uint8_t shortBeepCount = beepCount % BEEPER_WARNING_LONG_BEEP_MULTIPLIER;
|
||||
|
||||
unsigned i = 0;
|
||||
|
||||
unsigned count = 0;
|
||||
while (i < MAX_MULTI_BEEPS - 1 && count < WARNING_FLASH_COUNT) {
|
||||
beep_multiBeeps[i++] = WARNING_FLASH_DURATION_MS / 10;
|
||||
if (++count < WARNING_FLASH_COUNT) {
|
||||
beep_multiBeeps[i++] = WARNING_FLASH_DURATION_MS / 10;
|
||||
} else {
|
||||
beep_multiBeeps[i++] = WARNING_PAUSE_DURATION_MS / 10;
|
||||
}
|
||||
do {
|
||||
beep_multiBeeps[i++] = BEEPER_WARNING_BEEP_1_DURATION;
|
||||
beep_multiBeeps[i++] = BEEPER_WARNING_BEEP_GAP_DURATION;
|
||||
beep_multiBeeps[i++] = BEEPER_WARNING_BEEP_2_DURATION;
|
||||
beep_multiBeeps[i++] = BEEPER_WARNING_BEEP_GAP_DURATION;
|
||||
} while (i < cLimit);
|
||||
}
|
||||
|
||||
while (i < MAX_MULTI_BEEPS - 1 && longBeepCount > 0) {
|
||||
beep_multiBeeps[i++] = WARNING_CODE_DURATION_LONG_MS / 10;
|
||||
if (--longBeepCount > 0) {
|
||||
beep_multiBeeps[i++] = WARNING_CODE_DURATION_LONG_MS / 10;
|
||||
} else {
|
||||
beep_multiBeeps[i++] = WARNING_PAUSE_DURATION_MS / 10;
|
||||
}
|
||||
}
|
||||
|
||||
while (i < MAX_MULTI_BEEPS - 1 && shortBeepCount > 0) {
|
||||
beep_multiBeeps[i++] = WARNING_CODE_DURATION_SHORT_MS / 10;
|
||||
if (--shortBeepCount > 0) {
|
||||
beep_multiBeeps[i++] = WARNING_CODE_DURATION_LONG_MS / 10;
|
||||
}
|
||||
}
|
||||
|
||||
beep_multiBeeps[i] = BEEPER_COMMAND_STOP;
|
||||
|
||||
beeper(BEEPER_MULTI_BEEPS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue