-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cycle button triggered on boot for some devices #19
Comments
it looks like the currentAnimation isn't (re)stored correctly because currentAnimation is always index + 1 after a reboot, e.g.
|
Looks like commenting out the cycle button fixes it: // cycle button
// FastLEDHub.enableCycleButton(CYCLE_BTN_PIN); so it seems the button is triggered at startup..? |
I'm using an ESP32-C3 (supermini) and looks like GPIO10 ( I'll try a different pin. Update: changing to pin 21 makes no difference |
In the end, I decided to replace #include <Arduino.h>
#include <AceButton.h>
#include <FastLEDHub.h>
#include "Animations/Color.h"
#include "Animations/Rainbow.h"
#include "Animations/RGBWave.h"
#define CYCLE_BTN_PIN 21
#define NUM_LEDS 13
#define LIGHTSTRIP_PIN 9
#define LED_TYPE WS2812B
CRGB leds[NUM_LEDS];
ace_button::AceButton cycle_btn(CYCLE_BTN_PIN);
class ButtonHandler: public ace_button::IEventHandler {
public:
void handleEvent(ace_button::AceButton* /* button */, uint8_t eventType,
uint8_t buttonState) override {
switch (eventType) {
case ace_button::AceButton::kEventPressed:
FastLEDHub.cycle();
break;
}
}
};
ButtonHandler handleEvent;
void setup() {
FastLEDHub.initialize("Nintendo");
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS);
FastLEDHub.registerAnimation(new Color("Color"));
FastLEDHub.registerAnimation(new Rainbow("Rainbow"));
FastLEDHub.registerAnimation(new RGBWave("RGB Wave"));
FastLEDHub.registerSlider(new Slider("Saturation", 0, 255, 255, 1, "palette2"));
FastLEDHub.registerColorPicker(new ColorPicker("Color", CRGB(255, 0, 0)));
// cycle button
pinMode(CYCLE_BTN_PIN, INPUT);
ace_button::ButtonConfig* buttonConfig = cycle_btn.getButtonConfig();
buttonConfig->setIEventHandler(&handleEvent);
}
void loop() {
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. |
Program:
I have the following config:
And these animations:
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.
The text was updated successfully, but these errors were encountered: