mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-19 10:32:56 +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)
|
switch (action)
|
||||||
{
|
{
|
||||||
case ResetConfig:
|
case ResetConfig:
|
||||||
ledBlink(100);
|
|
||||||
|
|
||||||
config.begin("dmx", false);
|
config.begin("dmx", false);
|
||||||
config.clear();
|
config.clear();
|
||||||
config.end();
|
config.end();
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Restart:
|
case Restart:
|
||||||
|
config.begin("dmx", false);
|
||||||
|
config.putBool("restart-via-btn", true);
|
||||||
|
config.end();
|
||||||
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
break;
|
break;
|
||||||
case None:
|
case None:
|
||||||
|
@ -125,12 +126,13 @@ void setup()
|
||||||
// LED
|
// LED
|
||||||
config.begin("dmx", true);
|
config.begin("dmx", true);
|
||||||
brightness_led = config.getUInt("led-brightness", DEFAULT_LED_BRIGHTNESS);
|
brightness_led = config.getUInt("led-brightness", DEFAULT_LED_BRIGHTNESS);
|
||||||
|
bool restartViaButton = config.getBool("restart-via-btn", false);
|
||||||
config.end();
|
config.end();
|
||||||
analogWrite(PIN_LED, brightness_led);
|
analogWrite(PIN_LED, brightness_led);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
pinMode(PIN_BUTTON, INPUT_PULLUP);
|
pinMode(PIN_BUTTON, INPUT_PULLUP);
|
||||||
if (digitalRead(PIN_BUTTON) == LOW)
|
if (digitalRead(PIN_BUTTON) == LOW && !restartViaButton)
|
||||||
{
|
{
|
||||||
ledBlink(100);
|
ledBlink(100);
|
||||||
unsigned long startTime = millis();
|
unsigned long startTime = millis();
|
||||||
|
@ -148,6 +150,10 @@ void setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.begin("dmx", false);
|
||||||
|
config.putBool("restart-via-btn", false);
|
||||||
|
config.end();
|
||||||
|
|
||||||
ledBlink(500);
|
ledBlink(500);
|
||||||
|
|
||||||
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
||||||
|
|
Loading…
Add table
Reference in a new issue