Browse Source

5 Buttons , Build errors

master
Daniel Rieper 4 years ago
committed by Torsten Stauder
parent
commit
33d249ab13
  1. 44
      src/main.cpp
  2. 2
      src/settings-custom.h
  3. 2
      src/settings-espa1s.h
  4. 2
      src/settings-lolin32.h
  5. 2
      src/settings-lolin_d32.h
  6. 2
      src/settings-lolin_d32_pro.h
  7. 43
      src/settings.h
  8. 4
      src/values.h

44
src/main.cpp

@ -291,14 +291,15 @@ volatile SemaphoreHandle_t timerSemaphore;
// Button-helper // Button-helper
typedef struct { typedef struct {
bool lastState;
bool currentState;
bool isPressed;
bool isReleased;
bool lastState : 1;
bool currentState : 1;
bool isPressed : 1;
bool isReleased : 1;
unsigned long lastPressedTimestamp; unsigned long lastPressedTimestamp;
unsigned long lastReleasedTimestamp; unsigned long lastReleasedTimestamp;
} t_button; } t_button;
t_button buttons[4];
t_button buttons[6];
Preferences prefsRfid; Preferences prefsRfid;
Preferences prefsSettings; Preferences prefsSettings;
@ -491,7 +492,11 @@ void buttonHandler() {
buttons[0].currentState = digitalRead(NEXT_BUTTON); buttons[0].currentState = digitalRead(NEXT_BUTTON);
buttons[1].currentState = digitalRead(PREVIOUS_BUTTON); buttons[1].currentState = digitalRead(PREVIOUS_BUTTON);
buttons[2].currentState = digitalRead(PAUSEPLAY_BUTTON); buttons[2].currentState = digitalRead(PAUSEPLAY_BUTTON);
buttons[3].currentState = digitalRead(DREHENCODER_BUTTON);
#ifdef USEROTARY_ENABLE
buttons[3].currentState = digitalRead(DREHENCODER_BUTTON);
#endif
if(BUTTON_4 > 0 && BUTTON_4 < 50) buttons[4].currentState = digitalRead(BUTTON_4);
if(BUTTON_5 > 0 && BUTTON_5 < 50) buttons[5].currentState = digitalRead(BUTTON_5);
// Iterate over all buttons in struct-array // Iterate over all buttons in struct-array
for (uint8_t i=0; i < sizeof(buttons) / sizeof(buttons[0]); i++) { for (uint8_t i=0; i < sizeof(buttons) / sizeof(buttons[0]); i++) {
@ -572,6 +577,16 @@ void doButtonActions(void) {
doCmdAction(BUTTON_3_LONG); doCmdAction(BUTTON_3_LONG);
buttons[i].isPressed = false; buttons[i].isPressed = false;
break; break;
case 4:
doCmdAction(BUTTON_4_LONG);
buttons[i].isPressed = false;
break;
case 5:
doCmdAction(BUTTON_5_LONG);
buttons[i].isPressed = false;
break;
} }
} else { } else {
switch (i) // Short-press-actions switch (i) // Short-press-actions
@ -594,6 +609,17 @@ void doButtonActions(void) {
case 3: case 3:
doCmdAction(BUTTON_3_SHORT); doCmdAction(BUTTON_3_SHORT);
buttons[i].isPressed = false; buttons[i].isPressed = false;
break;
case 4:
doCmdAction(BUTTON_4_SHORT);
buttons[i].isPressed = false;
break;
case 5:
doCmdAction(BUTTON_5_SHORT);
buttons[i].isPressed = false;
break;
} }
} }
} }
@ -2504,7 +2530,7 @@ void doRfidCardModifications(const uint32_t mod) {
} }
#endif #endif
doAction(mod);
doCmdAction(mod);
} }
void doCmdAction(const uint32_t mod) { void doCmdAction(const uint32_t mod) {
@ -2900,10 +2926,10 @@ void doCmdAction(const uint32_t mod) {
case CMD_NEXTTRACK: case CMD_NEXTTRACK:
trackControlToQueueSender(NEXTTRACK); trackControlToQueueSender(NEXTTRACK);
break; break;
case CMD_FIRSTRACK:
case CMD_FIRSTTRACK:
trackControlToQueueSender(FIRSTTRACK); trackControlToQueueSender(FIRSTTRACK);
break; break;
case CMD_LASTRACK:
case CMD_LASTTRACK:
trackControlToQueueSender(LASTTRACK); trackControlToQueueSender(LASTTRACK);
break; break;
case CMD_VOLUMEINIT: case CMD_VOLUMEINIT:

2
src/settings-custom.h

@ -52,6 +52,8 @@
#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play #define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play
#define NEXT_BUTTON 4 // GPIO to detect next #define NEXT_BUTTON 4 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) #define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode)
#define BUTTON_4 99 // Button 4
#define BUTTON_5 99 // Button 5
// (optional) Power-control // (optional) Power-control
#define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

2
src/settings-espa1s.h

@ -46,6 +46,8 @@
#define PAUSEPLAY_BUTTON 36 // GPIO to detect pause/play #define PAUSEPLAY_BUTTON 36 // GPIO to detect pause/play
#define NEXT_BUTTON 199 // GPIO to detect next #define NEXT_BUTTON 199 // GPIO to detect next
#define PREVIOUS_BUTTON 198 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2) #define PREVIOUS_BUTTON 198 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2)
#define BUTTON_4 99 // Button 4
#define BUTTON_5 99 // Button 5
// Power-control // Power-control
#define POWER 19 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 19 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

2
src/settings-lolin32.h

@ -58,6 +58,8 @@
#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play #define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play
#define NEXT_BUTTON 4 // GPIO to detect next #define NEXT_BUTTON 4 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) #define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode)
#define BUTTON_4 99 // Button 4
#define BUTTON_5 99 // Button 5
// (optional) Power-control // (optional) Power-control
#define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

2
src/settings-lolin_d32.h

@ -59,6 +59,8 @@
#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play #define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play
#define NEXT_BUTTON 4 // GPIO to detect next #define NEXT_BUTTON 4 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2) #define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2)
#define BUTTON_4 99 // Button 4
#define BUTTON_5 99 // Button 5
// (optional) Power-control // (optional) Power-control
#define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

2
src/settings-lolin_d32_pro.h

@ -54,6 +54,8 @@
#define PAUSEPLAY_BUTTON 32 // GPIO to detect pause/play #define PAUSEPLAY_BUTTON 32 // GPIO to detect pause/play
#define NEXT_BUTTON 0 // GPIO to detect next #define NEXT_BUTTON 0 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2) #define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2)
#define BUTTON_4 99 // Button 4
#define BUTTON_5 99 // Button 5
// (optional) Power-control // (optional) Power-control
#define POWER 5 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 5 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

43
src/settings.h

@ -151,25 +151,30 @@ float voltageIndicatorHigh = 4.2; // Upper range for Neopixel-
// Button Layout // Button Layout
#define BUTTON_MULTI_01 = TOGGLE_WIFI_STATUS
#define BUTTON_MULTI_02 = ENABLE_FTP_SERVER
#define BUTTON_MULTI_03 = CMD_NOTHING
#define BUTTON_MULTI_12 = CMD_MEASUREBATTERY
#define BUTTON_MULTI_13 = CMD_NOTHING
#define BUTTON_MULTI_23 = CMD_NOTHING
#define BUTTON_0_SHORT = CMD_NEXTTRACK
#define BUTTON_1_SHORT = CMD_PREVTRACK
#define BUTTON_2_SHORT = CMD_PLAYPAUSE
#define BUTTON_3_SHORT = CMD_MEASUREBATTERY
#define BUTTON_3_LONG = CMD_SLEEPMODE
#define BUTTON_MULTI_01 TOGGLE_WIFI_STATUS
#define BUTTON_MULTI_02 ENABLE_FTP_SERVER
#define BUTTON_MULTI_03 CMD_NOTHING
#define BUTTON_MULTI_12 CMD_MEASUREBATTERY
#define BUTTON_MULTI_13 CMD_NOTHING
#define BUTTON_MULTI_23 CMD_NOTHING
#define BUTTON_0_SHORT CMD_NEXTTRACK
#define BUTTON_1_SHORT CMD_PREVTRACK
#define BUTTON_2_SHORT CMD_PLAYPAUSE
#define BUTTON_3_SHORT CMD_MEASUREBATTERY
#define BUTTON_3_LONG CMD_SLEEPMODE
#define BUTTON_4_SHORT CMD_VOLUMEDOWN
#define BUTTON_4_LONG CMD_VOLUMEDOWN
#define BUTTON_5_SHORT CMD_VOLUMEUP
#define BUTTON_5_LONG CMD_VOLUMEUP
#ifdef USEROTARY_ENABLE #ifdef USEROTARY_ENABLE
#define BUTTON_0_LONG = CMD_LASTTRACK
#define BUTTON_1_LONG = CMD_FIRSTTRACK
#define BUTTON_2_LONG = CMD_PLAYPAUSE
#define BUTTON_0_LONG CMD_LASTTRACK
#define BUTTON_1_LONG CMD_FIRSTTRACK
#define BUTTON_2_LONG CMD_PLAYPAUSE
#else #else
#define BUTTON_0_LONG = CMD_VOLUMEDOWN
#define BUTTON_1_LONG = CMD_VOLUMEUP
#define BUTTON_2_LONG = CMD_SLEEPMODE
#endif
#define BUTTON_0_LONG CMD_VOLUMEDOWN
#define BUTTON_1_LONG CMD_VOLUMEUP
#define BUTTON_2_LONG CMD_SLEEPMODE
#endif

4
src/values.h

@ -47,9 +47,9 @@
#define CMD_PLAYPAUSE 170 // Admin-Cmd Play/Pause #define CMD_PLAYPAUSE 170 // Admin-Cmd Play/Pause
#define CMD_PREVTRACK 171 // Admin-Cmd Prev Track #define CMD_PREVTRACK 171 // Admin-Cmd Prev Track
#define CMD_NEXTTACK 172 // Admin-Cmd Next Track
#define CMD_NEXTTRACK 172 // Admin-Cmd Next Track
#define CMD_FIRSTTRACK 173 // Admin-Cmd Prev Track #define CMD_FIRSTTRACK 173 // Admin-Cmd Prev Track
#define CMD_LASTTACK 174 // Admin-Cmd Next Track
#define CMD_LASTTRACK 174 // Admin-Cmd Next Track
#define CMD_VOLUMEINIT 175 // Set Volume to Initial #define CMD_VOLUMEINIT 175 // Set Volume to Initial
#define CMD_VOLUMEUP 176 // Set Volume up #define CMD_VOLUMEUP 176 // Set Volume up
#define CMD_VOLUMEDOWN 177 // Set Volume down #define CMD_VOLUMEDOWN 177 // Set Volume down

Loading…
Cancel
Save