first commit
This commit is contained in:
54
src/statusled.h
Normal file
54
src/statusled.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
#define LED_PIN LED_BUILTIN
|
||||
|
||||
// Status LED
|
||||
unsigned long lastLedBlink = 0;
|
||||
bool ledState = false;
|
||||
|
||||
|
||||
void updateStatusLED(int blinkPattern) {
|
||||
unsigned long currentTime = millis();
|
||||
|
||||
switch (blinkPattern) {
|
||||
case 0: // Suche Master - Langsames Blinken
|
||||
if (currentTime - lastLedBlink > 1000) {
|
||||
ledState = !ledState;
|
||||
digitalWrite(LED_PIN, ledState);
|
||||
lastLedBlink = currentTime;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // Verbunden - Kurzes Blinken alle 3 Sekunden
|
||||
if (currentTime - lastLedBlink > 3000) {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
lastLedBlink = currentTime;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // Button gedrückt - Schnelles Blinken 3x
|
||||
static int blinkCount = 0;
|
||||
if (currentTime - lastLedBlink > 100) {
|
||||
ledState = !ledState;
|
||||
digitalWrite(LED_PIN, ledState);
|
||||
lastLedBlink = currentTime;
|
||||
blinkCount++;
|
||||
|
||||
if (blinkCount >= 6) { // 3 komplette Blinks
|
||||
blinkCount = 0;
|
||||
blinkPattern = 1; // Zurück zu verbunden
|
||||
}
|
||||
}
|
||||
|
||||
case 3: // Flash bei Empfang - Einmaliges kurzes Blinken
|
||||
{
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user