mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
87 lines
1.8 KiB
C
87 lines
1.8 KiB
C
/*
|
|
* This file is part of Cleanflight.
|
|
*
|
|
* Cleanflight is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Cleanflight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "drivers/system.h"
|
|
#include "drivers/light_led.h"
|
|
|
|
#include "statusindicator.h"
|
|
|
|
static uint32_t warningLedTimer = 0;
|
|
|
|
typedef enum {
|
|
WARNING_LED_OFF = 0,
|
|
WARNING_LED_ON,
|
|
WARNING_LED_FLASH
|
|
} warningLedState_e;
|
|
|
|
static warningLedState_e warningLedState = WARNING_LED_OFF;
|
|
|
|
void warningLedResetTimer(void) {
|
|
uint32_t now = millis();
|
|
warningLedTimer = now + 500000;
|
|
}
|
|
|
|
void warningLedEnable(void)
|
|
{
|
|
warningLedState = WARNING_LED_ON;
|
|
}
|
|
|
|
void warningLedDisable(void)
|
|
{
|
|
warningLedState = WARNING_LED_OFF;
|
|
}
|
|
|
|
void warningLedFlash(void)
|
|
{
|
|
warningLedState = WARNING_LED_FLASH;
|
|
}
|
|
|
|
void warningLedRefresh(void)
|
|
{
|
|
switch (warningLedState) {
|
|
case WARNING_LED_OFF:
|
|
LED0_OFF;
|
|
break;
|
|
case WARNING_LED_ON:
|
|
LED0_ON;
|
|
break;
|
|
case WARNING_LED_FLASH:
|
|
LED0_TOGGLE;
|
|
break;
|
|
}
|
|
|
|
timeUs_t now = micros();
|
|
warningLedTimer = now + 500000;
|
|
}
|
|
|
|
void warningLedUpdate(void)
|
|
{
|
|
timeUs_t now = micros();
|
|
|
|
if ((timeDelta_t)(now - warningLedTimer) < 0) {
|
|
return;
|
|
}
|
|
|
|
warningLedRefresh();
|
|
}
|
|
|
|
|