Update src.ino
This commit is contained in:
parent
2579d5673a
commit
d5eb2ceeb8
25
src/src.ino
25
src/src.ino
|
|
@ -30,35 +30,23 @@
|
||||||
struct LED_Service : Service::LightBulb {
|
struct LED_Service : Service::LightBulb {
|
||||||
|
|
||||||
int ledPin;
|
int ledPin;
|
||||||
boolean oldPower=false;
|
|
||||||
SpanCharacteristic *power;
|
SpanCharacteristic *power;
|
||||||
|
|
||||||
LED_Service(int ledPin) : Service::LightBulb(){
|
LED_Service(int ledPin) : Service::LightBulb(){
|
||||||
|
|
||||||
power=new Characteristic::On();
|
power=new Characteristic::On();
|
||||||
this->ledPin=ledPin;
|
this->ledPin=ledPin;
|
||||||
pinMode(ledPin,OUTPUT);
|
pinMode(ledPin,OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update(){
|
boolean update(){
|
||||||
|
|
||||||
digitalWrite(ledPin,power->getNewVal());
|
digitalWrite(ledPin,power->getNewVal());
|
||||||
oldPower=power->getNewVal();
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void loop(){
|
|
||||||
// if(power->getVal()!=oldPower){
|
|
||||||
// oldPower=!oldPower;
|
|
||||||
// Serial.printf("Power was manually changed to %s\n",oldPower?"ON":"OFF");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
boolean oldPower=false;
|
|
||||||
LED_Service *pLed;
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
|
@ -71,22 +59,13 @@ void setup() {
|
||||||
new SpanAccessory();
|
new SpanAccessory();
|
||||||
new Service::AccessoryInformation();
|
new Service::AccessoryInformation();
|
||||||
new Characteristic::Identify();
|
new Characteristic::Identify();
|
||||||
pLed=new LED_Service(13);
|
new LED_Service(13);
|
||||||
|
|
||||||
homeSpan.autoPoll(8192,10,1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
|
homeSpan.poll();
|
||||||
// homeSpan.poll();
|
|
||||||
|
|
||||||
while(pLed->power->getVal()!=oldPower){
|
|
||||||
oldPower=pLed->power->getVal();
|
|
||||||
Serial.printf("Power was manually changed to %s\n",oldPower?"ON":"OFF");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue