diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 5d76818..40d3dc8 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -301,6 +301,7 @@ class Span{ } void setStatusDevice(Blinkable *sDev){statusDevice=sDev;} + void refreshStatusDevice(){if(statusLED)statusLED->refresh();} void setApSSID(const char *ssid){network.apSSID=ssid;} // sets Access Point SSID void setApPassword(const char *pwd){network.apPassword=pwd;} // sets Access Point Password diff --git a/src/src/extras/Blinker.cpp b/src/src/extras/Blinker.cpp index e97ee34..ede2a26 100644 --- a/src/src/extras/Blinker.cpp +++ b/src/src/extras/Blinker.cpp @@ -78,6 +78,7 @@ void Blinker::start(int period, float dutyCycle, int nBlinks, int delayTime){ pauseTime=millis(); isPaused=false; + status=STATUS::BLINKING; } ////////////////////////////////////// @@ -93,6 +94,7 @@ void Blinker::stop(){ } isPaused=true; + status=STATUS::OFF; } ////////////////////////////////////// @@ -107,6 +109,7 @@ void Blinker::on(){ pauseTime=millis(); isPaused=false; + status=STATUS::ON; } ////////////////////////////////////// @@ -118,6 +121,7 @@ void Blinker::off(){ stop(); led->off(); + status=STATUS::OFF; } ////////////////////////////////////// diff --git a/src/src/extras/Blinker.h b/src/src/extras/Blinker.h index 633bc19..1484a86 100644 --- a/src/src/extras/Blinker.h +++ b/src/src/extras/Blinker.h @@ -47,6 +47,8 @@ class Blinkable { //////////////////////////////// class Blinker { + + enum STATUS {OFF, BLINKING, ON}; TaskHandle_t blinkHandle = NULL; Blinkable *led; @@ -55,6 +57,7 @@ class Blinker { int onTime; int offTime; int delayTime; + STATUS status=STATUS::OFF; unsigned long pauseDuration; unsigned long pauseTime; @@ -102,6 +105,10 @@ class Blinker { // Stops current blinking pattern and turns off LED + void refresh(){if(status==STATUS::ON)on();} + +// Refreshes LED color by turning device ON if status=ON (if status=BLINKING, new color is automatically used at next blink) + void check(); // Optional check to see if LED output should be paused (check is bypassed if pauseDuration=0)