mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Fix support of more touch pins (#16518)
This commit is contained in:
parent
903d3174b2
commit
7e21442e96
@ -26,10 +26,9 @@
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define MAX_RELAY_BUTTON1 5 // Max number of relay controlled by BUTTON1
|
#define MAX_RELAY_BUTTON1 5 // Max number of relay controlled by BUTTON1
|
||||||
#ifdef ESP32
|
|
||||||
#define TOUCH_PIN_THRESHOLD 12 // Smaller value will treated as button press
|
#define TOUCH_PIN_THRESHOLD 12 // Smaller value will treated as button press
|
||||||
#define TOUCH_HIT_THRESHOLD 3 // successful hits to filter out noise
|
#define TOUCH_HIT_THRESHOLD 3 // successful hits to filter out noise
|
||||||
#endif // ESP32
|
|
||||||
|
|
||||||
const uint8_t BUTTON_PROBE_INTERVAL = 10; // Time in milliseconds between button input probe
|
const uint8_t BUTTON_PROBE_INTERVAL = 10; // Time in milliseconds between button input probe
|
||||||
const uint8_t BUTTON_FAST_PROBE_INTERVAL = 2; // Time in milliseconds between button input probe for AC detection
|
const uint8_t BUTTON_FAST_PROBE_INTERVAL = 2; // Time in milliseconds between button input probe for AC detection
|
||||||
@ -67,9 +66,9 @@ struct BUTTON {
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
struct TOUCH_BUTTON {
|
struct TOUCH_BUTTON {
|
||||||
uint8_t pin_threshold = TOUCH_PIN_THRESHOLD;
|
uint32_t calibration = 0; // Bitfield
|
||||||
|
uint32_t pin_threshold = TOUCH_PIN_THRESHOLD;
|
||||||
uint8_t hit_threshold = TOUCH_HIT_THRESHOLD;
|
uint8_t hit_threshold = TOUCH_HIT_THRESHOLD;
|
||||||
uint32_t calibration = 0; // Bitfield
|
|
||||||
} TOUCH_BUTTON;
|
} TOUCH_BUTTON;
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
|
@ -24,10 +24,9 @@
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define MAX_RELAY_BUTTON1 5 // Max number of relay controlled by BUTTON1
|
#define MAX_RELAY_BUTTON1 5 // Max number of relay controlled by BUTTON1
|
||||||
#ifdef ESP32
|
|
||||||
#define TOUCH_PIN_THRESHOLD 12 // Smaller value will treated as button press
|
#define TOUCH_PIN_THRESHOLD 12 // Smaller value will treated as button press
|
||||||
#define TOUCH_HIT_THRESHOLD 3 // successful hits to filter out noise
|
#define TOUCH_HIT_THRESHOLD 3 // successful hits to filter out noise
|
||||||
#endif // ESP32
|
|
||||||
|
|
||||||
const char kMultiPress[] PROGMEM =
|
const char kMultiPress[] PROGMEM =
|
||||||
"|SINGLE|DOUBLE|TRIPLE|QUAD|PENTA|";
|
"|SINGLE|DOUBLE|TRIPLE|QUAD|PENTA|";
|
||||||
@ -56,9 +55,9 @@ struct BUTTON {
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
struct TOUCH_BUTTON {
|
struct TOUCH_BUTTON {
|
||||||
uint8_t pin_threshold = TOUCH_PIN_THRESHOLD;
|
uint32_t calibration = 0; // Bitfield
|
||||||
|
uint32_t pin_threshold = TOUCH_PIN_THRESHOLD;
|
||||||
uint8_t hit_threshold = TOUCH_HIT_THRESHOLD;
|
uint8_t hit_threshold = TOUCH_HIT_THRESHOLD;
|
||||||
uint32_t calibration = 0; // Bitfield
|
|
||||||
} TOUCH_BUTTON;
|
} TOUCH_BUTTON;
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
|
@ -2605,39 +2605,34 @@ void CmndCpuFrequency(void) {
|
|||||||
ResponseCmndNumber(getCpuFrequencyMhz());
|
ResponseCmndNumber(getCpuFrequencyMhz());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndTouchCal(void)
|
void CmndTouchCal(void) {
|
||||||
{
|
|
||||||
if (XdrvMailbox.payload >= 0) {
|
if (XdrvMailbox.payload >= 0) {
|
||||||
if (XdrvMailbox.payload < MAX_KEYS + 1) TOUCH_BUTTON.calibration = bitSet(TOUCH_BUTTON.calibration, XdrvMailbox.payload);
|
if (XdrvMailbox.payload == 0) {
|
||||||
if (XdrvMailbox.payload == 0) TOUCH_BUTTON.calibration = 0;
|
TOUCH_BUTTON.calibration = 0;
|
||||||
if (XdrvMailbox.payload == 255) TOUCH_BUTTON.calibration = 255; // all pinss
|
}
|
||||||
|
else if (XdrvMailbox.payload < MAX_KEYS + 1) {
|
||||||
|
TOUCH_BUTTON.calibration = bitSet(TOUCH_BUTTON.calibration, XdrvMailbox.payload);
|
||||||
|
}
|
||||||
|
else if (XdrvMailbox.payload == 255) {
|
||||||
|
TOUCH_BUTTON.calibration = 0x0FFFFFFF; // All MAX_KEYS pins
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Response_P(PSTR("{\"" D_CMND_TOUCH_CAL "\": %u"), TOUCH_BUTTON.calibration);
|
ResponseCmndNumber(TOUCH_BUTTON.calibration);
|
||||||
ResponseJsonEnd();
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,"));
|
AddLog(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndTouchThres(void)
|
void CmndTouchThres(void) {
|
||||||
{
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 32000)) {
|
||||||
if (XdrvMailbox.payload >= 0) {
|
TOUCH_BUTTON.pin_threshold = XdrvMailbox.payload;
|
||||||
if (XdrvMailbox.payload<256){
|
|
||||||
TOUCH_BUTTON.pin_threshold = XdrvMailbox.payload;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Response_P(PSTR("{\"" D_CMND_TOUCH_THRES "\": %u"), TOUCH_BUTTON.pin_threshold);
|
ResponseCmndNumber(TOUCH_BUTTON.pin_threshold);
|
||||||
ResponseJsonEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndTouchNum(void)
|
void CmndTouchNum(void) {
|
||||||
{
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 32)) {
|
||||||
if (XdrvMailbox.payload >= 0) {
|
TOUCH_BUTTON.hit_threshold = XdrvMailbox.payload;
|
||||||
if (XdrvMailbox.payload<32){
|
|
||||||
TOUCH_BUTTON.hit_threshold = XdrvMailbox.payload;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Response_P(PSTR("{\"" D_CMND_TOUCH_NUM "\": %u"), TOUCH_BUTTON.hit_threshold);
|
ResponseCmndNumber(TOUCH_BUTTON.hit_threshold);
|
||||||
ResponseJsonEnd();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user