File tree Expand file tree Collapse file tree 6 files changed +29
-6
lines changed
Expand file tree Collapse file tree 6 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,14 @@ lib_ignore =
334334 ESPAsyncTCP
335335 ESPAsyncUDP
336336
337+ [env:custom32_TOUCHPIN_T0]
338+ board = esp32dev
339+ platform = espressif32@1.12.4
340+ build_flags = ${common.build_flags_esp32} -D TOUCHPIN =T0
341+ lib_ignore =
342+ ESPAsyncTCP
343+ ESPAsyncUDP
344+
337345[env:wemos_shield_esp32]
338346board = esp32dev
339347platform = espressif32@1.12.4
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ build_flags = ${common.build_flags_esp8266}
2121; PIN defines - uncomment and change, if needed:
2222; -D LEDPIN=2
2323; -D BTNPIN=0
24+ ; -D TOUCHPIN=T0
2425; -D IR_PIN=4
2526; -D RLYPIN=12
2627; -D RLYMDE=1
Original file line number Diff line number Diff line change @@ -15,13 +15,24 @@ void shortPressAction()
1515 }
1616}
1717
18+ bool isButtonPressed ()
19+ {
20+ #ifdef BTNPIN
21+ if (digitalRead (BTNPIN) == LOW) return true ;
22+ #endif
23+ #ifdef TOUCHPIN
24+ if (touchRead (TOUCHPIN) <= TOUCH_THRESHOLD) return true ;
25+ #endif
26+ return false ;
27+ }
28+
1829
1930void handleButton ()
2031{
21- #ifdef BTNPIN
32+ #if defined( BTNPIN) || defined(TOUCHPIN)
2233 if (!buttonEnabled) return ;
23-
24- if (digitalRead (BTNPIN) == LOW ) // pressed
34+
35+ if (isButtonPressed () ) // pressed
2536 {
2637 if (!buttonPressedBefore) buttonPressedTime = millis ();
2738 buttonPressedBefore = true ;
@@ -37,7 +48,7 @@ void handleButton()
3748 }
3849 }
3950 }
40- else if (digitalRead (BTNPIN) == HIGH && buttonPressedBefore) // released
51+ else if (! isButtonPressed () && buttonPressedBefore) // released
4152 {
4253 long dur = millis () - buttonPressedTime;
4354 if (dur < 50 ) {buttonPressedBefore = false ; return ;} // too short "press", debounce
Original file line number Diff line number Diff line change 126126
127127#define ABL_MILLIAMPS_DEFAULT 850; // auto lower brightness to stay close to milliampere limit
128128
129+ #define TOUCH_THRESHOLD 32 // limit to recognize a touch, higher value means more sensitive
130+
129131// Size of buffer for API JSON object (increase for more segments)
130132#ifdef ESP8266
131133 #define JSON_BUFFER_SIZE 9216
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ void updateBlynk();
2121
2222// button.cpp
2323void shortPressAction ();
24+ bool isButtonPressed ();
2425void handleButton ();
2526void handleIO ();
2627
Original file line number Diff line number Diff line change @@ -250,8 +250,8 @@ void WLED::beginStrip()
250250#endif
251251
252252 // disable button if it is "pressed" unintentionally
253- #ifdef BTNPIN
254- if (digitalRead (BTNPIN) == LOW )
253+ #if defined( BTNPIN) || defined(TOUCHPIN)
254+ if (isButtonPressed () )
255255 buttonEnabled = false ;
256256#else
257257 buttonEnabled = false ;
You can’t perform that action at this time.
0 commit comments