diff --git a/examples/Tutorials/A-Basic/01-SimpleLightBulb/01-SimpleLightBulb.ino b/examples/01-SimpleLightBulb/01-SimpleLightBulb.ino similarity index 100% rename from examples/Tutorials/A-Basic/01-SimpleLightBulb/01-SimpleLightBulb.ino rename to examples/01-SimpleLightBulb/01-SimpleLightBulb.ino diff --git a/examples/Tutorials/A-Basic/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino b/examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino similarity index 100% rename from examples/Tutorials/A-Basic/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino rename to examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino diff --git a/examples/Tutorials/A-Basic/03-CeilingFanWithLight/03-CeilingFanWithLight.ino b/examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino similarity index 100% rename from examples/Tutorials/A-Basic/03-CeilingFanWithLight/03-CeilingFanWithLight.ino rename to examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino diff --git a/examples/Tutorials/A-Basic/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino b/examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino similarity index 100% rename from examples/Tutorials/A-Basic/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino rename to examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino diff --git a/examples/Tutorials/B-Intermediate/05-WorkingLED/05-WorkingLED.ino b/examples/05-WorkingLED/05-WorkingLED.ino similarity index 100% rename from examples/Tutorials/B-Intermediate/05-WorkingLED/05-WorkingLED.ino rename to examples/05-WorkingLED/05-WorkingLED.ino diff --git a/examples/Tutorials/B-Intermediate/05-WorkingLED/DEV_LED.h b/examples/05-WorkingLED/DEV_LED.h similarity index 100% rename from examples/Tutorials/B-Intermediate/05-WorkingLED/DEV_LED.h rename to examples/05-WorkingLED/DEV_LED.h diff --git a/examples/Tutorials/B-Intermediate/06-DimmableLED/06-DimmableLED.ino b/examples/06-DimmableLED/06-DimmableLED.ino similarity index 100% rename from examples/Tutorials/B-Intermediate/06-DimmableLED/06-DimmableLED.ino rename to examples/06-DimmableLED/06-DimmableLED.ino diff --git a/examples/Tutorials/B-Intermediate/06-DimmableLED/DEV_LED.h b/examples/06-DimmableLED/DEV_LED.h similarity index 100% rename from examples/Tutorials/B-Intermediate/06-DimmableLED/DEV_LED.h rename to examples/06-DimmableLED/DEV_LED.h diff --git a/examples/Tutorials/B-Intermediate/07-IdentifyRoutines/07-IdentifyRoutines.ino b/examples/07-IdentifyRoutines/07-IdentifyRoutines.ino similarity index 100% rename from examples/Tutorials/B-Intermediate/07-IdentifyRoutines/07-IdentifyRoutines.ino rename to examples/07-IdentifyRoutines/07-IdentifyRoutines.ino diff --git a/examples/Tutorials/B-Intermediate/07-IdentifyRoutines/DEV_Identify.h b/examples/07-IdentifyRoutines/DEV_Identify.h similarity index 100% rename from examples/Tutorials/B-Intermediate/07-IdentifyRoutines/DEV_Identify.h rename to examples/07-IdentifyRoutines/DEV_Identify.h diff --git a/examples/Tutorials/B-Intermediate/07-IdentifyRoutines/DEV_LED.h b/examples/07-IdentifyRoutines/DEV_LED.h similarity index 100% rename from examples/Tutorials/B-Intermediate/07-IdentifyRoutines/DEV_LED.h rename to examples/07-IdentifyRoutines/DEV_LED.h diff --git a/examples/Tutorials/C-Advanced/08-Bridges/08-Bridges.ino b/examples/08-Bridges/08-Bridges.ino similarity index 100% rename from examples/Tutorials/C-Advanced/08-Bridges/08-Bridges.ino rename to examples/08-Bridges/08-Bridges.ino diff --git a/examples/Tutorials/C-Advanced/08-Bridges/DEV_Identify.h b/examples/08-Bridges/DEV_Identify.h similarity index 100% rename from examples/Tutorials/C-Advanced/08-Bridges/DEV_Identify.h rename to examples/08-Bridges/DEV_Identify.h diff --git a/examples/Tutorials/C-Advanced/08-Bridges/DEV_LED.h b/examples/08-Bridges/DEV_LED.h similarity index 100% rename from examples/Tutorials/C-Advanced/08-Bridges/DEV_LED.h rename to examples/08-Bridges/DEV_LED.h diff --git a/examples/Tutorials/C-Advanced/09-MessageLogging/09-MessageLogging.ino b/examples/09-MessageLogging/09-MessageLogging.ino similarity index 100% rename from examples/Tutorials/C-Advanced/09-MessageLogging/09-MessageLogging.ino rename to examples/09-MessageLogging/09-MessageLogging.ino diff --git a/examples/Tutorials/C-Advanced/09-MessageLogging/DEV_Identify.h b/examples/09-MessageLogging/DEV_Identify.h similarity index 100% rename from examples/Tutorials/C-Advanced/09-MessageLogging/DEV_Identify.h rename to examples/09-MessageLogging/DEV_Identify.h diff --git a/examples/Tutorials/C-Advanced/09-MessageLogging/DEV_LED.h b/examples/09-MessageLogging/DEV_LED.h similarity index 100% rename from examples/Tutorials/C-Advanced/09-MessageLogging/DEV_LED.h rename to examples/09-MessageLogging/DEV_LED.h diff --git a/examples/Tutorials/C-Advanced/10-RGB_LED/10-RGB_LED.ino b/examples/10-RGB_LED/10-RGB_LED.ino similarity index 100% rename from examples/Tutorials/C-Advanced/10-RGB_LED/10-RGB_LED.ino rename to examples/10-RGB_LED/10-RGB_LED.ino diff --git a/examples/Tutorials/C-Advanced/10-RGB_LED/DEV_Identify.h b/examples/10-RGB_LED/DEV_Identify.h similarity index 100% rename from examples/Tutorials/C-Advanced/10-RGB_LED/DEV_Identify.h rename to examples/10-RGB_LED/DEV_Identify.h diff --git a/examples/Tutorials/C-Advanced/10-RGB_LED/DEV_LED.h b/examples/10-RGB_LED/DEV_LED.h similarity index 100% rename from examples/Tutorials/C-Advanced/10-RGB_LED/DEV_LED.h rename to examples/10-RGB_LED/DEV_LED.h diff --git a/examples/Tutorials/C-Advanced/11-ServiceOptions/11-ServiceOptions.ino b/examples/11-ServiceOptions/11-ServiceOptions.ino similarity index 100% rename from examples/Tutorials/C-Advanced/11-ServiceOptions/11-ServiceOptions.ino rename to examples/11-ServiceOptions/11-ServiceOptions.ino diff --git a/examples/Tutorials/C-Advanced/11-ServiceOptions/DEV_Identify.h b/examples/11-ServiceOptions/DEV_Identify.h similarity index 100% rename from examples/Tutorials/C-Advanced/11-ServiceOptions/DEV_Identify.h rename to examples/11-ServiceOptions/DEV_Identify.h diff --git a/examples/Tutorials/C-Advanced/11-ServiceOptions/DEV_LED.h b/examples/11-ServiceOptions/DEV_LED.h similarity index 100% rename from examples/Tutorials/C-Advanced/11-ServiceOptions/DEV_LED.h rename to examples/11-ServiceOptions/DEV_LED.h diff --git a/examples/Tutorials/D-Expert/12-ServiceLoops/12-ServiceLoops.ino b/examples/12-ServiceLoops/12-ServiceLoops.ino similarity index 100% rename from examples/Tutorials/D-Expert/12-ServiceLoops/12-ServiceLoops.ino rename to examples/12-ServiceLoops/12-ServiceLoops.ino diff --git a/examples/Tutorials/D-Expert/12-ServiceLoops/DEV_Identify.h b/examples/12-ServiceLoops/DEV_Identify.h similarity index 100% rename from examples/Tutorials/D-Expert/12-ServiceLoops/DEV_Identify.h rename to examples/12-ServiceLoops/DEV_Identify.h diff --git a/examples/Tutorials/D-Expert/12-ServiceLoops/DEV_Sensors.h b/examples/12-ServiceLoops/DEV_Sensors.h similarity index 100% rename from examples/Tutorials/D-Expert/12-ServiceLoops/DEV_Sensors.h rename to examples/12-ServiceLoops/DEV_Sensors.h diff --git a/examples/Tutorials/D-Expert/13-TargetStates/13-TargetStates.ino b/examples/13-TargetStates/13-TargetStates.ino similarity index 100% rename from examples/Tutorials/D-Expert/13-TargetStates/13-TargetStates.ino rename to examples/13-TargetStates/13-TargetStates.ino diff --git a/examples/Tutorials/D-Expert/13-TargetStates/DEV_DoorsWindows.h b/examples/13-TargetStates/DEV_DoorsWindows.h similarity index 100% rename from examples/Tutorials/D-Expert/13-TargetStates/DEV_DoorsWindows.h rename to examples/13-TargetStates/DEV_DoorsWindows.h diff --git a/examples/Tutorials/D-Expert/13-TargetStates/DEV_Identify.h b/examples/13-TargetStates/DEV_Identify.h similarity index 100% rename from examples/Tutorials/D-Expert/13-TargetStates/DEV_Identify.h rename to examples/13-TargetStates/DEV_Identify.h diff --git a/examples/Tutorials/D-Expert/14-EmulatedPushButtons/14-EmulatedPushButtons.ino b/examples/14-EmulatedPushButtons/14-EmulatedPushButtons.ino similarity index 100% rename from examples/Tutorials/D-Expert/14-EmulatedPushButtons/14-EmulatedPushButtons.ino rename to examples/14-EmulatedPushButtons/14-EmulatedPushButtons.ino diff --git a/examples/Tutorials/D-Expert/14-EmulatedPushButtons/DEV_Blinker.h b/examples/14-EmulatedPushButtons/DEV_Blinker.h similarity index 100% rename from examples/Tutorials/D-Expert/14-EmulatedPushButtons/DEV_Blinker.h rename to examples/14-EmulatedPushButtons/DEV_Blinker.h diff --git a/examples/Tutorials/D-Expert/14-EmulatedPushButtons/DEV_Identify.h b/examples/14-EmulatedPushButtons/DEV_Identify.h similarity index 100% rename from examples/Tutorials/D-Expert/14-EmulatedPushButtons/DEV_Identify.h rename to examples/14-EmulatedPushButtons/DEV_Identify.h diff --git a/examples/Tutorials/D-Expert/15-RealPushButtons/15-RealPushButtons.ino b/examples/15-RealPushButtons/15-RealPushButtons.ino similarity index 100% rename from examples/Tutorials/D-Expert/15-RealPushButtons/15-RealPushButtons.ino rename to examples/15-RealPushButtons/15-RealPushButtons.ino diff --git a/examples/Tutorials/D-Expert/15-RealPushButtons/DEV_Identify.h b/examples/15-RealPushButtons/DEV_Identify.h similarity index 100% rename from examples/Tutorials/D-Expert/15-RealPushButtons/DEV_Identify.h rename to examples/15-RealPushButtons/DEV_Identify.h diff --git a/examples/Tutorials/D-Expert/15-RealPushButtons/DEV_LED.h b/examples/15-RealPushButtons/DEV_LED.h similarity index 100% rename from examples/Tutorials/D-Expert/15-RealPushButtons/DEV_LED.h rename to examples/15-RealPushButtons/DEV_LED.h diff --git a/examples/ZephyrHood/DEV_Identify.h b/examples/ZephyrHood/DEV_Identify.h deleted file mode 100644 index 17f7638..0000000 --- a/examples/ZephyrHood/DEV_Identify.h +++ /dev/null @@ -1,38 +0,0 @@ - -////////////////////////////////// -// DEVICE-SPECIFIC SERVICES // -////////////////////////////////// - -struct DEV_Identify : Service::AccessoryInformation { - - int nBlinks; // number of times to blink built-in LED in identify routine - SpanCharacteristic *identify; // reference to the Identify Characteristic - - DEV_Identify(char *name, char *manu, char *sn, char *model, char *version, int nBlinks, ServiceType sType=ServiceType::Regular) : Service::AccessoryInformation(sType){ - - new Characteristic::Name(name); // create all the required Characteristics with values set based on above arguments - new Characteristic::Manufacturer(manu); - new Characteristic::SerialNumber(sn); - new Characteristic::Model(model); - new Characteristic::FirmwareRevision(version); - identify=new Characteristic::Identify(); // store a reference to the Identify Characteristic for use below - - this->nBlinks=nBlinks; // store the number of times to blink the built-in LED - - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output - } - - StatusCode update(){ - - for(int i=0;icode=code; - this->buttonPin=buttonPin; - - Serial.print("Configuring Zephyr Vent Hood Light 433MHz Transmitter with code: "); - Serial.print(code,HEX); - Serial.print("\n"); - - new SpanButton(buttonPin); - } - - StatusCode update(){ - - if(power->getNewVal()){ - LOG1("Activating Zephyr Vent Hood Light\n"); - transmitZephyr(code); - } - - return(StatusCode::OK); - - } // update - - void loop(){ - - if(power->getVal() && power->timeVal()>500){ // check that power is true, and that time since last modification is greater than 3 seconds - LOG1("Resetting Zephyr Vent Hood Light Control\n"); // log message - power->setVal(false); // set power to false - } - - } // loop - - void button(int pin, boolean isLong) override { - - LOG1("Activating Zephyr Vent Hood Light\n"); - transmitZephyr(code); - power->setVal(true); - - } // button - -}; - -////////////////////////////////// - -struct DEV_ZephyrFan : Service::Fan { - - uint32_t code; - SpanCharacteristic *power; - int buttonPin; - - DEV_ZephyrFan(uint32_t code, int buttonPin, ServiceType mod=ServiceType::Regular) : Service::Fan(mod){ - - power=new Characteristic::Active(); - new Characteristic::Name("Vent Fan"); - this->code=code; - this->buttonPin=buttonPin; - - Serial.print("Configuring Zephyr Vent Hood Fan 433MHz Transmitter with code: "); - Serial.print(code,HEX); - Serial.print("\n"); - - new SpanButton(buttonPin); - } - - StatusCode update(){ - - if(power->getNewVal()){ - LOG1("Activating Zephyr Vent Hood Fan\n"); - transmitZephyr(code); - } - - return(StatusCode::OK); - - } // update - - void loop(){ - - if(power->getVal() && power->timeVal()>500){ // check that power is true, and that time since last modification is greater than 3 seconds - LOG1("Resetting Zephyr Vent Hood Fan Control\n"); // log message - power->setVal(false); // set power to false - } - - } // loop - - void button(int pin, boolean isLong) override { - - LOG1("Activating Zephyr Vent Hood Fan\n"); - transmitZephyr(code); - power->setVal(true); - - } // button - -}; - -////////////////////////////////// - -struct DEV_ZephyrPower : Service::Switch { - - uint32_t code; - SpanCharacteristic *power; - int buttonPin; - - DEV_ZephyrPower(uint32_t code, int buttonPin, ServiceType mod=ServiceType::Regular) : Service::Switch(mod){ - - power=new Characteristic::On(); - new Characteristic::Name("Vent Power"); - this->code=code; - this->buttonPin=buttonPin; - - Serial.print("Configuring Zephyr Vent Hood Power 433MHz Transmitter with code: "); - Serial.print(code,HEX); - Serial.print("\n"); - new SpanButton(buttonPin); - - } - - StatusCode update(){ - - if(power->getNewVal()){ - LOG1("Activating Zephyr Vent Hood Power\n"); - transmitZephyr(code); - } - - return(StatusCode::OK); - - } // update - - void loop(){ - - if(power->getVal() && power->timeVal()>500){ // check that power is true, and that time since last modification is greater than 3 seconds - LOG1("Resetting Zephyr Vent Hood Power Control\n"); // log message - power->setVal(false); // set power to false - } - - } // loop - - void button(int pin, boolean isLong) override { - - LOG1("Activating Zephyr Vent Hood Power\n"); - transmitZephyr(code); - power->setVal(true); - - } // button - -}; - -////////////////////////////////// - -void transmitZephyr(uint32_t code){ - char c[32]; - sprintf(c,"Transmitting code: %lx\n",code); - LOG1(c); - - RF433.clear(); - - for(int b=19;b>0;b--){ - if(code&(1<nBlinks=nBlinks; // store the number of times to blink the built-in LED - - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output - } - - StatusCode update(){ - - for(int i=0;icode=code; - this->buttonPin=buttonPin; - - Serial.print("Configuring Zephyr Vent Hood Light 433MHz Transmitter with code: "); - Serial.print(code,HEX); - Serial.print("\n"); - - new SpanButton(buttonPin); - } - - StatusCode update(){ - - LOG1("Zephyr Vent Hood Light Power: "); - LOG1(power->getVal()); - if(power->updated()){ - LOG1("->"); - LOG1(power->getNewVal()); - } - LOG1(" Level: "); - LOG1(level->getVal()); - if(level->updated()){ - LOG1("->"); - LOG1(level->getNewVal()); - } - LOG1("\n"); - - int oldState=power->getVal()*(4-level->getVal()); - int newState=(power->updated()?power->getNewVal():power->getVal()) - *(4-(level->updated()?level->getNewVal():level->getVal())); - - while(newState!=oldState){ - transmitZephyr(code); - delay(200); - oldState=(oldState+1)%4; - } - - return(StatusCode::OK); - - } // update - - void button(int pin, boolean isLong) override { - - LOG1("Zephyr Vent Hood Light Short Button Press\n"); - transmitZephyr(code); - - int newLevel=level->getVal()-1; - if(newLevel<0) - newLevel=3; - level->setVal(newLevel); - power->setVal(newLevel>0); - - } // button - - void loop(){ - - if(resetLight){ - power->setVal(false); - level->setVal(0); - resetLight=false; - } - - } // loop - -}; - -////////////////////////////////// - -struct DEV_ZephyrFan : Service::Fan { - - uint32_t fanCode; - uint32_t powerCode; - SpanCharacteristic *power; - int fanPin; - - DEV_ZephyrFan(uint32_t fanCode, uint32_t powerCode, int fanPin, ServiceType mod=ServiceType::Regular) : Service::Fan(mod){ - - power=new Characteristic::Active(); - new Characteristic::Name("Vent Fan"); - this->fanCode=fanCode; - this->powerCode=powerCode; - this->fanPin=fanPin; - - Serial.print("Configuring Zephyr Vent Hood Fan 433MHz Transmitter with fan code: "); - Serial.print(fanCode,HEX); - Serial.print(" power code: "); - Serial.print(powerCode,HEX); - Serial.print("\n"); - - new SpanButton(fanPin); - } - - StatusCode update(){ - - if(power->getNewVal()){ // it's okay to repease ON commands - this just cycles through fan speed - LOG1("Zephyr Vent Hood Fan: Power On\n"); - transmitZephyr(fanCode); - } else - if(power->getVal()){ // only transmit power code if we know power is really on, else this OFF command will turn fan ON! - LOG1("Zephyr Vent Hood Fan: Power Off\n"); - transmitZephyr(powerCode); - resetLight=true; - } - - return(StatusCode::OK); - - } // update - - void button(int pin, boolean isLong) override { - - if(!isLong){ - LOG1("Zephyr Vent Hood Fan Short Button Press: Speed Change\n"); - transmitZephyr(fanCode); - if(!power->getVal()) - power->setVal(true); - } else - if(power->getVal()){ - LOG1("Zephyr Vent Hood Fan Long Button Press: Power Off\n"); - transmitZephyr(powerCode); - power->setVal(false); - resetLight=true; - } else { - LOG1("Zephyr Vent Hood Fan Long Button Press: Power is already off!\n"); - resetLight=true; - } - - } // button - -}; - -////////////////////////////////// - -void transmitZephyr(uint32_t code){ - char c[32]; - sprintf(c,"Transmitting code: %lx\n",code); - LOG1(c); - - RF433.clear(); - - for(int b=19;b>0;b--){ - if(code&(1<nBlinks=nBlinks; // store the number of times to blink the built-in LED - - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output - } - - StatusCode update(){ - - for(int i=0;ilightCode=lightCode; - this->lightPin=lightPin; - - Serial.print("Configuring Zephyr Vent Hood Light 433MHz Transmitter with code: "); - Serial.print(lightCode,HEX); - Serial.print("\n"); - - new SpanButton(lightPin); - } - - StatusCode update(){ - - if(!power->getVal() && power->getNewVal()){ // only transmit code to turn on light if we know power is really off - LOG1("Zephyr Vent Hood Light: Power On\n"); - transmitZephyr(lightCode); - state=3; // light always turns on in brightest setting - } else - - if(!power->getNewVal()){ // send light code until state=0 - LOG1("Zephyr Vent Hood Light: Power Off\n"); - while(state){ - transmitZephyr(lightCode); - state--; - } - } - - return(StatusCode::OK); - - } // update - - void button(int pin, boolean isLong) override { - - LOG1("Zephyr Vent Hood Light Short Button Press\n"); - transmitZephyr(lightCode); - - state--; // decrement state - - if(state==0){ // if reached zero, set power to OFF - power->setVal(false); - } else - - if(state==-1){ // if state was already zero, reset to 3 and set power to ON - state=3; - power->setVal(true); - } - - } // button - - void loop(){ - - if(resetLight){ - power->setVal(false); - state=0; - resetLight=false; - } - - } // loop - -}; - -////////////////////////////////// - -struct DEV_ZephyrFan : Service::Fan { - - uint32_t fanCode; - uint32_t powerCode; - SpanCharacteristic *power; - int fanPin; - - DEV_ZephyrFan(uint32_t fanCode, uint32_t powerCode, int fanPin, ServiceType mod=ServiceType::Regular) : Service::Fan(mod){ - - power=new Characteristic::Active(); - new Characteristic::Name("Vent Fan"); - this->fanCode=fanCode; - this->powerCode=powerCode; - this->fanPin=fanPin; - - Serial.print("Configuring Zephyr Vent Hood Fan 433MHz Transmitter with fan code: "); - Serial.print(fanCode,HEX); - Serial.print(" power code: "); - Serial.print(powerCode,HEX); - Serial.print("\n"); - - new SpanButton(fanPin); - } - - StatusCode update(){ - - if(power->getNewVal()){ // it's okay to repeat ON commands - this just cycles through fan speed - LOG1("Zephyr Vent Hood Fan: Power On\n"); - transmitZephyr(fanCode); - } else - - if(power->getVal()){ // only transmit power code if we know power is really on, else this OFF command will turn everything ON! - LOG1("Zephyr Vent Hood Fan: Power Off\n"); - transmitZephyr(powerCode); - resetLight=true; - } - - return(StatusCode::OK); - - } // update - - void button(int pin, boolean isLong) override { - - if(!isLong){ - LOG1("Zephyr Vent Hood Fan Short Button Press: Speed Change\n"); - transmitZephyr(fanCode); - if(!power->getVal()) - power->setVal(true); - } else - - if(power->getVal()){ - LOG1("Zephyr Vent Hood Fan Long Button Press: Power Off\n"); - transmitZephyr(powerCode); - power->setVal(false); - resetLight=true; - } else { - - LOG1("Zephyr Vent Hood Fan Long Button Press: Power is already off!\n"); - resetLight=true; - } - - } // button - -}; - -////////////////////////////////// - -void transmitZephyr(uint32_t code){ - char c[32]; - sprintf(c,"Transmitting code: %lx\n",code); - LOG1(c); - - RF433.clear(); - - for(int b=19;b>0;b--){ - if(code&(1<