diff --git a/src/led.c b/src/led.c --- a/src/led.c +++ b/src/led.c @@ -1,36 +1,37 @@ #include "led.h" -#define LED_CYCLE_STATUS 2000 -#define LED_CYCLE_CAN 0 -#define LED_CYCLE_ERROR 0 - uint16_t led_timers[3]; uint16_t led_thresholds[3]; uint16_t led_cycles[3]; void led_init(void) { - memset(led_timers, 0, sizeof led_timers); - memset(led_thresholds, 0, sizeof led_thresholds); - memset(led_cycles, 0, sizeof led_cycles); - - led_cycles[LED_STATUS] = LED_CYCLE_STATUS; - led_cycles[LED_CAN] = LED_CYCLE_CAN; - led_cycles[LED_ERROR] = LED_CYCLE_ERROR; + memset(led_timers, 0, sizeof(led_timers)); + memset(led_thresholds, 0, sizeof(led_thresholds)); + memset(led_cycles, 0, sizeof(led_cycles)); } -void led_start(led_name_t led) +void led_blink(led_name_t led, uint16_t period) { - led_timers[led] = led_cycles[led]; - led_thresholds[led] = led_cycles[led]/2; + led_timers[led] = period; + led_thresholds[led] = period/2; + led_cycles[led] = period; } -void led_start_time(led_name_t led, uint16_t time) +void led_stop(led_name_t led) +{ + led_timers[led] = 0; + led_thresholds[led] = 0; + led_cycles[led] = 0; + led_set(led, 0); +} + +void led_blink_once(led_name_t led, uint16_t period) { if (led_timers[led] == 0) { - led_timers[led] = time; - led_thresholds[led] = time/2; + led_timers[led] = period; + led_thresholds[led] = period/2; } } @@ -70,6 +71,11 @@ void led_toggle(led_name_t led) gpio_toggle_led(led); } +bool led_set_brightness(uint8_t brightness) +{ + return gpio_set_led_brightness(brightness); +} + __weak bool gpio_set_led(led_name_t led, bool value) { return false; @@ -80,3 +86,8 @@ void led_toggle(led_name_t led) return false; } +__weak bool gpio_set_led_brightness(uint8_t brightness) +{ + return false; +} +