This snippet bricks my Xiao every time, and I have to set it into bootloader mode to recover it. What’s going on? All it does is call a method on one object through a reference. Even if there’s something wrong with this, it shouldn’t brick the thing.
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#include <WS2812FX.h>
#define LED_COUNT 40
#define LED_PIN 10
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// ------------------- CLASS Minimal Bricker -------------------
class MinimalBricker {
private:
WS2812FX *_lightStrip;
public:
MinimalBricker(WS2812FX lightStrip) {
_lightStrip = &lightStrip;
}
void doService() {
_lightStrip->service();
}
};
// ----------------- END CLASS Minimal Bricker -----------------
MinimalBricker minimalBricker = MinimalBricker(ws2812fx);
void setup() {
ws2812fx.init();
ws2812fx.setBrightness(50);
ws2812fx.start();
}
void loop() {
// ws2812fx.service(); // WORKS JUST FINE
minimalBricker.doService(); // BRICKS DEVICE
}