Browse Source

ON and OFF actions for button events

fastled
Xose Pérez 7 years ago
parent
commit
66131bbafd
2 changed files with 17 additions and 4 deletions
  1. +10
    -0
      code/espurna/button.ino
  2. +7
    -4
      code/espurna/config/general.h

+ 10
- 0
code/espurna/button.ino View File

@ -92,6 +92,16 @@ void buttonEvent(unsigned int id, unsigned char event) {
relayToggle(_buttons[id].relayID - 1); relayToggle(_buttons[id].relayID - 1);
} }
} }
if (action == BUTTON_MODE_ON) {
if (_buttons[id].relayID > 0) {
relayStatus(_buttons[id].relayID - 1, true);
}
}
if (action == BUTTON_MODE_OFF) {
if (_buttons[id].relayID > 0) {
relayStatus(_buttons[id].relayID - 1, false);
}
}
if (action == BUTTON_MODE_AP) createAP(); if (action == BUTTON_MODE_AP) createAP();
if (action == BUTTON_MODE_RESET) { if (action == BUTTON_MODE_RESET) {
customReset(CUSTOM_RESET_HARDWARE); customReset(CUSTOM_RESET_HARDWARE);


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

@ -100,6 +100,7 @@ PROGMEM const char* const custom_reset_string[] = {
#define BUTTON_EVENT_NONE 0 #define BUTTON_EVENT_NONE 0
#define BUTTON_EVENT_PRESSED 1 #define BUTTON_EVENT_PRESSED 1
#define BUTTON_EVENT_RELEASED 2
#define BUTTON_EVENT_CLICK 2 #define BUTTON_EVENT_CLICK 2
#define BUTTON_EVENT_DBLCLICK 3 #define BUTTON_EVENT_DBLCLICK 3
#define BUTTON_EVENT_LNGCLICK 4 #define BUTTON_EVENT_LNGCLICK 4
@ -107,10 +108,12 @@ PROGMEM const char* const custom_reset_string[] = {
#define BUTTON_MODE_NONE 0 #define BUTTON_MODE_NONE 0
#define BUTTON_MODE_TOGGLE 1 #define BUTTON_MODE_TOGGLE 1
#define BUTTON_MODE_AP 2
#define BUTTON_MODE_RESET 3
#define BUTTON_MODE_PULSE 4
#define BUTTON_MODE_FACTORY 5
#define BUTTON_MODE_ON 2
#define BUTTON_MODE_OFF 3
#define BUTTON_MODE_AP 4
#define BUTTON_MODE_RESET 5
#define BUTTON_MODE_PULSE 6
#define BUTTON_MODE_FACTORY 7
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// RELAY // RELAY


Loading…
Cancel
Save