Logging of the S -term values in blackbox for Fixed wings. (#14012)
[betaflight.git] / src / main / io / statusindicator.c
blob137535c4449765c6b4d221865acb8e6f1e7a8cc9
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
26 #include "drivers/light_led.h"
27 #include "drivers/time.h"
29 #include "statusindicator.h"
31 static uint32_t warningLedTimer = 0;
33 typedef enum {
34 WARNING_LED_OFF = 0,
35 WARNING_LED_ON,
36 WARNING_LED_FLASH
37 } warningLedState_e;
39 static warningLedState_e warningLedState = WARNING_LED_OFF;
41 void warningLedResetTimer(void)
43 uint32_t now = millis();
44 warningLedTimer = now + 500000;
47 void warningLedEnable(void)
49 warningLedState = WARNING_LED_ON;
52 void warningLedDisable(void)
54 warningLedState = WARNING_LED_OFF;
57 void warningLedFlash(void)
59 warningLedState = WARNING_LED_FLASH;
62 void warningLedRefresh(void)
64 switch (warningLedState) {
65 case WARNING_LED_OFF:
66 LED0_OFF;
67 break;
68 case WARNING_LED_ON:
69 LED0_ON;
70 break;
71 case WARNING_LED_FLASH:
72 LED0_TOGGLE;
73 break;
76 uint32_t now = micros();
77 warningLedTimer = now + 500000;
80 void warningLedUpdate(void)
82 uint32_t now = micros();
84 if ((int32_t)(now - warningLedTimer) < 0) {
85 return;
88 warningLedRefresh();