mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-18 21:55:34 +00:00
made the led work
in a rather bad way...
This commit is contained in:
parent
1dc5587893
commit
4ebefde13f
1 changed files with 30 additions and 12 deletions
24
src/main.cpp
24
src/main.cpp
|
@ -37,6 +37,7 @@ byte dmx2_data[DMX_PACKET_SIZE];
|
|||
|
||||
uint8_t brightness_led = 20;
|
||||
bool led_on = true;
|
||||
double lastMills = 0;
|
||||
|
||||
// Ethernet stuff
|
||||
#define ETH_SCK 36
|
||||
|
@ -102,6 +103,9 @@ void updateTimer(int interval_ms)
|
|||
|
||||
void updateLed() // TODO: callback for timer
|
||||
{
|
||||
if (millis() - lastMills >= led_config.interval_ms)
|
||||
{
|
||||
lastMills = millis();
|
||||
led_config = getBlinkingConfig(status);
|
||||
if (led_config.is_blinking)
|
||||
{
|
||||
|
@ -114,6 +118,7 @@ void updateLed() // TODO: callback for timer
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setStatus(Status newStatus)
|
||||
{
|
||||
|
@ -155,6 +160,9 @@ void onButtonPress()
|
|||
void setup()
|
||||
{
|
||||
setStatus(Status::Starting);
|
||||
pinMode(PIN_LED, OUTPUT);
|
||||
updateLed();
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
// Get ETH mac
|
||||
|
@ -182,7 +190,7 @@ void setup()
|
|||
brightness_led = config.getUInt("led-brightness", DEFAULT_LED_BRIGHTNESS);
|
||||
bool restartViaButton = config.getBool("restart-via-btn", false);
|
||||
config.end();
|
||||
analogWrite(PIN_LED, brightness_led);
|
||||
updateLed();
|
||||
|
||||
// Button
|
||||
pinMode(PIN_BUTTON, INPUT_PULLUP);
|
||||
|
@ -192,6 +200,7 @@ void setup()
|
|||
unsigned long startTime = millis();
|
||||
while (digitalRead(PIN_BUTTON) == LOW && (millis() - startTime <= 3000))
|
||||
{
|
||||
updateLed();
|
||||
}
|
||||
if (digitalRead(PIN_BUTTON) == LOW)
|
||||
{
|
||||
|
@ -200,7 +209,11 @@ void setup()
|
|||
config.clear();
|
||||
config.end();
|
||||
setStatus(Status::Normal);
|
||||
delay(2000);
|
||||
unsigned long startTime = millis();
|
||||
while (millis() - startTime <= 2000)
|
||||
{
|
||||
updateLed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +226,11 @@ void setup()
|
|||
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
||||
|
||||
// wait for serial monitor
|
||||
delay(5000);
|
||||
unsigned long startTime = millis();
|
||||
while (millis() - startTime <= 5000)
|
||||
{
|
||||
updateLed();
|
||||
}
|
||||
Serial.println("Starting DMX-Interface...");
|
||||
|
||||
config.begin("dmx", true);
|
||||
|
@ -494,4 +511,5 @@ void loop()
|
|||
}
|
||||
|
||||
webSocketLoop();
|
||||
updateLed();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue