mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-12-15 23:34:07 +00:00
added button action configuration and handling for reset and restart
This commit is contained in:
parent
5870182507
commit
3aeb8ffe5b
4 changed files with 62 additions and 0 deletions
23
src/main.cpp
23
src/main.cpp
|
|
@ -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...");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue