... | ... |
@@ -47,6 +47,8 @@ |
47 | 47 |
#include <EEPROM.h> |
48 | 48 |
#define EEPROM_SIZE 3 // To save BeaconType & BeaconNum upon restart |
49 | 49 |
|
50 |
+ |
|
51 |
+ |
|
50 | 52 |
//#define DISABLE_BT //For Battery charging test |
51 | 53 |
//#define DEBUG_PAYLOAD //TO print the payload to be sent |
52 | 54 |
|
... | ... |
@@ -170,7 +172,7 @@ void setup() { |
170 | 172 |
Serial.println(String(APPNAME)+" v"+String(APPVER)); |
171 | 173 |
Serial.println("DeviceAddress: "+String(macStr)); |
172 | 174 |
Serial.println("------------------------------"); |
173 |
- |
|
175 |
+ lastExecTime = millis(); |
|
174 | 176 |
|
175 | 177 |
|
176 | 178 |
beacon_type = EEPROM.read(0); |
... | ... |
@@ -8,8 +8,8 @@ It has been successfully tested on Wemos TTGO LoRa / Heltech & M5-Stick-C / ESPC |
8 | 8 |
One long press on PRG button is used to cycle through beacon type (Safe -> Exit -> Other -> Entry -> Hazard) |
9 | 9 |
|
10 | 10 |
## Limitations |
11 |
-- ESP32C3: Button not working |
|
12 | 11 |
- ESP32C3: Display not working |
12 |
+- ESP32C3: Button is working **BUT** it is recommended to restart after each press |
|
13 | 13 |
|
14 | 14 |
## Files |
15 | 15 |
```bash |
... | ... |
@@ -4,17 +4,28 @@ |
4 | 4 |
#include <EEPROM.h> |
5 | 5 |
#include "beacon.h" |
6 | 6 |
|
7 |
+#define DEBOUNCE_TIME 100 |
|
8 |
+int lastExecTime = 0; |
|
9 |
+ |
|
7 | 10 |
int buttonState = 0; // variable for reading the pushbutton status |
8 | 11 |
#ifdef ARDUINO_HELTEC_WIFI_LORA_32 |
9 | 12 |
const int BUTTON_PRG = 0; // PRG Button |
10 | 13 |
#elif ARDUINO_M5Stick_C |
11 | 14 |
const int BUTTON_PRG = M5_BUTTON_HOME; // Home Button |
12 | 15 |
#elif ARDUINO_ESP32C3_DEV |
13 |
- const int BUTTON_PRG = 0; // PRG Button |
|
16 |
+ const int BUTTON_PRG = 9; // PRG Button |
|
14 | 17 |
#endif // ARDUINO_HELTEC_WIFI_LORA_32 & ARDUINO_M5Stick_C &ARDUINO_ESP32C3_DEV |
15 | 18 |
|
16 | 19 |
void onPrgFall(){ |
20 |
+ int currentExecTime=millis(); |
|
21 |
+ if(DEBOUNCE_TIME > (currentExecTime - lastExecTime)) { |
|
22 |
+ //Bouncing |
|
23 |
+ return; |
|
24 |
+ } |
|
17 | 25 |
Serial.println("onPrgFall"); |
26 |
+ lastExecTime=currentExecTime; |
|
27 |
+ |
|
28 |
+ //delay(BEACON_SLEEP_ADV); |
|
18 | 29 |
switch( beacon_type ) { |
19 | 30 |
case EN_BEACON_TYPE_entry: |
20 | 31 |
beacon_type = EN_BEACON_TYPE_hazard; |