From 21439b86740af34230d39de10834b61e22628527 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Tue, 7 Feb 2023 02:03:46 +0100 Subject: [PATCH] Update lighthouse app according to new WS2812 driver interface --- lighthouse/main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lighthouse/main.c b/lighthouse/main.c index a67456b..dc1c6ad 100644 --- a/lighthouse/main.c +++ b/lighthouse/main.c @@ -89,6 +89,14 @@ const struct pio status_led_red = LPC_GPIO_1_2; #define ADC_EXT1 LPC_ADC(1) #define ADC_EXT2 LPC_ADC(2) +#define WS2812_NB_LEDS 12 +uint8_t ws2812_leds_data[WS2812_NB_LEDS * 3]; +struct ws2812_conf ws2812_leds = { + .nb_leds = WS2812_NB_LEDS, + .led_data = ws2812_leds_data, + .inverted = 0, +}; + /***************************************************************************** */ void system_init() { @@ -214,12 +222,12 @@ void handle_rf_rx_data(void) uprintf(UART0, "Color(%d) : %d,%d,%d.\n", led, data[2], data[3], data[4]); #endif - ws2812_set_pixel(led++, data[2], data[3], data[4]); - if (led > 4) { + ws2812_set_pixel(&ws2812_leds, led++, data[2], data[3], data[4]); + if (led > WS2812_NB_LEDS) { led = 0; } msleep(5); - ws2812_send_frame(0); + ws2812_send_frame(&ws2812_leds, 0); } @@ -279,8 +287,8 @@ int main(void) rf_config(); /* Led strip configuration */ - ws2812_config(&ws2812_data_out_pin); - ws2812_clear(); + ws2812_config(&ws2812_leds, &ws2812_data_out_pin); + ws2812_clear(&ws2812_leds); /* RTC */ set_rtc_callback(&rtc_toggle_led, 0, 2); -- 2.43.0