Update src.ino

This commit is contained in:
Gregg 2023-07-03 07:05:51 -05:00
parent 0997c2561b
commit 62b1e9bd35
1 changed files with 12 additions and 7 deletions

View File

@ -47,16 +47,21 @@ struct LED_Service : Service::LightBulb {
////////////////////////////////////// //////////////////////////////////////
struct reverseLED : Blinkable { struct invertedLED : Blinkable { // create a child class derived from Blinkable
int pin; int pin; // variable to store the pin number
reverseLED(int pin) : pin{pin} {pinMode(pin,OUTPUT);digitalWrite(pin,1);} invertedLED(int pin) : pin{pin} { // constructor that initializes the pin parameter
void on() override {digitalWrite(pin,LOW);} pinMode(pin,OUTPUT); // set the pin to OUTPUT
void off() override {digitalWrite(pin,HIGH);} digitalWrite(pin,HIGH); // set pin HIGH (which is off for an inverted LED)
int getPin() override {return(pin);} }
void on() override { digitalWrite(pin,LOW); } // required function on() - sets pin LOW
void off() override { digitalWrite(pin,HIGH); } // required function off() - sets pin HIGH
int getPin() override { return(pin); } // required function getPin() - returns pin number
}; };
////////////////////////////////////// //////////////////////////////////////
void setup() { void setup() {
@ -67,7 +72,7 @@ void setup() {
// homeSpan.setSerialInputDisable(true); // homeSpan.setSerialInputDisable(true);
homeSpan.enableOTA(); homeSpan.enableOTA();
homeSpan.setStatusDevice(new reverseLED(13)); homeSpan.setStatusDevice(new invertedLED(13)); // set Status LED to be a new Blinkable device attached to pin 13
homeSpan.setStatusAutoOff(30); homeSpan.setStatusAutoOff(30);
homeSpan.begin(Category::Lighting,"HomeSpan LED"); homeSpan.begin(Category::Lighting,"HomeSpan LED");