From 2fd9758d93ff7f8a7dfb3d49db33cd2cebf91b17 Mon Sep 17 00:00:00 2001 From: Daniel Rieper Date: Sun, 14 Feb 2021 21:05:22 +0100 Subject: [PATCH] Check Buttons Enabled --- src/main.cpp | 41 ++++++++++++++++++++++++++++++------ src/settings-custom.h | 12 +++++------ src/settings-espa1s.h | 12 +++++------ src/settings-lolin32.h | 14 ++++++------ src/settings-lolin_d32.h | 10 ++++----- src/settings-lolin_d32_pro.h | 12 +++++------ 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2b755ad..154ccd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -316,6 +316,25 @@ QueueHandle_t rfidCardQueue; RingbufHandle_t explorerFileUploadRingBuffer; QueueHandle_t explorerFileUploadStatusQueue; +#if (NEXT_BUTTON > 0 && NEXT_BUTTON<50) + #define BUTTON_0_ENABLE +#endif +#if (PREVIOUS_BUTTON > 0 && PREVIOUS_BUTTON<50) + #define BUTTON_1_ENABLE +#endif +#if (PAUSEPLAY_BUTTON > 0 && PAUSEPLAY_BUTTON<50) + #define BUTTON_2_ENABLE +#endif +#ifdef USEROTARY_ENABLE + #define BUTTON_3_ENABLE +#endif +#if (BUTTON_4 > 0 && BUTTON_4<50) + #define BUTTON_4_ENABLE +#endif +#if (BUTTON_5 > 0 && BUTTON_5<50) + #define BUTTON_5_ENABLE +#endif + // Prototypes void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask); static int arrSortHelper(const void* a, const void* b); @@ -491,14 +510,24 @@ void buttonHandler() { return; } unsigned long currentTimestamp = millis(); - buttons[0].currentState = digitalRead(NEXT_BUTTON); - buttons[1].currentState = digitalRead(PREVIOUS_BUTTON); - buttons[2].currentState = digitalRead(PAUSEPLAY_BUTTON); - #ifdef USEROTARY_ENABLE + #ifdef BUTTON_0_ENABLE + buttons[0].currentState = digitalRead(NEXT_BUTTON); + #endif + #ifdef BUTTON_1_ENABLE + buttons[1].currentState = digitalRead(PREVIOUS_BUTTON); + #endif + #ifdef BUTTON_2_ENABLE + buttons[2].currentState = digitalRead(PAUSEPLAY_BUTTON); + #endif + #ifdef BUTTON_3_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); + #ifdef BUTTON_4_ENABLE + buttons[4].currentState = digitalRead(BUTTON_4); + #endif + #ifdef BUTTON_5_ENABLE + buttons[5].currentState = digitalRead(BUTTON_5); + #endif // Iterate over all buttons in struct-array for (uint8_t i=0; i < sizeof(buttons) / sizeof(buttons[0]); i++) { diff --git a/src/settings-custom.h b/src/settings-custom.h index 56096e8..8031bb0 100644 --- a/src/settings-custom.h +++ b/src/settings-custom.h @@ -46,14 +46,14 @@ // Rotary encoder #define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) #define DREHENCODER_DT 35 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring! -#define DREHENCODER_BUTTON 32 // Button is used to switch ESPuino on and off +#define DREHENCODER_BUTTON 32 // Button 3: is used to switch ESPuino on and off // Control-buttons -#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play -#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 BUTTON_4 99 // Button 4 -#define BUTTON_5 99 // Button 5 +#define NEXT_BUTTON 4 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 0 // Button 2: GPIO to detect pause/play +#define BUTTON_4 99 // Button 4 +#define BUTTON_5 99 // Button 5 // (optional) Power-control #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep diff --git a/src/settings-espa1s.h b/src/settings-espa1s.h index 7c776f3..1c16910 100644 --- a/src/settings-espa1s.h +++ b/src/settings-espa1s.h @@ -40,14 +40,14 @@ // Rotary encoder #define DREHENCODER_CLK 5 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) #define DREHENCODER_DT 18 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring! -#define DREHENCODER_BUTTON 4 // Button is used to switch ESPuino on and off +#define DREHENCODER_BUTTON 4 // Button 3: is used to switch ESPuino on and off // Control-buttons -#define PAUSEPLAY_BUTTON 36 // GPIO to detect pause/play -#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 BUTTON_4 99 // Button 4 -#define BUTTON_5 99 // Button 5 +#define NEXT_BUTTON 199 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 198 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 36 // Button 2: GPIO to detect pause/play +#define BUTTON_4 99 // Button 4 +#define BUTTON_5 99 // Button 5 // Power-control #define POWER 19 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep diff --git a/src/settings-lolin32.h b/src/settings-lolin32.h index ae7ba1b..7f5f90f 100644 --- a/src/settings-lolin32.h +++ b/src/settings-lolin32.h @@ -34,7 +34,7 @@ // RFID (via SPI) #define RST_PIN 99 // Not necessary but has to be set anyway; so let's use a dummy-number -#define RFID_CS 21 // GPIO for chip select (RFID) +#define RFID_CS 5 // GPIO for chip select (RFID) #define RFID_MOSI 23 // GPIO for master out slave in (RFID) #define RFID_MISO 19 // GPIO for master in slave out (RFID) #define RFID_SCK 18 // GPIO for clock-signal (RFID) @@ -52,14 +52,14 @@ // Rotary encoder #define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) #define DREHENCODER_DT 35 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring! -#define DREHENCODER_BUTTON 32 // Button is used to switch ESPuino on and off +#define DREHENCODER_BUTTON 32 // Button 3: is used to switch ESPuino on and off // Control-buttons -#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play -#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 BUTTON_4 99 // Button 4 -#define BUTTON_5 99 // Button 5 +#define NEXT_BUTTON 4 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 5 // Button 2: GPIO to detect pause/play +#define BUTTON_4 99 // Button 4 +#define BUTTON_5 99 // Button 5 // (optional) Power-control #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep diff --git a/src/settings-lolin_d32.h b/src/settings-lolin_d32.h index 7d21828..ada5f70 100644 --- a/src/settings-lolin_d32.h +++ b/src/settings-lolin_d32.h @@ -56,11 +56,11 @@ #define DREHENCODER_BUTTON 32 // Button is used to switch ESPuino on and off // Control-buttons -#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play -#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 BUTTON_4 99 // Button 4 -#define BUTTON_5 99 // Button 5 +#define NEXT_BUTTON 4 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 5 // Button 2: GPIO to detect pause/play +#define BUTTON_4 99 // Button 4 +#define BUTTON_5 99 // Button 5 // (optional) Power-control #define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep diff --git a/src/settings-lolin_d32_pro.h b/src/settings-lolin_d32_pro.h index 56fe13e..a5cfca9 100644 --- a/src/settings-lolin_d32_pro.h +++ b/src/settings-lolin_d32_pro.h @@ -48,14 +48,14 @@ // Rotary encoder #define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) #define DREHENCODER_DT 39 // 39 = 'VN' -#define DREHENCODER_BUTTON 36 // Button is used to switch ESPuino on and off; 36 = 'VP' +#define DREHENCODER_BUTTON 36 // Button 3: is used to switch ESPuino on and off; 36 = 'VP' // Control-buttons -#define PAUSEPLAY_BUTTON 32 // GPIO to detect pause/play -#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 BUTTON_4 99 // Button 4 -#define BUTTON_5 99 // Button 5 +#define NEXT_BUTTON 0 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 32 // Button 2: GPIO to detect pause/play +#define BUTTON_4 99 // Button 4 +#define BUTTON_5 99 // Button 5 // (optional) Power-control #define POWER 5 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep