added button action configuration and handling for reset and restart

This commit is contained in:
RaffaelW 2024-12-21 21:28:35 +01:00
parent 5870182507
commit 3aeb8ffe5b
4 changed files with 62 additions and 0 deletions

View file

@ -87,6 +87,27 @@ void ledBlink(int ms)
}
}
void onButtonPress()
{
ButtonAction action = static_cast<ButtonAction>(config.getUInt("button-action", DEFAULT_BUTTON_ACTION));
Serial.print("Button pressed, action: ");
Serial.println(action);
switch (action)
{
case ResetConfig:
config.begin("dmx", false);
config.clear();
config.end();
ESP.restart();
break;
case Restart:
ESP.restart();
break;
}
}
void setup()
{
Serial.begin(9600);
@ -122,6 +143,8 @@ void setup()
ledBlink(500);
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
// wait for serial monitor
delay(5000);
Serial.println("Starting DMX-Interface...");