I am creating a usermod with the v2 API, but I can’t seem to control the LED strip.
My setup is
- Platform IO, created a usermod in the usermod directory and included it in usermods_list.cpp
- Compiling and uploading against a NodeMCU v0.9 connected to an GRBW Neopixel Strip
- My usermod is a copy of EXAMPLE_v2
All normal functionality works, the strip can be configured and controlled by the User Interface over WIFI. My usermod loads, I see the output of my Serial.println() statements.
My first step is of course creating a “blink”, that should be the lowest bar for a usermod I copied the tried this in the loop of my usermod:
private:
// ...
unsigned long lastTime = 0;
bool on = false;
byte lastBri = 0;
public:
// ...
void loop() {
if (millis() - lastTime > 1000) {
lastTime = millis();
Serial.print("Hello from my usermod. bri=");
Serial.println(bri,DEC);
if (on) {
// switch off
lastBri = strip.getBrightness();
strip.setBrightness(0);
} else {
// switch on
strip.setBrightness(lastBri);
}
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
// strip.setBrightness();
on != on;
}
}
I’ve seen a lot of “interesting” code and I tried several things, even writing bri
directly, and calling strip.show()
. What did I miss, or what is the correct way of controlling the LED strip from a usermod?