add buffer message

This commit is contained in:
King Kévin 2015-07-17 10:07:49 +02:00
parent cdd432302e
commit da57a9d18c
1 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@
#include "ws2812b.h" // to control WS2812B LEDs
/* global variables */
volatile uint8_t uart_in[19]; // input from USART, enough space for one atmolight message
volatile uint8_t uart_in[19*2]; // input from USART, enough space for two atmolight messages (one as buffer)
volatile uint8_t uart_in_i = 0; // UART input index
/* flags, set in the interrupts and handled in the main program */
@ -140,9 +140,14 @@ int main(void)
ws2812b_set_led_color(4,led,uart_in[16],uart_in[17],uart_in[18]);
}
}
if (uart_in_i>=sizeof(uart_in)) { // end of message
uart_in_i = 0; // start with next message
if (uart_in_i>=19) { // end of message
ws2812b_show(); // show the new colors
if (uart_in_i>19) { // move buffered message
for (uint8_t i=19; i<uart_in_i; i++) {
uart_in[i-19] = uart_in[i];
}
}
uart_in_i -= 19; // start with next message
}
}
}