diff options
| -rw-r--r-- | src/led.c | 6 | ||||
| -rw-r--r-- | src/ws2812.c | 2 | ||||
| -rw-r--r-- | src/ws2812.h | 4 |
3 files changed, 5 insertions, 7 deletions
@@ -36,7 +36,7 @@ led_task(void) break; case LED_ON: if (led_reset) - ws2812_put(&onboard_led, WS2812_U32RGB(led_rgb)); + ws2812_put(&onboard_led, led_rgb); break; case LED_BLINK: if (led_reset) @@ -47,7 +47,7 @@ led_task(void) start_ms += led_blink_ms; state = !state; - ws2812_put(&onboard_led, state ? WS2812_U32RGB(led_rgb) : 0); + ws2812_put(&onboard_led, state ? led_rgb : 0); break; } @@ -59,7 +59,7 @@ led_blip(uint32_t rgb) { uint32_t start; - ws2812_put(&onboard_led, WS2812_U32RGB(rgb)); + ws2812_put(&onboard_led, rgb); start = board_millis(); while (board_millis() < start + BLINK_DELAY) tud_task(); diff --git a/src/ws2812.c b/src/ws2812.c index 4140fd6..943cd52 100644 --- a/src/ws2812.c +++ b/src/ws2812.c @@ -39,5 +39,7 @@ ws2812_init(struct ws2812 *pix, PIO pio, uint pin) void ws2812_put(struct ws2812 *pix, uint32_t rgb) { + rgb = ((rgb & 0xFF0000) >> 16) | ((rgb & 0x00FF00) << 8) + | ((rgb & 0x0000FF) << 8); pio_sm_put_blocking(pix->pio, pix->sm, rgb << 8u); } diff --git a/src/ws2812.h b/src/ws2812.h index 8c878ff..95ba4f2 100644 --- a/src/ws2812.h +++ b/src/ws2812.h @@ -5,10 +5,6 @@ #include <stdbool.h> -#define _WS2812_U8(v, si, so) ((((uint32_t) (v) >> si) & 0xFF) << so) -#define WS2812_U32RGB(rgb) (_WS2812_U8(rgb, 16, 0) \ - | _WS2812_U8(rgb, 0, 8) | _WS2812_U8(rgb, 8, 16)) - struct ws2812 { PIO pio; uint sm; |
