mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-18 21:55:34 +00:00
fixed accidental reset when restarting the interface via button and keeping the button pressed
This commit is contained in:
parent
aaae5ac91b
commit
b1d3e6bd69
1 changed files with 10 additions and 4 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -96,17 +96,18 @@ void onButtonPress()
|
|||
switch (action)
|
||||
{
|
||||
case ResetConfig:
|
||||
ledBlink(100);
|
||||
|
||||
config.begin("dmx", false);
|
||||
config.clear();
|
||||
config.end();
|
||||
delay(1000);
|
||||
|
||||
ESP.restart();
|
||||
break;
|
||||
|
||||
case Restart:
|
||||
config.begin("dmx", false);
|
||||
config.putBool("restart-via-btn", true);
|
||||
config.end();
|
||||
|
||||
ESP.restart();
|
||||
break;
|
||||
case None:
|
||||
|
@ -125,12 +126,13 @@ void setup()
|
|||
// LED
|
||||
config.begin("dmx", true);
|
||||
brightness_led = config.getUInt("led-brightness", DEFAULT_LED_BRIGHTNESS);
|
||||
bool restartViaButton = config.getBool("restart-via-btn", false);
|
||||
config.end();
|
||||
analogWrite(PIN_LED, brightness_led);
|
||||
|
||||
// Button
|
||||
pinMode(PIN_BUTTON, INPUT_PULLUP);
|
||||
if (digitalRead(PIN_BUTTON) == LOW)
|
||||
if (digitalRead(PIN_BUTTON) == LOW && !restartViaButton)
|
||||
{
|
||||
ledBlink(100);
|
||||
unsigned long startTime = millis();
|
||||
|
@ -148,6 +150,10 @@ void setup()
|
|||
}
|
||||
}
|
||||
|
||||
config.begin("dmx", false);
|
||||
config.putBool("restart-via-btn", false);
|
||||
config.end();
|
||||
|
||||
ledBlink(500);
|
||||
|
||||
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
||||
|
|
Loading…
Add table
Reference in a new issue