From 962196ef1d0036b749da374ec5c5c79e989a256f Mon Sep 17 00:00:00 2001 From: Zaltora Date: Sat, 2 Dec 2017 10:37:52 +0100 Subject: [PATCH] color and timing (ws2812_i2s) (#493) --- examples/ws2812_i2s/ws2812_i2s_colour_loop.c | 2 +- extras/ws2812_i2s/ws2812_i2s.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/ws2812_i2s/ws2812_i2s_colour_loop.c b/examples/ws2812_i2s/ws2812_i2s_colour_loop.c index c5b5411..b28f83b 100644 --- a/examples/ws2812_i2s/ws2812_i2s_colour_loop.c +++ b/examples/ws2812_i2s/ws2812_i2s_colour_loop.c @@ -41,7 +41,7 @@ static int fix_index(int index) static ws2812_pixel_t next_colour() { - ws2812_pixel_t colour = {0, 0, 0, 0}; + ws2812_pixel_t colour = { {0, 0, 0, 0} }; colour.red = rand() % 256; colour.green = rand() % 256; colour.blue = rand() % 256; diff --git a/extras/ws2812_i2s/ws2812_i2s.h b/extras/ws2812_i2s/ws2812_i2s.h index 16956dc..ffb2701 100644 --- a/extras/ws2812_i2s/ws2812_i2s.h +++ b/extras/ws2812_i2s/ws2812_i2s.h @@ -31,11 +31,14 @@ extern "C" { #endif -typedef struct { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t white; +typedef union { + struct { + uint8_t blue; //LSB + uint8_t green; + uint8_t red; + uint8_t white; + }; + uint32_t color; // 0xWWRRGGBB } ws2812_pixel_t; typedef enum {