From 2cf40859150be7ff00db91906097776ab7006e1a Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Tue, 27 Sep 2016 23:14:52 +0200 Subject: [PATCH] Update to ws2812 driver (internal behavior only) --- extdrv/ws2812.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/extdrv/ws2812.c b/extdrv/ws2812.c index ee67d6d..4c0c300 100644 --- a/extdrv/ws2812.c +++ b/extdrv/ws2812.c @@ -45,7 +45,7 @@ void ws2812_config(const struct pio* gpio) } static uint8_t led_data[NB_LEDS * 3]; -static int16_t max_led = -1; +static uint16_t max_led = 0; static uint32_t nb_bytes = 0; @@ -133,12 +133,7 @@ int ws2812_send_frame(uint16_t nb_leds) return -1; } if (nb_leds == 0) { - if (max_led == -1) { - return 0; - } nb_leds = max_led; - /* All leds set previously will be sent, back to no leds set */ - max_led = -1; } nb_bytes = (nb_leds + 1) * 3; ws2812_bit_sender(); @@ -177,7 +172,7 @@ int ws2812_get_pixel(uint16_t pixel_num, uint8_t* red, uint8_t* green, uint8_t* void ws2812_clear_buffer(void) { memset(led_data, 0, (NB_LEDS * 3)); - max_led = -1; + max_led = 0; } /* Clear the internal data buffer and send it to the Leds, turning them all off */ @@ -186,7 +181,7 @@ void ws2812_clear(void) /* Start at first led and send all leds off */ ws2812_clear_buffer(); ws2812_send_frame(NB_LEDS); - max_led = -1; + max_led = 0; } void ws2812_stop(void) __attribute__ ((alias ("ws2812_clear"))); -- 2.43.0