Browse Source

Issue #170. Using updated DebounceEvent library to allow disabling double click option and get faster click responses

fastled
Xose Pérez 7 years ago
parent
commit
0535fcee5e
3 changed files with 11 additions and 9 deletions
  1. +6
    -6
      code/espurna/button.ino
  2. +4
    -2
      code/espurna/config/general.h
  3. +1
    -1
      code/platformio.ini

+ 6
- 6
code/espurna/button.ino View File

@ -68,8 +68,8 @@ uint8_t mapEvent(uint8_t event, uint8_t count, uint16_t length) {
if (event == EVENT_CHANGED) return BUTTON_EVENT_CLICK; if (event == EVENT_CHANGED) return BUTTON_EVENT_CLICK;
if (event == EVENT_RELEASED) { if (event == EVENT_RELEASED) {
if (count == 1) { if (count == 1) {
if (length > BUTTON_LNGLNGCLICK_LENGTH) return BUTTON_EVENT_LNGLNGCLICK;
if (length > BUTTON_LNGCLICK_LENGTH) return BUTTON_EVENT_LNGCLICK;
if (length > BUTTON_LNGLNGCLICK_DELAY) return BUTTON_EVENT_LNGLNGCLICK;
if (length > BUTTON_LNGCLICK_DELAY) return BUTTON_EVENT_LNGCLICK;
return BUTTON_EVENT_CLICK; return BUTTON_EVENT_CLICK;
} }
if (count == 2) return BUTTON_EVENT_DBLCLICK; if (count == 2) return BUTTON_EVENT_DBLCLICK;
@ -121,25 +121,25 @@ void buttonSetup() {
#ifdef BUTTON1_PIN #ifdef BUTTON1_PIN
{ {
unsigned int actions = buttonStore(BUTTON1_PRESS, BUTTON1_CLICK, BUTTON1_DBLCLICK, BUTTON1_LNGCLICK, BUTTON1_LNGLNGCLICK); unsigned int actions = buttonStore(BUTTON1_PRESS, BUTTON1_CLICK, BUTTON1_DBLCLICK, BUTTON1_LNGCLICK, BUTTON1_LNGLNGCLICK);
_buttons.push_back({new DebounceEvent(BUTTON1_PIN, BUTTON1_MODE), actions, BUTTON1_RELAY});
_buttons.push_back({new DebounceEvent(BUTTON1_PIN, BUTTON1_MODE, BUTTON_DEBOUNCE_DELAY, BUTTON_DBLCLICK_DELAY), actions, BUTTON1_RELAY});
} }
#endif #endif
#ifdef BUTTON2_PIN #ifdef BUTTON2_PIN
{ {
unsigned int actions = buttonStore(BUTTON2_PRESS, BUTTON2_CLICK, BUTTON2_DBLCLICK, BUTTON2_LNGCLICK, BUTTON2_LNGLNGCLICK); unsigned int actions = buttonStore(BUTTON2_PRESS, BUTTON2_CLICK, BUTTON2_DBLCLICK, BUTTON2_LNGCLICK, BUTTON2_LNGLNGCLICK);
_buttons.push_back({new DebounceEvent(BUTTON2_PIN, BUTTON2_MODE), actions, BUTTON2_RELAY});
_buttons.push_back({new DebounceEvent(BUTTON2_PIN, BUTTON2_MODE, BUTTON_DEBOUNCE_DELAY, BUTTON_DBLCLICK_DELAY), actions, BUTTON2_RELAY});
} }
#endif #endif
#ifdef BUTTON3_PIN #ifdef BUTTON3_PIN
{ {
unsigned int actions = buttonStore(BUTTON3_PRESS, BUTTON3_CLICK, BUTTON3_DBLCLICK, BUTTON3_LNGCLICK, BUTTON3_LNGLNGCLICK); unsigned int actions = buttonStore(BUTTON3_PRESS, BUTTON3_CLICK, BUTTON3_DBLCLICK, BUTTON3_LNGCLICK, BUTTON3_LNGLNGCLICK);
_buttons.push_back({new DebounceEvent(BUTTON3_PIN, BUTTON3_MODE), actions, BUTTON3_RELAY});
_buttons.push_back({new DebounceEvent(BUTTON3_PIN, BUTTON3_MODE, BUTTON_DEBOUNCE_DELAY, BUTTON_DBLCLICK_DELAY), actions, BUTTON3_RELAY});
} }
#endif #endif
#ifdef BUTTON4_PIN #ifdef BUTTON4_PIN
{ {
unsigned int actions = buttonStore(BUTTON4_PRESS, BUTTON4_CLICK, BUTTON4_DBLCLICK, BUTTON4_LNGCLICK, BUTTON4_LNGLNGCLICK); unsigned int actions = buttonStore(BUTTON4_PRESS, BUTTON4_CLICK, BUTTON4_DBLCLICK, BUTTON4_LNGCLICK, BUTTON4_LNGLNGCLICK);
_buttons.push_back({new DebounceEvent(BUTTON4_PIN, BUTTON4_MODE), actions, BUTTON4_RELAY});
_buttons.push_back({new DebounceEvent(BUTTON4_PIN, BUTTON4_MODE, BUTTON_DEBOUNCE_DELAY, BUTTON_DBLCLICK_DELAY), actions, BUTTON4_RELAY});
} }
#endif #endif


+ 4
- 2
code/espurna/config/general.h View File

@ -69,8 +69,10 @@ PROGMEM const char* const custom_reset_string[] = {
// BUTTON // BUTTON
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
#define BUTTON_LNGCLICK_LENGTH 1000
#define BUTTON_LNGLNGCLICK_LENGTH 10000
#define BUTTON_DEBOUNCE_DELAY 50
#define BUTTON_DBLCLICK_DELAY 500
#define BUTTON_LNGCLICK_DELAY 1000
#define BUTTON_LNGLNGCLICK_DELAY 10000
#define BUTTON_EVENT_NONE 0 #define BUTTON_EVENT_NONE 0
#define BUTTON_EVENT_PRESSED 1 #define BUTTON_EVENT_PRESSED 1


+ 1
- 1
code/platformio.ini View File

@ -26,7 +26,7 @@ lib_deps =
https://bitbucket.org/xoseperez/fauxmoesp.git#2.1.0 https://bitbucket.org/xoseperez/fauxmoesp.git#2.1.0
https://bitbucket.org/xoseperez/nofuss.git#0.2.2 https://bitbucket.org/xoseperez/nofuss.git#0.2.2
https://bitbucket.org/xoseperez/emonliteesp.git#0.1.2 https://bitbucket.org/xoseperez/emonliteesp.git#0.1.2
https://bitbucket.org/xoseperez/debounceevent.git#2.0.0
https://bitbucket.org/xoseperez/debounceevent.git#2.0.1
https://github.com/xoseperez/my9291#1.0.0 https://github.com/xoseperez/my9291#1.0.0
https://github.com/xoseperez/RemoteSwitch-arduino-library.git https://github.com/xoseperez/RemoteSwitch-arduino-library.git
lib_ignore = lib_ignore =


Loading…
Cancel
Save