Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ void handleButton()
{
static unsigned long lastRead = 0UL;
static unsigned long lastRun = 0UL;
bool analog = false;
unsigned long now = millis();

//if (strip.isUpdating()) return; // don't interfere with strip updates. Our button will still be there in 1ms (next cycle)
Expand All @@ -241,14 +240,18 @@ void handleButton()

if (usermods.handleButton(b)) continue; // did usermod handle buttons

if ((buttonType[b] == BTN_TYPE_ANALOG || buttonType[b] == BTN_TYPE_ANALOG_INVERTED) && now - lastRead > ANALOG_BTN_READ_CYCLE) { // button is not a button but a potentiometer
analog = true;
handleAnalog(b); continue;
if (buttonType[b] == BTN_TYPE_ANALOG || buttonType[b] == BTN_TYPE_ANALOG_INVERTED) { // button is not a button but a potentiometer
if (now - lastRead > ANALOG_BTN_READ_CYCLE) {
handleAnalog(b);
lastRead = now;
}
continue;
}

//button is not momentary, but switch. This is only suitable on pins whose on-boot state does not matter (NOT gpio0)
if (buttonType[b] == BTN_TYPE_SWITCH || buttonType[b] == BTN_TYPE_PIR_SENSOR) {
handleSwitch(b); continue;
handleSwitch(b);
continue;
}

//momentary button logic
Expand Down Expand Up @@ -305,7 +308,6 @@ void handleButton()
shortPressAction(b);
}
}
if (analog) lastRead = now;
}

// If enabled, RMT idle level is set to HIGH when off
Expand Down