Added LED_ONCE to led handler

This commit is contained in:
Dirk Jahnke 2018-02-02 14:17:40 +01:00
parent 542ee83c04
commit e03ea33bcd
2 changed files with 11 additions and 1 deletions

View File

@ -43,6 +43,15 @@ static void blink_on_board_led_cb(void *arg) {
// toggle LED each tick
mgos_gpio_toggle(ON_BOARD_LED);
break;
case LED_ONCE:
++numTicksLedHasThisState;
if (numTicksLedHasThisState == 1) {
mgos_gpio_write(ON_BOARD_LED, 0); // on
} else
if (numTicksLedHasThisState > 8) {
set_led_status(LED_OFF);
}
break;
default:
LOG(LL_ERROR, ("Invalid current LED status: %d -- ignored", currentStatus));
break;

View File

@ -10,7 +10,8 @@ enum LEDStatus {
LED_OFF = 0, // permanently off
LED_ON = 1, // permanently on
LED_BLINK_SLOW = 2, // on 0,5x / second (1s on, 1s off)
LED_BLINK_FAST = 3 // on 2x / second (250ms on, 250ms off)
LED_BLINK_FAST = 3, // on 2x / second (250ms on, 250ms off)
LED_ONCE = 4 // on for 2 seconds, then off again
};
extern void set_led_status(enum LEDStatus newStatus);