diff options
Diffstat (limited to 'src/ws2812b.c')
-rw-r--r-- | src/ws2812b.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/ws2812b.c b/src/ws2812b.c index 8547b5d..3721b23 100644 --- a/src/ws2812b.c +++ b/src/ws2812b.c @@ -3,6 +3,7 @@ #include <string.h> #include "spi.h" +#include "sysled.h" // either 0b110 when (n) is true, otherwise 0b100 #define BIT_TO_SPI_DATA(v, n) ((BIT_N(v, n)) ? 6 : 4) @@ -32,20 +33,24 @@ inline static void complie_color_inline( rgb_t color, struct rgb_compiled* out, enum ws2812b_byte_order byte_order) { if (byte_order == BYTE_ORDER_GBR) { - uint8_t tmp = color.b; - color.b = color.g; + uint8_t tmp = color.r; + color.r = color.g; color.g = tmp; } + color.r = color.r; + color.g = color.g; + color.b = color.b; + out->first_bits = - BYTE_1(COLOR_BYTE_1(color.b)) | BYTE_2(COLOR_BYTE_2(color.b)) | - BYTE_3(COLOR_BYTE_3(color.b)) | BYTE_4(COLOR_BYTE_1(color.g)); + BYTE_1(COLOR_BYTE_1(color.r)) | BYTE_2(COLOR_BYTE_2(color.r)) | + BYTE_3(COLOR_BYTE_3(color.r)) | BYTE_4(COLOR_BYTE_1(color.g)); out->second_bits = BYTE_1(COLOR_BYTE_2(color.g)) | BYTE_2(COLOR_BYTE_3(color.g)) | - BYTE_3(COLOR_BYTE_1(color.r)) | BYTE_4(COLOR_BYTE_2(color.r)); + BYTE_3(COLOR_BYTE_1(color.b)) | BYTE_4(COLOR_BYTE_2(color.b)); - out->last_bits = COLOR_BYTE_3(color.r); + out->last_bits = COLOR_BYTE_3(color.b); } void compile_color( @@ -74,8 +79,10 @@ int write_rgb(struct ws2812b_buf* out, rgb_t color) while ((dma_loc - CLIP_TO_DMA_BITS(out->buf + out->cur) < TOTAL_BYTES_PER_LED) && (dma_loc < dma_end)) { + set_sysled(1); // Little indication to tell if we are waiting for the DMA. dma_loc = *dma_now; } + set_sysled(0); } memcpy(out->buf + out->cur, comp.buf, WIRE_BYTES_PER_COLOR); |