hi Hennigs, thank you for your awesome library , the esp32 touch sample run well, so I I'd like to implement more than one touch button i.e: (meniu_button ,eq_button volup_button, voldow_down, ). that the code run , but only one the menu_button responding action, please help to validate my below sketch. thank you alot!
ah, I found that you use the setDebounceTime method to define the threshold value for the handler to make compre with touch read value . I fixed my issue now, thank you!
hi Hennigs, thank you for your awesome library , the esp32 touch sample run well, so I I'd like to implement more than one touch button i.e: (meniu_button ,eq_button volup_button, voldow_down, ). that the code run , but only one the menu_button responding action, please help to validate my below sketch. thank you alot!
/////////////////////////////////////////////////////////////////
if !defined(ESP32)
error This sketch needs an ESP32
else
/////////////////////////////////////////////////////////////////
include "Button2.h"
/////////////////////////////////////////////////////////////////
Button2 menu_button; Button2 eq_button; Button2 volup_button; Button2 voldow_button;
define button1 4 // menu-button
define button2 15 // e button
define button3 32 // vol +
define button4 33 // vol -
/////////////////////////////////////////////////////////////////
byte capStateHandler1() { int capa = touchRead(button1); return capa < menu_button.getDebounceTime() ? LOW : HIGH; } byte capStateHandler2() { int capa = touchRead(button2); return capa < eq_button.getDebounceTime() ? LOW : HIGH; } byte capStateHandler3() { int capa = touchRead(button3); return capa < volup_button.getDebounceTime() ? LOW : HIGH; } byte capStateHandler4() { int capa = touchRead(button4); return capa < voldow_button.getDebounceTime() ? LOW : HIGH; }
/////////////////////////////////////////////////////////////////
void setup() { Serial.begin(9600); delay(50); Serial.println("\n\nCapacitive Touch Demo");
}
/////////////////////////////////////////////////////////////////
void loop() { menu_button.loop(); eq_button.loop(); volup_button.loop(); voldow_button.loop(); }
///////////////////////////////////////////////////////////////// void click(Button2& btn) { Serial.println("menu click\n"); }
// long click void longClick(Button2 &btn) { unsigned int time = btn.wasPressedFor(); if (time > 1000) { Serial.println("long click\n"); } }
void eq_click(Button2& btn) { Serial.println("eq click\n"); }
void volup_click(Button2& btn) { Serial.println("volup click\n"); }
void voldow_click(Button2& btn) { Serial.println("voldow click\n"); }
/////////////////////////////////////////////////////////////////
endif
/////////////////////////////////////////////////////////////////