Add button type: Touch (switch) #3537

This commit is contained in:
Blaz Kristan 2023-11-22 15:35:11 +01:00
parent b5a8f3156c
commit 6a793536dd
4 changed files with 553 additions and 549 deletions

View File

@ -97,6 +97,7 @@ bool isButtonPressed(uint8_t i)
if (digitalRead(pin) == HIGH) return true;
break;
case BTN_TYPE_TOUCH:
case BTN_TYPE_TOUCH_SWITCH:
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3)
if (touchRead(pin) <= touchThreshold) return true;
#endif
@ -252,7 +253,7 @@ void handleButton()
}
// 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) {
if (buttonType[b] == BTN_TYPE_SWITCH || buttonType[b] == BTN_TYPE_TOUCH_SWITCH || buttonType[b] == BTN_TYPE_PIR_SENSOR) {
handleSwitch(b);
continue;
}

View File

@ -285,6 +285,7 @@
#define BTN_TYPE_TOUCH 6
#define BTN_TYPE_ANALOG 7
#define BTN_TYPE_ANALOG_INVERTED 8
#define BTN_TYPE_TOUCH_SWITCH 9
//Ethernet board types
#define WLED_NUM_ETH_TYPES 11

View File

@ -512,6 +512,7 @@ Length: <input type="number" name="XC${i}" id="xc${i}" class="l" min="1" max="65
c += `<option value="6" ${t==6?"selected":""}>Touch</option>`;
c += `<option value="7" ${t==7?"selected":""}>Analog</option>`;
c += `<option value="8" ${t==8?"selected":""}>Analog inverted</option>`;
c += `<option value="9" ${t==9?"selected":""}>Touch (switch)</option>`;
c += `</select>`;
c += `<span style="cursor: pointer;" onclick="off('${bt}')">&nbsp;&#x2715;</span><br>`;
gId("btns").innerHTML = c;

File diff suppressed because it is too large Load Diff