diff --git a/wled00/button.cpp b/wled00/button.cpp index 1b949feb..26218c15 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -20,11 +20,26 @@ void shortPressAction(uint8_t b) bool isButtonPressed(uint8_t i) { if (btnPin[i]<0) return false; - //TODO: this may need switch statement (for inverted buttons) - #ifdef ARDUINO_ARCH_ESP32 - if (buttonType[i]==BTN_TYPE_TOUCH && touchRead(btnPin[i]) <= touchThreshold) return true; else - #endif - if (digitalRead(btnPin[i]) == LOW) return true; + switch (buttonType[i]) { + case BTN_TYPE_NONE: + case BTN_TYPE_RESERVED: + break; + case BTN_TYPE_PUSH: + case BTN_TYPE_SWITCH: + if (digitalRead(btnPin[i]) == LOW) return true; + break; + case BTN_TYPE_PUSH_ACT_HIGH: + case BTN_TYPE_SWITCH_ACT_HIGH: + if (digitalRead(btnPin[i]) == HIGH) return true; + break; + case BTN_TYPE_TOUCH: + #ifdef ARDUINO_ARCH_ESP32 + if (touchRead(btnPin[i]) <= touchThreshold) return true; + DEBUG_PRINT(F("Touch value: ")); + DEBUG_PRINTLN(touchRead(btnPin[i])); + #endif + break; + } return false; } diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 437918ff..5db70490 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -161,9 +161,18 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { macroDoublePress[s] = 0; } } else { - //TODO: fix JSON API call (and new install) + // new install/missing configuration (button 0 has defaults) + if (fromFS) + for (uint8_t s=1; s c += ``; c += ` ×
`; diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index a2426c99..0515de1f 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -172,10 +172,10 @@ - + - + diff --git a/wled00/html_settings.h b/wled00/html_settings.h index b07d34d4..ce8f05ac 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -74,7 +74,7 @@ Do not enable if WiFi is working correctly, increases power consumption.
LED Settings
push
switch
short
on->off
long
off->on
doubledouble
N/A