I’m getting some strange behavior after repurposing the WS2812 driver sample with the following code. Note that my code has Bluetooth enabled. It seems like it might be some sort of invalid interrupt activity or something. As the video below shows there are strange random colors popping up in my LED strip (see the blue @ second ~2 in the attached video).
struct led_rgb pixels[NUM_LEDS];
struct led_rgb* led_color_data = get_led_data();
memset(&pixels, 0x00, sizeof(pixels));
while(1)
{
led_color_data = get_led_data();
for (int i = 0; i < NUM_LEDS; i++)
{
led_index = (i + j) % NUM_LEDS;
memcpy(&pixels[led_index], &led_color_data[i], sizeof(struct led_rgb));
}
rc = led_strip_update_rgb(strip, pixels, NUM_LEDS);
k_msleep(200);
}
After using the same code sample without Bluetooth, the bug went away. We're thinking that the Bluetooth stack is causing some sort of strange interrupt activity during the update strip call:
rc = led_strip_update_rgb(strip, pixels, NUM_LEDS);
Does this seem like a reasonable assumption?
If so, is there an easy way to turn off the Bluetooth radio activity before calling the led_strip_update function?
// Turn off bluetooth radio (prevent interrupts?) rc = led_strip_update_rgb(strip, pixels, NUM_LEDS); // Turn bluetooth back on
Working with the author of the WS2812 library @marti.bolivar.nordic over on the Zephyr Slack, the Mulitprotocol Serivce Layer library was suggested as a tool to turn off any background Bluetooth functions. Are we on the right track here?
If so, which API calls should be made to disable the BLE activity? The documentation doesn't seem to offer any clear interface layers.