mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-12-15 23:34:07 +00:00
Merge branch 'main' into HendrikRauh/issue33
This commit is contained in:
commit
be774c028b
4 changed files with 77 additions and 1 deletions
39
src/main.cpp
39
src/main.cpp
|
|
@ -105,6 +105,36 @@ float getTemperature()
|
|||
temp_sensor_read_celsius(&tempC);
|
||||
return tempC;
|
||||
}
|
||||
|
||||
void onButtonPress()
|
||||
{
|
||||
config.begin("dmx", true);
|
||||
ButtonAction action = static_cast<ButtonAction>(config.getUInt("button-action", DEFAULT_BUTTON_ACTION));
|
||||
config.end();
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ResetConfig:
|
||||
config.begin("dmx", false);
|
||||
config.clear();
|
||||
config.end();
|
||||
|
||||
ESP.restart();
|
||||
break;
|
||||
|
||||
case Restart:
|
||||
config.begin("dmx", false);
|
||||
config.putBool("restart-via-btn", true);
|
||||
config.end();
|
||||
|
||||
ESP.restart();
|
||||
break;
|
||||
case None:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
|
|
@ -133,12 +163,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();
|
||||
|
|
@ -156,8 +187,14 @@ void setup()
|
|||
}
|
||||
}
|
||||
|
||||
config.begin("dmx", false);
|
||||
config.putBool("restart-via-btn", false);
|
||||
config.end();
|
||||
|
||||
// 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