Files
@ a72d393244e6
Branch filter:
Location: HydroBot/hydrobot-sharedlibs/src/led.c - annotation
a72d393244e6
1.7 KiB
text/plain
Added can buffering and protocol updates
6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 021012fc2f31 021012fc2f31 021012fc2f31 6f05f30b23be 6f05f30b23be 021012fc2f31 6f05f30b23be 021012fc2f31 021012fc2f31 021012fc2f31 6f05f30b23be 6f05f30b23be 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 6f05f30b23be 6f05f30b23be 6f05f30b23be 021012fc2f31 021012fc2f31 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 8b77baddb5ab 8b77baddb5ab 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 6f05f30b23be 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 021012fc2f31 | #include "led.h"
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));
}
void led_blink(led_name_t led, uint16_t period)
{
led_timers[led] = period;
led_thresholds[led] = period/2;
led_cycles[led] = period;
}
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] = period;
led_thresholds[led] = period/2;
}
}
void led_update(led_name_t led)
{
if (led_timers[led] > led_thresholds[led])
{
led_set(led, 1);
led_timers[led]--;
}
else if (led_timers[led] > 0)
{
led_set(led, 0);
led_timers[led]--;
}
else if (led_cycles[led] > 0)
{
led_set(led, 0);
led_timers[led] = led_cycles[led];
}
}
void led_update_all(void)
{
led_update(LED_STATUS);
led_update(LED_CAN);
led_update(LED_ERROR);
}
void led_set(led_name_t led, bool value)
{
gpio_set_led(led, value);
}
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;
}
__weak bool gpio_toggle_led(led_name_t led)
{
return false;
}
__weak bool gpio_set_led_brightness(uint8_t brightness)
{
return false;
}
|