From 000a6f301069e9172b3a5c10cbc0966532c47d53 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 19 Nov 2020 19:43:11 +0100 Subject: [PATCH] Update test app due to driver interface update. --- ledstrip/main.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ledstrip/main.c b/ledstrip/main.c index e9d3fae..286b61f 100644 --- a/ledstrip/main.c +++ b/ledstrip/main.c @@ -72,6 +72,14 @@ const struct pio status_led_red = LPC_GPIO_1_5; const struct pio button = LPC_GPIO_0_12; /* ISP button */ const struct pio ws2812_data_out_pin = LPC_GPIO_0_19; /* Led control data pin */ +#define NB_LEDS 6 + +uint8_t ws2812_leds_data[NB_LEDS * 3]; +struct ws2812_conf led_strip = { + .nb_leds = NB_LEDS, + .led_data = ws2812_leds_data, + .inverted = 0, +}; /***************************************************************************** */ void system_init() @@ -135,14 +143,14 @@ void mode_adc_colors(void) adc_get_value(&green, LPC_ADC(1)); adc_get_value(&blue, LPC_ADC(2)); /* Set one pixel */ - ws2812_set_pixel(pixel++, ((red >> 2) & 0xFF), ((green >> 2) & 0xFF), ((blue >> 2) & 0xFF)); + ws2812_set_pixel(&led_strip, pixel++, ((red >> 2) & 0xFF), ((green >> 2) & 0xFF), ((blue >> 2) & 0xFF)); /* Give some time for the ADC value to change (potentiometers should be connected to ADC inputs) */ msleep(150); /* give some feedback that something is going on */ status_led(green_toggle); /* Buffer full, send it ! */ if (pixel >= NB_LEDS) { - ws2812_send_frame(0); + ws2812_send_frame(&led_strip, 0); pixel = 0; } } @@ -185,9 +193,9 @@ void mode_noise(void) } uprintf(UART0, "Loudness: %d - 0x%02x, r: %d, g:%d, b:%d, z:%d\n", loudness, loudness, red, green, blue, zoom); for (i = 0; i < NB_LEDS; i++) { - ws2812_set_pixel(i, red, green, blue); + ws2812_set_pixel(&led_strip, i, red, green, blue); } - ws2812_send_frame(0); + ws2812_send_frame(&led_strip, 0); msleep(500); /* FIXME : Set to 100 and remove uprintf */ } @@ -208,7 +216,7 @@ int main(void) adc_start_burst_conversion(ADC_MCH(0) | ADC_MCH(1) | ADC_MCH(2) | ADC_MCH(3), LPC_ADC_SEQ(0)); /* Led strip configuration */ - ws2812_config(&ws2812_data_out_pin); + ws2812_config(&led_strip, &ws2812_data_out_pin); while (1) { switch (new_mode) { @@ -219,7 +227,7 @@ int main(void) mode_noise(); break; default: - ws2812_stop(); + ws2812_stop(&led_strip); msleep(1500); new_mode = 0; } -- 2.43.0