Added optional triggerType to homeSpan.setControlPin()
Default is SpanButton::TRIGGER_ON_LOW. Follows same options as SpanButton, including the ability to provide your own triggerType function of form: boolean f(int pin)
This commit is contained in:
parent
3c3e5c21ea
commit
260be21462
|
|
@ -298,19 +298,23 @@ class Span{
|
||||||
boolean updateDatabase(boolean updateMDNS=true); // updates HAP Configuration Number and Loop vector; if updateMDNS=true and config number has changed, re-broadcasts MDNS 'c#' record; returns true if config number changed
|
boolean updateDatabase(boolean updateMDNS=true); // updates HAP Configuration Number and Loop vector; if updateMDNS=true and config number has changed, re-broadcasts MDNS 'c#' record; returns true if config number changed
|
||||||
boolean deleteAccessory(uint32_t aid); // deletes Accessory with matching aid; returns true if found, else returns false
|
boolean deleteAccessory(uint32_t aid); // deletes Accessory with matching aid; returns true if found, else returns false
|
||||||
|
|
||||||
Span& setControlPin(uint8_t pin){controlButton=new PushButton(pin);return(*this);} // sets Control Pin
|
Span& setControlPin(uint8_t pin, PushButton::triggerType_t triggerType=PushButton::TRIGGER_ON_LOW){ // sets Control Pin, with optional trigger type
|
||||||
Span& setStatusPin(uint8_t pin){statusDevice=new GenericLED(pin);return(*this);} // sets Status Device to a simple LED on specified pin
|
controlButton=new PushButton(pin, triggerType);
|
||||||
Span& setStatusAutoOff(uint16_t duration){autoOffLED=duration;return(*this);} // sets Status LED auto off (seconds)
|
return(*this);
|
||||||
int getStatusPin(){return(statusLED->getPin());} // get Status Pin (getPin will return -1 if underlying statusDevice is undefined)
|
}
|
||||||
|
|
||||||
int getControlPin(){return(controlButton?controlButton->getPin():-1);} // get Control Pin (returns -1 if undefined)
|
int getControlPin(){return(controlButton?controlButton->getPin():-1);} // get Control Pin (returns -1 if undefined)
|
||||||
|
|
||||||
|
Span& setStatusPin(uint8_t pin){statusDevice=new GenericLED(pin);return(*this);} // sets Status Device to a simple LED on specified pin
|
||||||
Span& setStatusPixel(uint8_t pin,float h=0,float s=100,float v=100){ // sets Status Device to an RGB Pixel on specified pin
|
Span& setStatusPixel(uint8_t pin,float h=0,float s=100,float v=100){ // sets Status Device to an RGB Pixel on specified pin
|
||||||
statusDevice=((new Pixel(pin))->setOnColor(Pixel::HSV(h,s,v)));
|
statusDevice=((new Pixel(pin))->setOnColor(Pixel::HSV(h,s,v)));
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
Span& setStatusDevice(Blinkable *sDev){statusDevice=sDev;return(*this);} // sets Status Device to a generic Blinkable object
|
||||||
|
|
||||||
Span& setStatusDevice(Blinkable *sDev){statusDevice=sDev;return(*this);}
|
Span& setStatusAutoOff(uint16_t duration){autoOffLED=duration;return(*this);} // sets Status LED auto off (seconds)
|
||||||
void refreshStatusDevice(){if(statusLED)statusLED->refresh();}
|
int getStatusPin(){return(statusLED->getPin());} // get Status Pin (returns -1 if undefined)
|
||||||
|
void refreshStatusDevice(){if(statusLED)statusLED->refresh();} // refreshes state of Status LED
|
||||||
|
|
||||||
Span& setApSSID(const char *ssid){network.apSSID=ssid;return(*this);} // sets Access Point SSID
|
Span& setApSSID(const char *ssid){network.apSSID=ssid;return(*this);} // sets Access Point SSID
|
||||||
Span& setApPassword(const char *pwd){network.apPassword=pwd;return(*this);} // sets Access Point Password
|
Span& setApPassword(const char *pwd){network.apPassword=pwd;return(*this);} // sets Access Point Password
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ typedef uint16_t touch_value_t;
|
||||||
|
|
||||||
class PushButton{
|
class PushButton{
|
||||||
|
|
||||||
|
friend class Span;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
int toggleStatus;
|
int toggleStatus;
|
||||||
boolean doubleCheck;
|
boolean doubleCheck;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
homeSpan.setLogLevel(1);
|
homeSpan.setLogLevel(1).setControlPin(21,SpanButton::TRIGGER_ON_HIGH).setStatusPin(13);
|
||||||
homeSpan.enableWebLog(50,"pool.ntp.org","UTC");
|
homeSpan.enableWebLog(50,"pool.ntp.org","UTC");
|
||||||
|
|
||||||
homeSpan.begin(Category::Lighting,"HomeSpan Max");
|
homeSpan.begin(Category::Lighting,"HomeSpan Max");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue