From 0507f26b13fc9d4091e8c79df7c99176cb8ef21c Mon Sep 17 00:00:00 2001 From: Gregg Date: Sat, 16 Apr 2022 15:21:13 -0500 Subject: [PATCH] Updated "Other Examples" and added SPAN_ACCESSORY() Macro Need to revisit Television sketch - the latest iOS seemed to have disabled the ability to dynamically set visibility of input sources. Checking/Un-Checking the visibility radio buttons either during pairing, or after pairing on the settings screen, seems to be ignored by the Home App (the same input sources are shown in the selector regardless of any changes made). However, dynamically changing the name of an input source seems to work fine. --- .../CustomService/CustomService.ino | 14 +---- Other Examples/Pixel/Pixel.ino | 54 +++---------------- .../RemoteControl/RemoteControl.ino | 27 +++++++++- Other Examples/ServoControl/DEV_Identify.h | 38 ------------- Other Examples/ServoControl/ServoControl.ino | 12 ++--- Other Examples/TableLamp/TableLamp.ino | 43 ++++++++++----- Other Examples/Television/Television.ino | 12 +---- src/Span.h | 5 ++ 8 files changed, 76 insertions(+), 129 deletions(-) delete mode 100644 Other Examples/ServoControl/DEV_Identify.h diff --git a/Other Examples/CustomService/CustomService.ino b/Other Examples/CustomService/CustomService.ino index 2551e9b..ec2f15d 100644 --- a/Other Examples/CustomService/CustomService.ino +++ b/Other Examples/CustomService/CustomService.ino @@ -97,19 +97,7 @@ void setup() { homeSpan.begin(Category::Sensors,"Eve Air Pressure"); - new SpanAccessory(); - - new Service::AccessoryInformation(); - new Characteristic::Name("Air Pressure"); - new Characteristic::Manufacturer("HomeSpan"); - new Characteristic::SerialNumber("123-ABC"); - new Characteristic::Model("Simulated Sensor"); - new Characteristic::FirmwareRevision("1.0"); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); - + SPAN_ACCESSORY(); new PressureSensor(); } diff --git a/Other Examples/Pixel/Pixel.ino b/Other Examples/Pixel/Pixel.ino index 8f121d7..5723de4 100644 --- a/Other Examples/Pixel/Pixel.ino +++ b/Other Examples/Pixel/Pixel.ino @@ -59,7 +59,7 @@ #define DEVICE_SUFFIX "-C3" #endif - + #include "HomeSpan.h" #include "extras/Pixel.h" // include the HomeSpan Pixel class @@ -182,56 +182,16 @@ void setup() { homeSpan.begin(Category::Lighting,"Pixel LEDS" DEVICE_SUFFIX); - new SpanAccessory(); // create Bridge - new Service::AccessoryInformation(); - new Characteristic::Name("Pixel LEDS" DEVICE_SUFFIX); - new Characteristic::Manufacturer("HomeSpan"); - new Characteristic::SerialNumber("123-ABC"); - new Characteristic::Model("Neo/Dot Pixels"); - new Characteristic::FirmwareRevision("1.0"); - new Characteristic::Identify(); + SPAN_ACCESSORY(); // create Bridge (note this sketch uses the SPAN_ACCESSORY() macro, introduced in v1.5.1 --- see the HomeSpan API Reference for details on this convenience macro) - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); - -///////// - - new SpanAccessory(); - new Service::AccessoryInformation(); - new Characteristic::Name("Neo RGB"); - new Characteristic::Manufacturer("HomeSpan"); - new Characteristic::SerialNumber("123-ABC"); - new Characteristic::Model("8-LED Strand"); - new Characteristic::FirmwareRevision("1.0"); - new Characteristic::Identify(); - + SPAN_ACCESSORY("Neo RGB"); new NeoPixel_RGB(NEOPIXEL_RGB_PIN,8); // create 8-LED NeoPixel RGB Strand with full color control -///////// + SPAN_ACCESSORY("Neo RGBW"); + new NeoPixel_RGBW(NEOPIXEL_RGBW_PIN,60); // create 60-LED NeoPixel RGBW Strand with simulated color temperature control - new SpanAccessory(); - new Service::AccessoryInformation(); - new Characteristic::Name("Neo RGBW"); - new Characteristic::Manufacturer("HomeSpan"); - new Characteristic::SerialNumber("123-ABC"); - new Characteristic::Model("60-LED Strand"); - new Characteristic::FirmwareRevision("1.0"); - new Characteristic::Identify(); - - new NeoPixel_RGBW(NEOPIXEL_RGBW_PIN,60); // create 60-LED NeoPixel RGBW Strand with simulated color temperature control - -///////// - - new SpanAccessory(); - new Service::AccessoryInformation(); - new Characteristic::Name("Dot RGB"); - new Characteristic::Manufacturer("HomeSpan"); - new Characteristic::SerialNumber("123-ABC"); - new Characteristic::Model("30-LED Strand"); - new Characteristic::FirmwareRevision("1.0"); - new Characteristic::Identify(); - - new DotStar_RGB(DOTSTAR_DATA_PIN,DOTSTAR_CLOCK_PIN,30); // create 30-LED DotStar RGB Strand displaying a spectrum of colors and using the current-limiting feature of DotStars to create flicker-free dimming + SPAN_ACCESSORY("Dot RGB"); + new DotStar_RGB(DOTSTAR_DATA_PIN,DOTSTAR_CLOCK_PIN,30); // create 30-LED DotStar RGB Strand displaying a spectrum of colors and using the current-limiting feature of DotStars to create flicker-free dimming } diff --git a/Other Examples/RemoteControl/RemoteControl.ino b/Other Examples/RemoteControl/RemoteControl.ino index eca7bc2..bc752ef 100644 --- a/Other Examples/RemoteControl/RemoteControl.ino +++ b/Other Examples/RemoteControl/RemoteControl.ino @@ -1,4 +1,29 @@ -/* HomeSpan Remote Control Example */ +/********************************************************************************* + * MIT License + * + * Copyright (c) 2020-2022 Gregg E. Berman + * + * https://github.com/HomeSpan/HomeSpan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + ********************************************************************************/ #include "HomeSpan.h" // include the HomeSpan library #include "extras/RFControl.h" // include RF Control Library diff --git a/Other Examples/ServoControl/DEV_Identify.h b/Other Examples/ServoControl/DEV_Identify.h deleted file mode 100644 index b8d21d6..0000000 --- a/Other Examples/ServoControl/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(const char *name, const char *manu, const char *sn, const char *model, const char *version, int nBlinks) : Service::AccessoryInformation(){ - - 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 LED - - pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output - } - - boolean update(){ - - for(int i=0;i