mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "drivers/system.h"
|
|
#include "drivers/gpio.h"
|
|
#include "drivers/light_led.h"
|
|
#include "drivers/sound_beeper.h"
|
|
|
|
#include "statusindicator.h"
|
|
|
|
void blinkLedAndSoundBeeper(uint8_t num, uint8_t wait, uint8_t repeat)
|
|
{
|
|
uint8_t i, r;
|
|
|
|
for (r = 0; r < repeat; r++) {
|
|
for (i = 0; i < num; i++) {
|
|
LED0_TOGGLE; // switch LEDPIN state
|
|
BEEP_ON;
|
|
delay(wait);
|
|
BEEP_OFF;
|
|
}
|
|
delay(60);
|
|
}
|
|
}
|
|
|
|
|
|
static uint32_t warningLedTimer = 0;
|
|
|
|
void enableWarningLed(uint32_t currentTime)
|
|
{
|
|
if (warningLedTimer != 0) {
|
|
return; // already enabled
|
|
}
|
|
warningLedTimer = currentTime + 500000;
|
|
LED0_ON;
|
|
}
|
|
|
|
void disableWarningLed(void)
|
|
{
|
|
warningLedTimer = 0;
|
|
LED0_OFF;
|
|
}
|
|
|
|
void updateWarningLed(uint32_t currentTime)
|
|
{
|
|
if (warningLedTimer && (int32_t)(currentTime - warningLedTimer) >= 0) {
|
|
LED0_TOGGLE;
|
|
warningLedTimer = warningLedTimer + 500000;
|
|
}
|
|
}
|
|
|