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()
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;
}
}
}
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 */
}
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) {
mode_noise();
break;
default:
- ws2812_stop();
+ ws2812_stop(&led_strip);
msleep(1500);
new_mode = 0;
}