From cd138e5b712f477e061fce20850a3bb00805db61 Mon Sep 17 00:00:00 2001 From: Hendrik Rauh <114620133+HendrikRauh@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:33:46 +0100 Subject: [PATCH 1/3] Reset protection Fixes #39 --- src/main.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6a15209..a1c752d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,21 +100,27 @@ void setup() // LED analogWrite(PIN_LED, brightness_led); - // delay(5000); - ledBlink(500); // Button pinMode(PIN_BUTTON, INPUT_PULLUP); if (digitalRead(PIN_BUTTON) == LOW) { ledBlink(100); - delay(2000); - Serial.println("Reset config"); - config.begin("dmx", false); - config.clear(); - config.end(); + unsigned long startTime = millis(); + while (digitalRead(PIN_BUTTON) == LOW && (millis() - startTime >= 5000)) + { + } + if (digitalRead(PIN_BUTTON) == LOW) + { + Serial.println("Reset config"); + config.begin("dmx", false); + config.clear(); + config.end(); + } } + ledBlink(500); + // wait for serial monitor delay(5000); Serial.println("Starting DMX-Interface..."); From 6e828b2e8ec7d999c99fd6895c047fcb7de60940 Mon Sep 17 00:00:00 2001 From: Hendrik Rauh <114620133+HendrikRauh@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:53:38 +0100 Subject: [PATCH 2/3] updated doc to match new reset #39 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b4b29f..03abb0e 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ All print files (STL, STEP, X_T) can be found in [assets/case](/assets/case/). A ## ⚙️ Default config -To reset the settings, hold down the button and connect the ESP to the power supply. As soon as the LED flashes quickly, the settings are reset. +To reset the settings, hold down the button and connect the ESP to the power supply, the LED will flash quickly. After 5 seconds the LED should start flashing slowly and the settings are reset. If you release the button early you abort the reset. | Setting | Value | | -------------- | ------------------ | From 2126a70d69986e90e4ce9086dceaab26e0ed321d Mon Sep 17 00:00:00 2001 From: Hendrik Rauh <114620133+HendrikRauh@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:50:57 +0100 Subject: [PATCH 3/3] fixed and changed the reset protection --- README.md | 2 +- src/main.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03abb0e..80f450d 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ All print files (STL, STEP, X_T) can be found in [assets/case](/assets/case/). A ## ⚙️ Default config -To reset the settings, hold down the button and connect the ESP to the power supply, the LED will flash quickly. After 5 seconds the LED should start flashing slowly and the settings are reset. If you release the button early you abort the reset. +To reset the settings, hold down the button and connect the ESP to the power supply, the LED will flash quickly. After 3 seconds the LED should light up static and the settings are reset. If you release the button early you abort the reset and the LED flashes slowly. | Setting | Value | | -------------- | ------------------ | diff --git a/src/main.cpp b/src/main.cpp index a1c752d..9dccc71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,15 +107,17 @@ void setup() { ledBlink(100); unsigned long startTime = millis(); - while (digitalRead(PIN_BUTTON) == LOW && (millis() - startTime >= 5000)) + while (digitalRead(PIN_BUTTON) == LOW && (millis() - startTime <= 3000)) { } if (digitalRead(PIN_BUTTON) == LOW) { + ledBlink(1); Serial.println("Reset config"); config.begin("dmx", false); config.clear(); config.end(); + delay(2000); } }