Added homeSpan.refreshStatusDevice()
Provides for additional control over Status LED when a generic device has been used. If the color of the device is changed, the change will only take effect when the LED is next turned on. If the LED is blinking, the color changes upon the next blink. But if the LED is ON, there is no next blink and color will not change. This method check the status of the LED, and if it is ON, is calls the on() function again, which will result in an update of the color. The method does nothing if the LED is OFF or BLINKING.
This commit is contained in:
parent
9ef9a590da
commit
a8271c8724
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue