From c5a0f061ce948794d60b3b3d589724a14ec7bb58 Mon Sep 17 00:00:00 2001 From: Gregg Date: Thu, 8 Feb 2024 07:39:03 -0600 Subject: [PATCH] Removed #include "extras/PwmPin.h" from all Tutorial Examples Since PwmPin.h is already included in HomeSpan.h, there is no reason to separately include it in user sketches. --- examples/06-DimmableLED/06-DimmableLED.ino | 11 +++++------ examples/06-DimmableLED/DEV_LED.h | 2 -- examples/07-AccessoryNames/DEV_LED.h | 2 -- examples/08-Bridges/DEV_LED.h | 2 -- examples/09-MessageLogging/DEV_LED.h | 2 -- examples/10-RGB_LED/DEV_LED.h | 4 ---- examples/15-RealPushButtons/DEV_LED.h | 4 ---- examples/18-SavingStatus/DEV_LED.h | 4 ---- src/HomeSpan.h | 6 ++++-- src/src/extras/StepperControl.h | 5 +++-- src/src/extras/Stepper_A3967.h | 2 ++ src/src/extras/Stepper_TB6612.h | 2 ++ src/src/extras/Stepper_UNIPOLAR.h | 2 ++ src/src/extras/extras.ino | 3 --- 14 files changed, 18 insertions(+), 33 deletions(-) diff --git a/examples/06-DimmableLED/06-DimmableLED.ino b/examples/06-DimmableLED/06-DimmableLED.ino index 804b116..edeba4b 100644 --- a/examples/06-DimmableLED/06-DimmableLED.ino +++ b/examples/06-DimmableLED/06-DimmableLED.ino @@ -50,12 +50,11 @@ void setup() { // As usual, all previous comments have been deleted and only new changes from the previous example are shown. // NOTE: The Arduino/ESP32 code base does not include the function analogWrite() which is typically used to create a PWM - // output to drive the brightness of an LED. The ESP32 code base itself includes a set of functions to create PWM output - // and the ESP32 chip has built-in PWM functionality specifically for this purpose. There are numerous libraries - // you can download that mimics or reproduces analogWrite() in some form or another. HomeSpan conveniently comes with - // its own version of a wrapper around the ESP32 PWM classes that make it very easy to define LED pins, and set the - // PWM level (or duty cycle) from 0-100%. These functions are encapsualted in the LedPin class, as defined in - // extras/PwmPin.h. We will include this file in our updated DEV_LED.h for use with DEV_DimmableLED. + // output to drive the brightness of an LED. Instead, the ESP32 code base itself includes a set of functions to create PWM output + // and the ESP32 chip has built-in PWM functionality specifically for this purpose. + + // HomeSpan wraps all of this PWM functionality into a single integrated class called LedPin, making it very easy to define + // dimmable LED pins and set the PWM level (i.e. duty cycle) from 0-100%. Use of this LedPin class is shown in DEV_DimmableLED. Serial.begin(115200); diff --git a/examples/06-DimmableLED/DEV_LED.h b/examples/06-DimmableLED/DEV_LED.h index d9445e9..8fc95f0 100644 --- a/examples/06-DimmableLED/DEV_LED.h +++ b/examples/06-DimmableLED/DEV_LED.h @@ -3,8 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // NEW! Include this HomeSpan "extra" to create LED-compatible PWM signals on one or more pins - struct DEV_LED : Service::LightBulb { // ON/OFF LED int ledPin; // pin number defined for this LED diff --git a/examples/07-AccessoryNames/DEV_LED.h b/examples/07-AccessoryNames/DEV_LED.h index d9445e9..8fc95f0 100644 --- a/examples/07-AccessoryNames/DEV_LED.h +++ b/examples/07-AccessoryNames/DEV_LED.h @@ -3,8 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // NEW! Include this HomeSpan "extra" to create LED-compatible PWM signals on one or more pins - struct DEV_LED : Service::LightBulb { // ON/OFF LED int ledPin; // pin number defined for this LED diff --git a/examples/08-Bridges/DEV_LED.h b/examples/08-Bridges/DEV_LED.h index 36c05de..55b7ce4 100644 --- a/examples/08-Bridges/DEV_LED.h +++ b/examples/08-Bridges/DEV_LED.h @@ -3,8 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // allows PWM control of LED brightness - struct DEV_LED : Service::LightBulb { // ON/OFF LED int ledPin; // pin number defined for this LED diff --git a/examples/09-MessageLogging/DEV_LED.h b/examples/09-MessageLogging/DEV_LED.h index 94726e8..5e9cb8a 100644 --- a/examples/09-MessageLogging/DEV_LED.h +++ b/examples/09-MessageLogging/DEV_LED.h @@ -3,8 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // allows PWM control of LED brightness - struct DEV_LED : Service::LightBulb { // ON/OFF LED int ledPin; // pin number defined for this LED diff --git a/examples/10-RGB_LED/DEV_LED.h b/examples/10-RGB_LED/DEV_LED.h index 480f3ce..8a3c10a 100644 --- a/examples/10-RGB_LED/DEV_LED.h +++ b/examples/10-RGB_LED/DEV_LED.h @@ -3,10 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // library of various PWM functions - -//////////////////////////////////// - struct DEV_LED : Service::LightBulb { // ON/OFF LED int ledPin; // pin number defined for this LED diff --git a/examples/15-RealPushButtons/DEV_LED.h b/examples/15-RealPushButtons/DEV_LED.h index 93a3657..b1d750d 100644 --- a/examples/15-RealPushButtons/DEV_LED.h +++ b/examples/15-RealPushButtons/DEV_LED.h @@ -3,10 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // library of various PWM functions - -//////////////////////////////////// - struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED // This version of the Dimmable LED Service is similar to the one last used in Example 11, but now includes support for 3 physical PushButtons diff --git a/examples/18-SavingStatus/DEV_LED.h b/examples/18-SavingStatus/DEV_LED.h index 04839b6..7efa977 100644 --- a/examples/18-SavingStatus/DEV_LED.h +++ b/examples/18-SavingStatus/DEV_LED.h @@ -3,10 +3,6 @@ // DEVICE-SPECIFIC LED SERVICES // //////////////////////////////////// -#include "extras/PwmPin.h" // library of various PWM functions - -//////////////////////////////////// - struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED // This version of the Dimmable LED Service includes a PushButton that can be used to turn on/off the LED. Status of both the diff --git a/src/HomeSpan.h b/src/HomeSpan.h index eeb9e80..dcc79d8 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -45,6 +45,10 @@ #include "extras/Blinker.h" #include "extras/Pixel.h" +#include "extras/RFControl.h" +#include "extras/PwmPin.h" +#include "extras/StepperControl.h" + #include "Settings.h" #include "Utils.h" #include "Network.h" @@ -52,8 +56,6 @@ #include "HapQR.h" #include "Characteristics.h" -#include "extras/StepperControl.h" - using std::vector; using std::unordered_map; using std::list; diff --git a/src/src/extras/StepperControl.h b/src/src/extras/StepperControl.h index b8d879c..a903e1b 100644 --- a/src/src/extras/StepperControl.h +++ b/src/src/extras/StepperControl.h @@ -106,8 +106,9 @@ class StepperControl { ////////////////////////// #include "Stepper_UNIPOLAR.h" -#include "Stepper_TB6612.h" -#include "Stepper_A3967.h" +#include "Stepper_TB6612.h" // https://www.adafruit.com/product/2448 +#include "Stepper_A3967.h" // https://www.sparkfun.com/products/12779 + struct Stepper_UNL2003 : Stepper_UNIPOLAR { Stepper_UNL2003(int IN1, int IN2, int IN3, int IN4, std::pair taskParams = {1,0}) : Stepper_UNIPOLAR(IN1,IN3,IN2,IN4,taskParams){} diff --git a/src/src/extras/Stepper_A3967.h b/src/src/extras/Stepper_A3967.h index c50fa91..8492e4b 100644 --- a/src/src/extras/Stepper_A3967.h +++ b/src/src/extras/Stepper_A3967.h @@ -25,6 +25,8 @@ * ********************************************************************************/ +#pragma once + // Implementation of StepperControl for a Sparkfun A3967 EasyDriver Stepper Motor Driver // Breakout Board (https://www.sparkfun.com/products/12779) diff --git a/src/src/extras/Stepper_TB6612.h b/src/src/extras/Stepper_TB6612.h index e11e366..dd4f9c7 100644 --- a/src/src/extras/Stepper_TB6612.h +++ b/src/src/extras/Stepper_TB6612.h @@ -25,6 +25,8 @@ * ********************************************************************************/ +#pragma once + // Implementation of StepperControl for an Adafruit TB6612 1.2A DC/Stepper Motor Driver // Breakout Board (https://www.adafruit.com/product/2448) diff --git a/src/src/extras/Stepper_UNIPOLAR.h b/src/src/extras/Stepper_UNIPOLAR.h index b46e076..eb4a692 100644 --- a/src/src/extras/Stepper_UNIPOLAR.h +++ b/src/src/extras/Stepper_UNIPOLAR.h @@ -25,6 +25,8 @@ * ********************************************************************************/ +#pragma once + // Implementation of a basic 4-wire controller for a center-tapped Unipolar Stepper Motor // with two coils (Coil 1 and Coil 2) each having two driving inputs (A and B). // diff --git a/src/src/extras/extras.ino b/src/src/extras/extras.ino index ea202ef..c46b968 100644 --- a/src/src/extras/extras.ino +++ b/src/src/extras/extras.ino @@ -28,9 +28,6 @@ // This is a placeholder .ino file that allows you to easily edit the contents of this files using the Arduino IDE, // as well as compile and test from this point. This file is ignored when the library is included in other sketches. -//#include "Stepper_TB6612.h" // include the driver for a TB6612 chip -//#include "Stepper_A3967.h" - #include "StepperControl.h" StepperControl *bigMotor;