aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-02-01 13:10:46 +0100
committerLouis Burda <quent.burda@gmail.com>2023-02-01 13:10:46 +0100
commit1f1b153d6f5a25c6929af1562cb9d67b9843007e (patch)
tree1fd108be0a8ad0d0b52366510627879f0595d96b /src
parentff97177aa004c6e564b253aae6aec3aa07cec24c (diff)
downloadsxkbd-1f1b153d6f5a25c6929af1562cb9d67b9843007e.tar.gz
sxkbd-1f1b153d6f5a25c6929af1562cb9d67b9843007e.zip
Move rgb convert into ws2814.c
Diffstat (limited to 'src')
-rw-r--r--src/led.c6
-rw-r--r--src/ws2812.c2
-rw-r--r--src/ws2812.h4
3 files changed, 5 insertions, 7 deletions
diff --git a/src/led.c b/src/led.c
index 83cf786..c8dbc4b 100644
--- a/src/led.c
+++ b/src/led.c
@@ -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;