You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cycle button triggered on boot for some devices #19
but restarting the device plays the wrong animation (Rainbow instead of Gradient). Same happens for the other animations, it's always index + 1 it seems.
In the end, I decided to replace FastLEDHub.enableCycleButton(CYCLE_BTN_PIN); with a custom implementation (using AceButton) that seems to work fine calling FastLEDHub.cycle() when needed. It also gives me ability to implement extra features using long press, double-click etc.
#include<Arduino.h>
#include<AceButton.h>
#include<FastLEDHub.h>
#include"Animations/Color.h"
#include"Animations/Rainbow.h"
#include"Animations/RGBWave.h"
#defineCYCLE_BTN_PIN21
#defineNUM_LEDS13
#defineLIGHTSTRIP_PIN9
#defineLED_TYPEWS2812BCRGB leds[NUM_LEDS];
ace_button::AceButton cycle_btn(CYCLE_BTN_PIN);
classButtonHandler: publicace_button::IEventHandler {
public:voidhandleEvent(ace_button::AceButton* /* button */, uint8_t eventType,
uint8_t buttonState) override {
switch (eventType) {
case ace_button::AceButton::kEventPressed:
FastLEDHub.cycle();
break;
}
}
};
ButtonHandler handleEvent;
voidsetup() {
FastLEDHub.initialize("Nintendo");
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS);
FastLEDHub.registerAnimation(newColor("Color"));
FastLEDHub.registerAnimation(newRainbow("Rainbow"));
FastLEDHub.registerAnimation(newRGBWave("RGB Wave"));
FastLEDHub.registerSlider(newSlider("Saturation", 0, 255, 255, 1, "palette2"));
FastLEDHub.registerColorPicker(newColorPicker("Color", CRGB(255, 0, 0)));
// cycle buttonpinMode(CYCLE_BTN_PIN, INPUT);
ace_button::ButtonConfig* buttonConfig = cycle_btn.getButtonConfig();
buttonConfig->setIEventHandler(&handleEvent);
}
voidloop() {
FastLEDHub.handle();
// Should be called every 4-5ms or faster, for the default debouncing time// of ~20ms.
cycle_btn.check();
}
Hi @thijstriemstra, thank you for raising the issue. Unfortunately, I was unable to reproduce the problem on the ESP8266 (Wemos D1 Mini) or my only ESP32 board, the Wemos Lolin32. The Lolin32 board also shows some pins as high on boot, but this doesn't appear to be causing the problem on my end.
It's possible that the GPIO state on boot needs better handling. Perhaps there's a clue in the AceButton library you mentioned. I'll take a look when I have some time.
Activity
thijstriemstra commentedon Apr 5, 2024
it looks like the currentAnimation isn't (re)stored correctly because currentAnimation is always index + 1 after a reboot, e.g.
thijstriemstra commentedon Apr 5, 2024
Looks like commenting out the cycle button fixes it:
so it seems the button is triggered at startup..?
thijstriemstra commentedon Apr 5, 2024
I'm using an ESP32-C3 (supermini) and looks like GPIO10 (
CYCLE_BTN_PIN) is HIGH at boot: https://www.studiopieters.nl/esp32-c3-pinout/I'll try a different pin.
Update: changing to pin 21 makes no difference
thijstriemstra commentedon Apr 5, 2024
In the end, I decided to replace
FastLEDHub.enableCycleButton(CYCLE_BTN_PIN);with a custom implementation (using AceButton) that seems to work fine callingFastLEDHub.cycle()when needed. It also gives me ability to implement extra features using long press, double-click etc.srwi commentedon Apr 7, 2024
Hi @thijstriemstra, thank you for raising the issue. Unfortunately, I was unable to reproduce the problem on the ESP8266 (Wemos D1 Mini) or my only ESP32 board, the Wemos Lolin32. The Lolin32 board also shows some pins as high on boot, but this doesn't appear to be causing the problem on my end.
It's possible that the GPIO state on boot needs better handling. Perhaps there's a clue in the AceButton library you mentioned. I'll take a look when I have some time.
[-]Incorrect startup animation[/-][+]Cycle button triggered on boot for some devices[/+]Fix cycle button triggered on boot (#19)
srwi commentedon Oct 24, 2026
Fixed in 2.3.0