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);}
void on() override {digitalWrite(pin,LOW);}
void off() override {digitalWrite(pin,HIGH);}
int getPin() override {return(pin);}
invertedLED(int pin) : pin{pin} { // constructor that initializes the pin parameter
pinMode(pin,OUTPUT); // set the pin to OUTPUT
digitalWrite(pin,HIGH); // set pin HIGH (which is off for an inverted LED)
}
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() {
@ -67,7 +72,7 @@ void setup() {
// homeSpan.setSerialInputDisable(true);
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.begin(Category::Lighting,"HomeSpan LED");