Comments (9)
Sorry, but the Touch Sensor library on the ESP32 is quite complicated and the button class would need to be significantly changed to incorporate that library.
from homespan.
@PeteBurgess to use touch in the Arduino IDE is as easy as do a comparison: touchRead(13) < TOUCH_LMT
. TOUCH_LMT
depends on the surface used as sensor, but you could easily print touchRead values and calibrate from there. Of course you need everything related to a button after that. such as debounce. Hope it helps.
Code sample:
int lastState = LOW;
int lastDebouncedState = LOW;
int currentState;
unsigned long lastDebounceTime = 0;
#define TOUCH_LMT 35
#define DEBOUNCE_DELAY 50
void setup() {
}
void loop(){
currentState = touchRead(13) < TOUCH_LMT;
// If the switch/button changed, due to noise or pressing:
if (currentState != lastState) {
// reset the debouncing timer
lastDebounceTime = millis();
// save the the last flickerable state
lastState = currentState;
}
if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
if(lastDebouncedState == HIGH && currentState == LOW)
Serial.println("Button pressed");
else if(lastDebouncedState == LOW && currentState == HIGH)
Serial.println("Button released");
lastDebouncedState = currentState;
}
from homespan.
Wow - thank you! I had no idea the ESP32-Arduino library had this feature. This makes it a LOT easier to integrate. I will extend the button class to allow the use of touchRead. Probably won't be able to get it into the next update (which I'm hoping to release later this week) but should be able to add it to the next one (as well as provide it earlier in dev once ready).
from homespan.
Thanks. I’ve used it before, it actually works pretty well.
from homespan.
Hello, has this been implemented?
from homespan.
Sorry, I have not yet added that to HomeSpan, but hope to in a future release. Given other similar requests for alternative buttons (pull-ups, use of multiplexers, etc.) I anticipate making something more generic so that the user can define a function that simply returns true/false depending on whether the "button" is pressed, regardless of button type.
Note you can still use the touch library at present with HomeSpan, but you will need to add logic to process the "touches" in the loop()
method of a Service, instead of using SpanButton
from homespan.
HomeSpan version 1.6.0 (just released) now includes the ability to use touch pad/sensors with SpanButton. Complete details can be found in the the latest version of SpanButton() in the API documentation, with additional tutorial instructions describing how touch pad sensitivity is calibrated added to the end of Example 15 - RealPushButtons. Thanks for raising this request!
from homespan.
Is it possible to use the touch sensor as control pin?
from homespan.
No, you can only use touch for SpanButton at this time. Control still needs to be a physical button to ground.
from homespan.
Related Issues (20)
- Multiclicks SpanButton HOT 2
- When restarting after a power failure, the ESP32 will no longer reconnect to WIFI HOT 5
- Pushbutton ON/OFF
- Weblogs keeping TCP connections open HOT 3
- NTP Libraries reboot the device HOT 4
- Sodium FATAL ERROR v3 : HomeSpan\src\HAP.cpp:29:20: fatal error: sodium.h: No such file or directory HOT 1
- M2: Accessory -> iOS Device – ‘SRP Start Responseʼ code HOT 2
- Expected behavior of using setPortNum() with weblogs? HOT 5
- Help needed: GPIO output gpio_num error HOT 4
- esp switch goes abruptly unreachable HOT 3
- setWifiCallbackAll HOT 6
- Issue with library update HOT 2
- FATAL ERROR after installing to 1.9.0 HOT 3
- ESP32-C3 Mini Development Board not able to connect to WiFi HOT 1
- LED strip with WS2811 controller HOT 31
- Color wheel is inverted HOT 5
- HomeSpan 1.9.0 take more flash than 1.8.0 HOT 16
- Unable to use setParingCode() successfully HOT 5
- Captive portal HOT 2
- Feature request: Stepper->Stop() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homespan.