Hi,
I've noticed, that in this configuration (ITEAD_SONOFF_BASIC):
#define BUTTON1_PIN 0
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON2_PIN 14
#define BUTTON2_MODE BUTTON_SWITCH | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH
#define BUTTON2_RELAY 1
if BUTTON2 is closed (BUTTON2_PIN is LOW) and Espurna reboots, then RELAY1 always turns on (even if the state before reset was off).
I have the same issue with BUTTON_MODE = BUTTON_SWITCH.
I think the button state should be read during setup and should not fire a Click event?
Edit:
fixed it. Only a small change in the Debonce Library:
DebounceEvent.cpp (_init Method):
void DebounceEvent::_init(uint8_t pin, uint8_t mode, unsigned long delay, unsigned long repeat) {
// store configuration
_pin = pin;
_mode = mode & 0x01;
_defaultStatus = (mode & BUTTON_DEFAULT_HIGH) > 0;
_delay = delay;
_repeat = repeat;
// init button state
_status = ((mode & BUTTON_SWITCH) > 0) ? digitalRead(_pin) : _defaultStatus;
I've no BitBucket, so somone else could do a PR there?
PS: Boot mode (Always on and Always off) is working with toggle switches too, after this change!
Most helpful comment
I have the same issue with BUTTON_MODE = BUTTON_SWITCH.
I think the button state should be read during setup and should not fire a Click event?
Edit:
fixed it. Only a small change in the Debonce Library:
DebounceEvent.cpp (_init Method):
I've no BitBucket, so somone else could do a PR there?
PS: Boot mode (Always on and Always off) is working with toggle switches too, after this change!