From a2480e6b4323025ff15898564cec3e64441216dc Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 21:00:10 -0400 Subject: [PATCH 01/11] Device names are now stored in EEPROM (saves RAM) --- Arduino/libraries/ST_Anything/Constants.h | 3 ++ Arduino/libraries/ST_Anything/Device.cpp | 44 ++++++++++++++++--- Arduino/libraries/ST_Anything/Device.h | 13 +++--- Arduino/libraries/ST_Anything/EX_Alarm.cpp | 2 +- Arduino/libraries/ST_Anything/EX_Alarm.h | 2 +- Arduino/libraries/ST_Anything/EX_Switch.cpp | 2 +- Arduino/libraries/ST_Anything/EX_Switch.h | 2 +- Arduino/libraries/ST_Anything/Everything.cpp | 3 +- Arduino/libraries/ST_Anything/Everything.h | 4 ++ Arduino/libraries/ST_Anything/Executor.cpp | 2 +- Arduino/libraries/ST_Anything/Executor.h | 2 +- Arduino/libraries/ST_Anything/IS_Contact.cpp | 2 +- Arduino/libraries/ST_Anything/IS_Contact.h | 2 +- .../libraries/ST_Anything/IS_DoorControl.cpp | 2 +- .../libraries/ST_Anything/IS_DoorControl.h | 2 +- Arduino/libraries/ST_Anything/IS_Motion.cpp | 2 +- Arduino/libraries/ST_Anything/IS_Motion.h | 2 +- .../libraries/ST_Anything/InterruptSensor.cpp | 2 +- .../libraries/ST_Anything/InterruptSensor.h | 2 +- .../libraries/ST_Anything/PS_Illuminance.cpp | 2 +- .../libraries/ST_Anything/PS_Illuminance.h | 2 +- Arduino/libraries/ST_Anything/PS_Water.cpp | 2 +- Arduino/libraries/ST_Anything/PS_Water.h | 2 +- .../libraries/ST_Anything/PollingSensor.cpp | 2 +- Arduino/libraries/ST_Anything/PollingSensor.h | 2 +- Arduino/libraries/ST_Anything/Sensor.cpp | 2 +- Arduino/libraries/ST_Anything/Sensor.h | 2 +- .../PS_AdafruitThermocouple.cpp | 2 +- .../PS_AdafruitThermocouple.h | 2 +- .../ST_Anything_RCSwitch/EX_RCSwitch.cpp | 2 +- .../ST_Anything_RCSwitch/EX_RCSwitch.h | 2 +- .../PS_TemperatureHumidity.cpp | 2 +- .../PS_TemperatureHumidity.h | 2 +- 33 files changed, 82 insertions(+), 41 deletions(-) diff --git a/Arduino/libraries/ST_Anything/Constants.h b/Arduino/libraries/ST_Anything/Constants.h index 8ffeb0af..a899b5aa 100755 --- a/Arduino/libraries/ST_Anything/Constants.h +++ b/Arduino/libraries/ST_Anything/Constants.h @@ -65,6 +65,9 @@ namespace st class Constants { public: + //Max name length (including null terminator!) + static const byte MAX_NAME_LENGTH=30; + //Serial debug console baud rate static const unsigned int SERIAL_BAUDRATE=9600; //Uncomment If NOT using pins 0,1 for ST Shield communications (default) //static const unsigned int SERIAL_BAUDRATE=2400; //Uncomment if using Pins 0,1 for ST Shield Communications diff --git a/Arduino/libraries/ST_Anything/Device.cpp b/Arduino/libraries/ST_Anything/Device.cpp index d253bffd..b6400ee7 100755 --- a/Arduino/libraries/ST_Anything/Device.cpp +++ b/Arduino/libraries/ST_Anything/Device.cpp @@ -16,6 +16,9 @@ //****************************************************************************************** #include "Device.h" +#include "Everything.h" +#include "Constants.h" +#include namespace st { @@ -23,13 +26,24 @@ namespace st //public //constructor - Device::Device(const String &name): - m_Name(name) + Device::Device(const char *name): + m_pEeprom(Everything::EepromPointer) { + String nameStr(name); + Everything::EepromPointer+=nameStr.length()+2; + + //write string into EEPROM + int i; + for(i=0; i 0, do NOT perform refreshDevices() routine + + static unsigned short EepromPointer; static bool debug; //debug flag to determine if debug print statements are executed - set value in your sketch's setup() routine friend SmartThingsCallout_t receiveSmartString; //callback function to act on data received from SmartThings Shield - called from SmartThings Shield Library + //static String progmemToString(const __FlashStringHelper *s); + //SmartThings Object #ifndef DISABLE_SMARTTHINGS static void setLED(uint8_t red, uint8_t green, uint8_t blue) {SmartThing.shieldSetLED(red, green, blue);} diff --git a/Arduino/libraries/ST_Anything/Executor.cpp b/Arduino/libraries/ST_Anything/Executor.cpp index c792f433..f471d7f1 100755 --- a/Arduino/libraries/ST_Anything/Executor.cpp +++ b/Arduino/libraries/ST_Anything/Executor.cpp @@ -30,7 +30,7 @@ st //public //constructor - Executor::Executor(const String &name): + Executor::Executor(const char *name): Device(name) { diff --git a/Arduino/libraries/ST_Anything/Executor.h b/Arduino/libraries/ST_Anything/Executor.h index a3485a4a..e6b2b067 100755 --- a/Arduino/libraries/ST_Anything/Executor.h +++ b/Arduino/libraries/ST_Anything/Executor.h @@ -29,7 +29,7 @@ namespace st public: //constructor - Executor(const String &name); + Executor(const char *name); //destructor virtual ~Executor(); diff --git a/Arduino/libraries/ST_Anything/IS_Contact.cpp b/Arduino/libraries/ST_Anything/IS_Contact.cpp index dd624990..12d26893 100644 --- a/Arduino/libraries/ST_Anything/IS_Contact.cpp +++ b/Arduino/libraries/ST_Anything/IS_Contact.cpp @@ -36,7 +36,7 @@ namespace st //public //constructor - IS_Contact::IS_Contact(const String &name, byte pin, bool iState, bool pullup, long numReqCounts) : + IS_Contact::IS_Contact(const char *name, byte pin, bool iState, bool pullup, long numReqCounts) : InterruptSensor(name, pin, iState, pullup, numReqCounts) //use parent class' constructor { } diff --git a/Arduino/libraries/ST_Anything/IS_Contact.h b/Arduino/libraries/ST_Anything/IS_Contact.h index 2238ed93..de200464 100644 --- a/Arduino/libraries/ST_Anything/IS_Contact.h +++ b/Arduino/libraries/ST_Anything/IS_Contact.h @@ -39,7 +39,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_Contact(const String &name, byte pin, bool iState, bool internalPullup = false, long numReqCounts = 0); //(defaults to NOT using internal pullup resistors, and required counts = 0) + IS_Contact(const char *name, byte pin, bool iState, bool internalPullup = false, long numReqCounts = 0); //(defaults to NOT using internal pullup resistors, and required counts = 0) //destructor virtual ~IS_Contact(); diff --git a/Arduino/libraries/ST_Anything/IS_DoorControl.cpp b/Arduino/libraries/ST_Anything/IS_DoorControl.cpp index d04daa28..e91b9d9a 100644 --- a/Arduino/libraries/ST_Anything/IS_DoorControl.cpp +++ b/Arduino/libraries/ST_Anything/IS_DoorControl.cpp @@ -46,7 +46,7 @@ namespace st //public //constructor - IS_DoorControl::IS_DoorControl(const String &name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime) : + IS_DoorControl::IS_DoorControl(const char *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime) : InterruptSensor(name, pinInput, iState, pullup), //use parent class' constructor m_bCurrentState(startingState), m_bInvertLogic(invertLogic), diff --git a/Arduino/libraries/ST_Anything/IS_DoorControl.h b/Arduino/libraries/ST_Anything/IS_DoorControl.h index 674bbab9..69fce6fe 100644 --- a/Arduino/libraries/ST_Anything/IS_DoorControl.h +++ b/Arduino/libraries/ST_Anything/IS_DoorControl.h @@ -56,7 +56,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_DoorControl(const String &name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime); + IS_DoorControl(const char *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime); //destructor virtual ~IS_DoorControl(); diff --git a/Arduino/libraries/ST_Anything/IS_Motion.cpp b/Arduino/libraries/ST_Anything/IS_Motion.cpp index 2c9898a8..4925f36b 100644 --- a/Arduino/libraries/ST_Anything/IS_Motion.cpp +++ b/Arduino/libraries/ST_Anything/IS_Motion.cpp @@ -34,7 +34,7 @@ namespace st //public //constructor - IS_Motion::IS_Motion(const String &name, byte pin, bool iState, bool pullup) : + IS_Motion::IS_Motion(const char *name, byte pin, bool iState, bool pullup) : InterruptSensor(name, pin, iState, pullup), //use parent class' constructor calibrated(false) { diff --git a/Arduino/libraries/ST_Anything/IS_Motion.h b/Arduino/libraries/ST_Anything/IS_Motion.h index f8e7666b..e293b6dc 100644 --- a/Arduino/libraries/ST_Anything/IS_Motion.h +++ b/Arduino/libraries/ST_Anything/IS_Motion.h @@ -40,7 +40,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_Motion(const String &name, byte pin, bool iState, bool internalPullup = false); //(defaults to NOT using internal pullup resistors) + IS_Motion(const char *name, byte pin, bool iState, bool internalPullup = false); //(defaults to NOT using internal pullup resistors) //destructor virtual ~IS_Motion(); diff --git a/Arduino/libraries/ST_Anything/InterruptSensor.cpp b/Arduino/libraries/ST_Anything/InterruptSensor.cpp index 6d1427c7..cbeabb85 100755 --- a/Arduino/libraries/ST_Anything/InterruptSensor.cpp +++ b/Arduino/libraries/ST_Anything/InterruptSensor.cpp @@ -54,7 +54,7 @@ namespace st //public //constructor - InterruptSensor::InterruptSensor(const String &name, byte pin, bool iState, bool pullup, long numReqCounts) : + InterruptSensor::InterruptSensor(const char *name, byte pin, bool iState, bool pullup, long numReqCounts) : Sensor(name), m_bInterruptState(iState), m_bStatus(false), diff --git a/Arduino/libraries/ST_Anything/InterruptSensor.h b/Arduino/libraries/ST_Anything/InterruptSensor.h index 64a585d3..0b85701f 100755 --- a/Arduino/libraries/ST_Anything/InterruptSensor.h +++ b/Arduino/libraries/ST_Anything/InterruptSensor.h @@ -39,7 +39,7 @@ namespace st public: //constructor - InterruptSensor(const String &name, byte pin, bool iState, bool internalPullup=false, long numReqCounts=0); //(defaults to NOT using internal pullup resistors, and required counts = 0) + InterruptSensor(const char *name, byte pin, bool iState, bool internalPullup=false, long numReqCounts=0); //(defaults to NOT using internal pullup resistors, and required counts = 0) //destructor virtual ~InterruptSensor(); diff --git a/Arduino/libraries/ST_Anything/PS_Illuminance.cpp b/Arduino/libraries/ST_Anything/PS_Illuminance.cpp index 1667c825..d8eda9bc 100755 --- a/Arduino/libraries/ST_Anything/PS_Illuminance.cpp +++ b/Arduino/libraries/ST_Anything/PS_Illuminance.cpp @@ -50,7 +50,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_Illuminance::PS_Illuminance(const String &name, unsigned int interval, int offset, byte analogInputPin, int s_l, int s_h, int m_l, int m_h): + PS_Illuminance::PS_Illuminance(const char *name, unsigned int interval, int offset, byte analogInputPin, int s_l, int s_h, int m_l, int m_h): PollingSensor(name, interval, offset), m_nSensorValue(0), SENSOR_LOW(s_l), diff --git a/Arduino/libraries/ST_Anything/PS_Illuminance.h b/Arduino/libraries/ST_Anything/PS_Illuminance.h index 9f7505b6..988456c4 100755 --- a/Arduino/libraries/ST_Anything/PS_Illuminance.h +++ b/Arduino/libraries/ST_Anything/PS_Illuminance.h @@ -54,7 +54,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_Illuminance(const String &name, unsigned int interval, int offset, byte analogInputPin, int s_l=0, int s_h=1024, int m_l=1000, int m_h=0); + PS_Illuminance(const char *name, unsigned int interval, int offset, byte analogInputPin, int s_l=0, int s_h=1024, int m_l=1000, int m_h=0); //destructor virtual ~PS_Illuminance(); diff --git a/Arduino/libraries/ST_Anything/PS_Water.cpp b/Arduino/libraries/ST_Anything/PS_Water.cpp index 5fedc0ab..46ffedc5 100644 --- a/Arduino/libraries/ST_Anything/PS_Water.cpp +++ b/Arduino/libraries/ST_Anything/PS_Water.cpp @@ -42,7 +42,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_Water::PS_Water(const String &name, unsigned int interval, int offset, byte analogInputPin): + PS_Water::PS_Water(const char *name, unsigned int interval, int offset, byte analogInputPin): PollingSensor(name, interval, offset), m_nSensorValue(0) { diff --git a/Arduino/libraries/ST_Anything/PS_Water.h b/Arduino/libraries/ST_Anything/PS_Water.h index 074f0a49..ca03f5e2 100644 --- a/Arduino/libraries/ST_Anything/PS_Water.h +++ b/Arduino/libraries/ST_Anything/PS_Water.h @@ -45,7 +45,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_Water(const String &name, unsigned int interval, int offset, byte analogInputPin); + PS_Water(const char *name, unsigned int interval, int offset, byte analogInputPin); //destructor virtual ~PS_Water(); diff --git a/Arduino/libraries/ST_Anything/PollingSensor.cpp b/Arduino/libraries/ST_Anything/PollingSensor.cpp index afba0a94..89ee7f36 100755 --- a/Arduino/libraries/ST_Anything/PollingSensor.cpp +++ b/Arduino/libraries/ST_Anything/PollingSensor.cpp @@ -66,7 +66,7 @@ namespace st //public //constructor - PollingSensor::PollingSensor(const String &name, long interval, long offset): + PollingSensor::PollingSensor(const char *name, long interval, long offset): Sensor(name), m_nPreviousTime(0), m_nDeltaTime(0), diff --git a/Arduino/libraries/ST_Anything/PollingSensor.h b/Arduino/libraries/ST_Anything/PollingSensor.h index 1f2f0f44..6337061d 100755 --- a/Arduino/libraries/ST_Anything/PollingSensor.h +++ b/Arduino/libraries/ST_Anything/PollingSensor.h @@ -40,7 +40,7 @@ namespace st public: //constructor - PollingSensor(const String &name, long interval, long offset=0); + PollingSensor(const char *name, long interval, long offset=0); //destructor virtual ~PollingSensor(); diff --git a/Arduino/libraries/ST_Anything/Sensor.cpp b/Arduino/libraries/ST_Anything/Sensor.cpp index 32a04e81..f79bc3c7 100755 --- a/Arduino/libraries/ST_Anything/Sensor.cpp +++ b/Arduino/libraries/ST_Anything/Sensor.cpp @@ -26,7 +26,7 @@ namespace st //public //constructor - Sensor::Sensor(const String &name): + Sensor::Sensor(const char *name): Device(name) { diff --git a/Arduino/libraries/ST_Anything/Sensor.h b/Arduino/libraries/ST_Anything/Sensor.h index ee925a80..b6166ad3 100755 --- a/Arduino/libraries/ST_Anything/Sensor.h +++ b/Arduino/libraries/ST_Anything/Sensor.h @@ -29,7 +29,7 @@ namespace st public: //constructor - Sensor(const String &name); + Sensor(const char *name); //destructor virtual ~Sensor(); diff --git a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp index 9e3b3e87..0001a827 100644 --- a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp +++ b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp @@ -47,7 +47,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_AdafruitThermocouple::PS_AdafruitThermocouple(const String &name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO): + PS_AdafruitThermocouple::PS_AdafruitThermocouple(const char *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO): PollingSensor(name, interval, offset), m_dblTemperatureSensorValue(0.0), m_Adafruit_MAX31855(Adafruit_MAX31855(pinSCLK, pinCS, pinMISO)) diff --git a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h index fc043386..56c2a24c 100644 --- a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h +++ b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h @@ -51,7 +51,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_AdafruitThermocouple(const String &name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO); + PS_AdafruitThermocouple(const char *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO); //destructor virtual ~PS_AdafruitThermocouple(); diff --git a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp index cb6da404..60314d8b 100644 --- a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp +++ b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp @@ -50,7 +50,7 @@ namespace st //public //constructor - EX_RCSwitch::EX_RCSwitch(const String &name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState) : + EX_RCSwitch::EX_RCSwitch(const char *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState) : Executor(name), m_bCurrentState(startingState), m_myRCSwitch(RCSwitch()), diff --git a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h index 372baa83..3deef137 100644 --- a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h +++ b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h @@ -48,7 +48,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - EX_RCSwitch(const String &name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState = LOW); + EX_RCSwitch(const char *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState = LOW); //destructor virtual ~EX_RCSwitch(); diff --git a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp index 84082e9f..a8801b2a 100644 --- a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp +++ b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp @@ -49,7 +49,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_TemperatureHumidity::PS_TemperatureHumidity(const String &name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp, String strHumid) : + PS_TemperatureHumidity::PS_TemperatureHumidity(const char *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp, String strHumid) : PollingSensor(name, interval, offset), m_nTemperatureSensorValue(0), m_nHumiditySensorValue(0), diff --git a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h index 64460bf0..06701e6e 100644 --- a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h +++ b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h @@ -61,7 +61,7 @@ namespace st enum DHT_SENSOR { DHT11, DHT21, DHT22, DHT33, DHT44 }; //constructor - called in your sketch's global variable declaration section - PS_TemperatureHumidity(const String &name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp="temperature", String strHumid="humidity"); + PS_TemperatureHumidity(const char *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp="temperature", String strHumid="humidity"); //destructor virtual ~PS_TemperatureHumidity(); From 08cccdbed299da33d6a7b6948568a7ec52d73185 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 21:52:07 -0400 Subject: [PATCH 02/11] Ditched EEPROM; names stored exclusively in PROGMEM now. Major RAM savings --- Arduino/Sketches/ST_Anything/ST_Anything.ino | 35 ++++++++++--------- Arduino/libraries/ST_Anything/Device.cpp | 32 ++--------------- Arduino/libraries/ST_Anything/Device.h | 5 ++- Arduino/libraries/ST_Anything/EX_Alarm.cpp | 2 +- Arduino/libraries/ST_Anything/EX_Alarm.h | 2 +- Arduino/libraries/ST_Anything/EX_Switch.cpp | 2 +- Arduino/libraries/ST_Anything/EX_Switch.h | 2 +- Arduino/libraries/ST_Anything/Everything.cpp | 11 +++++- Arduino/libraries/ST_Anything/Everything.h | 6 ++-- Arduino/libraries/ST_Anything/Executor.cpp | 2 +- Arduino/libraries/ST_Anything/Executor.h | 2 +- Arduino/libraries/ST_Anything/IS_Contact.cpp | 2 +- Arduino/libraries/ST_Anything/IS_Contact.h | 2 +- .../libraries/ST_Anything/IS_DoorControl.cpp | 2 +- .../libraries/ST_Anything/IS_DoorControl.h | 2 +- Arduino/libraries/ST_Anything/IS_Motion.cpp | 2 +- Arduino/libraries/ST_Anything/IS_Motion.h | 2 +- .../libraries/ST_Anything/InterruptSensor.cpp | 2 +- .../libraries/ST_Anything/InterruptSensor.h | 2 +- .../libraries/ST_Anything/PS_Illuminance.cpp | 2 +- .../libraries/ST_Anything/PS_Illuminance.h | 2 +- Arduino/libraries/ST_Anything/PS_Water.cpp | 2 +- Arduino/libraries/ST_Anything/PS_Water.h | 2 +- .../libraries/ST_Anything/PollingSensor.cpp | 2 +- Arduino/libraries/ST_Anything/PollingSensor.h | 2 +- Arduino/libraries/ST_Anything/Sensor.cpp | 2 +- Arduino/libraries/ST_Anything/Sensor.h | 2 +- .../PS_AdafruitThermocouple.cpp | 4 +-- .../PS_AdafruitThermocouple.h | 4 +-- .../ST_Anything_RCSwitch/EX_RCSwitch.cpp | 2 +- .../ST_Anything_RCSwitch/EX_RCSwitch.h | 2 +- .../PS_TemperatureHumidity.cpp | 4 +-- .../PS_TemperatureHumidity.h | 4 +-- 33 files changed, 68 insertions(+), 85 deletions(-) mode change 100644 => 100755 Arduino/Sketches/ST_Anything/ST_Anything.ino diff --git a/Arduino/Sketches/ST_Anything/ST_Anything.ino b/Arduino/Sketches/ST_Anything/ST_Anything.ino old mode 100644 new mode 100755 index bdc0ad7f..5d51c9f1 --- a/Arduino/Sketches/ST_Anything/ST_Anything.ino +++ b/Arduino/Sketches/ST_Anything/ST_Anything.ino @@ -42,6 +42,7 @@ #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield #include //DHT Temperature and Humidity Library +#include //****************************************************************************************** // ST_Anything Library @@ -98,18 +99,17 @@ // "temperature" and one for "humidity") //****************************************************************************************** //Polling Sensors -st::PS_Illuminance sensor1("illuminance", 120, 0, PIN_ILLUMINANCE); -st::PS_TemperatureHumidity sensor2("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); -st::PS_Water sensor3("water", 60, 20, PIN_WATER); +//st::PS_Illuminance sensor1("illuminance", 120, 0, PIN_ILLUMINANCE); +//st::PS_TemperatureHumidity sensor2("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); +//st::PS_Water sensor3("water", 60, 20, PIN_WATER); //Interrupt Sensors -st::IS_Motion sensor4("motion", PIN_MOTION, HIGH, false); -st::IS_Contact sensor5("contact", PIN_CONTACT, LOW, true); +//st::IS_Motion sensor4("motion", PIN_MOTION, HIGH, false); +//st::IS_Contact sensor5("contact", PIN_CONTACT, LOW, true); //Executors -st::EX_Switch executor1("switch", PIN_SWITCH, LOW, true); -st::EX_Alarm executor2("alarm", PIN_ALARM, LOW, true); - +//st::EX_Switch executor1("switch", PIN_SWITCH, LOW, true); +//st::EX_Alarm executor2("alarm", PIN_ALARM, LOW, true); //****************************************************************************************** //Arduino Setup() routine @@ -126,7 +126,6 @@ void setup() st::Device::debug=true; st::PollingSensor::debug=true; st::InterruptSensor::debug=true; - //***************************************************************************** //Initialize the "Everything" Class //***************************************************************************** @@ -135,17 +134,19 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); + //polling sensors + st::Everything::addSensor(new st::PS_Illuminance(F("illuminance"), 120, 0, PIN_ILLUMINANCE)); + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22)); + st::Everything::addSensor(new st::PS_Water(F("water"), 60, 20, PIN_WATER)); + //interrupt sensors + st::Everything::addSensor(new st::IS_Motion(F("motion"), PIN_MOTION, HIGH, false)); + st::Everything::addSensor(new st::IS_Contact(F("contact"), PIN_CONTACT, LOW, true)); //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(&executor1); - st::Everything::addExecutor(&executor2); + st::Everything::addExecutor(new st::EX_Switch(F("switch"), PIN_SWITCH, LOW, true)); + st::Everything::addExecutor(new st::EX_Alarm(F("alarm"), PIN_ALARM, LOW, true)); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class @@ -162,4 +163,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} diff --git a/Arduino/libraries/ST_Anything/Device.cpp b/Arduino/libraries/ST_Anything/Device.cpp index b6400ee7..5a4cfac7 100755 --- a/Arduino/libraries/ST_Anything/Device.cpp +++ b/Arduino/libraries/ST_Anything/Device.cpp @@ -18,7 +18,6 @@ #include "Device.h" #include "Everything.h" #include "Constants.h" -#include namespace st { @@ -26,20 +25,9 @@ namespace st //public //constructor - Device::Device(const char *name): - m_pEeprom(Everything::EepromPointer) + Device::Device(const __FlashStringHelper *name): + m_pName(name) { - String nameStr(name); - Everything::EepromPointer+=nameStr.length()+2; - - //write string into EEPROM - int i; - for(i=0; i +#include namespace st { class Device { private: - //String m_Name; - unsigned short m_pEeprom; + const __FlashStringHelper *m_pName; public: //constructor - Device(const char *name); Device(const __FlashStringHelper *name); //destructor diff --git a/Arduino/libraries/ST_Anything/EX_Alarm.cpp b/Arduino/libraries/ST_Anything/EX_Alarm.cpp index db1fdc1b..5e1fb0b6 100644 --- a/Arduino/libraries/ST_Anything/EX_Alarm.cpp +++ b/Arduino/libraries/ST_Anything/EX_Alarm.cpp @@ -41,7 +41,7 @@ namespace st //public //constructor - EX_Alarm::EX_Alarm(const char *name, byte pin, bool startingState, bool invertLogic) : + EX_Alarm::EX_Alarm(const __FlashStringHelper *name, byte pin, bool startingState, bool invertLogic) : Executor(name), m_bCurrentState(startingState), m_bInvertLogic(invertLogic) diff --git a/Arduino/libraries/ST_Anything/EX_Alarm.h b/Arduino/libraries/ST_Anything/EX_Alarm.h index 5146b664..6175603e 100644 --- a/Arduino/libraries/ST_Anything/EX_Alarm.h +++ b/Arduino/libraries/ST_Anything/EX_Alarm.h @@ -47,7 +47,7 @@ namespace st public: //constructor - EX_Alarm(const char *name, byte Pin, bool startingState = LOW, bool invertLogic = false); + EX_Alarm(const __FlashStringHelper *name, byte Pin, bool startingState = LOW, bool invertLogic = false); //destructor virtual ~EX_Alarm(); diff --git a/Arduino/libraries/ST_Anything/EX_Switch.cpp b/Arduino/libraries/ST_Anything/EX_Switch.cpp index 202fdf80..b3bbbd99 100755 --- a/Arduino/libraries/ST_Anything/EX_Switch.cpp +++ b/Arduino/libraries/ST_Anything/EX_Switch.cpp @@ -40,7 +40,7 @@ namespace st //public //constructor - EX_Switch::EX_Switch(const char *name, byte pin, bool startingState, bool invertLogic) : + EX_Switch::EX_Switch(const __FlashStringHelper *name, byte pin, bool startingState, bool invertLogic) : Executor(name), m_bCurrentState(startingState), m_bInvertLogic(invertLogic) diff --git a/Arduino/libraries/ST_Anything/EX_Switch.h b/Arduino/libraries/ST_Anything/EX_Switch.h index e60c60c3..cadc48e5 100755 --- a/Arduino/libraries/ST_Anything/EX_Switch.h +++ b/Arduino/libraries/ST_Anything/EX_Switch.h @@ -40,7 +40,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - EX_Switch(const char *name, byte pin, bool startingState = LOW, bool invertLogic = false); + EX_Switch(const __FlashStringHelper *name, byte pin, bool startingState = LOW, bool invertLogic = false); //destructor virtual ~EX_Switch(); diff --git a/Arduino/libraries/ST_Anything/Everything.cpp b/Arduino/libraries/ST_Anything/Everything.cpp index 5f04040b..4c4422fe 100755 --- a/Arduino/libraries/ST_Anything/Everything.cpp +++ b/Arduino/libraries/ST_Anything/Everything.cpp @@ -25,6 +25,7 @@ //****************************************************************************************** #include +#include #include "Everything.h" int freeRam(); //freeRam() function prototype - useful in determining how much SRAM is available on Arduino @@ -337,6 +338,15 @@ namespace st return true; } + String Everything::progmemToString(const __FlashStringHelper *s) + { + char tmp[Constants::MAX_NAME_LENGTH]; + strcpy_P(tmp, (const char*)s); + + String rStr(tmp); + return rStr; + } + //friends! void receiveSmartString(String message) { @@ -368,7 +378,6 @@ namespace st unsigned long Everything::sendstringsLastMillis = 0; bool Everything::debug=false; byte Everything::bTimersPending = 0; //initialize variable - unsigned short Everything::EepromPointer = 0; //SmartThings static members #ifndef DISABLE_SMARTTHINGS diff --git a/Arduino/libraries/ST_Anything/Everything.h b/Arduino/libraries/ST_Anything/Everything.h index 022e2757..012df749 100755 --- a/Arduino/libraries/ST_Anything/Everything.h +++ b/Arduino/libraries/ST_Anything/Everything.h @@ -87,14 +87,14 @@ namespace st static bool addExecutor(Executor *executor);//adds a Executor object to st::Everything's m_Executors[] array - called in your sketch setup() routine static byte bTimersPending; //number of time critical events in progress - if > 0, do NOT perform refreshDevices() routine - - static unsigned short EepromPointer; static bool debug; //debug flag to determine if debug print statements are executed - set value in your sketch's setup() routine + + static String progmemToString(const __FlashStringHelper *s); //conveniently converts a string stored in progmem into a String object friend SmartThingsCallout_t receiveSmartString; //callback function to act on data received from SmartThings Shield - called from SmartThings Shield Library - //static String progmemToString(const __FlashStringHelper *s); + //SmartThings Object #ifndef DISABLE_SMARTTHINGS diff --git a/Arduino/libraries/ST_Anything/Executor.cpp b/Arduino/libraries/ST_Anything/Executor.cpp index f471d7f1..5996046f 100755 --- a/Arduino/libraries/ST_Anything/Executor.cpp +++ b/Arduino/libraries/ST_Anything/Executor.cpp @@ -30,7 +30,7 @@ st //public //constructor - Executor::Executor(const char *name): + Executor::Executor(const __FlashStringHelper *name): Device(name) { diff --git a/Arduino/libraries/ST_Anything/Executor.h b/Arduino/libraries/ST_Anything/Executor.h index e6b2b067..81ac88aa 100755 --- a/Arduino/libraries/ST_Anything/Executor.h +++ b/Arduino/libraries/ST_Anything/Executor.h @@ -29,7 +29,7 @@ namespace st public: //constructor - Executor(const char *name); + Executor(const __FlashStringHelper *name); //destructor virtual ~Executor(); diff --git a/Arduino/libraries/ST_Anything/IS_Contact.cpp b/Arduino/libraries/ST_Anything/IS_Contact.cpp index 12d26893..f2912f38 100644 --- a/Arduino/libraries/ST_Anything/IS_Contact.cpp +++ b/Arduino/libraries/ST_Anything/IS_Contact.cpp @@ -36,7 +36,7 @@ namespace st //public //constructor - IS_Contact::IS_Contact(const char *name, byte pin, bool iState, bool pullup, long numReqCounts) : + IS_Contact::IS_Contact(const __FlashStringHelper *name, byte pin, bool iState, bool pullup, long numReqCounts) : InterruptSensor(name, pin, iState, pullup, numReqCounts) //use parent class' constructor { } diff --git a/Arduino/libraries/ST_Anything/IS_Contact.h b/Arduino/libraries/ST_Anything/IS_Contact.h index de200464..abcdd4a8 100644 --- a/Arduino/libraries/ST_Anything/IS_Contact.h +++ b/Arduino/libraries/ST_Anything/IS_Contact.h @@ -39,7 +39,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_Contact(const char *name, byte pin, bool iState, bool internalPullup = false, long numReqCounts = 0); //(defaults to NOT using internal pullup resistors, and required counts = 0) + IS_Contact(const __FlashStringHelper *name, byte pin, bool iState, bool internalPullup = false, long numReqCounts = 0); //(defaults to NOT using internal pullup resistors, and required counts = 0) //destructor virtual ~IS_Contact(); diff --git a/Arduino/libraries/ST_Anything/IS_DoorControl.cpp b/Arduino/libraries/ST_Anything/IS_DoorControl.cpp index e91b9d9a..a5f9de8e 100644 --- a/Arduino/libraries/ST_Anything/IS_DoorControl.cpp +++ b/Arduino/libraries/ST_Anything/IS_DoorControl.cpp @@ -46,7 +46,7 @@ namespace st //public //constructor - IS_DoorControl::IS_DoorControl(const char *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime) : + IS_DoorControl::IS_DoorControl(const __FlashStringHelper *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime) : InterruptSensor(name, pinInput, iState, pullup), //use parent class' constructor m_bCurrentState(startingState), m_bInvertLogic(invertLogic), diff --git a/Arduino/libraries/ST_Anything/IS_DoorControl.h b/Arduino/libraries/ST_Anything/IS_DoorControl.h index 69fce6fe..b3c058c8 100644 --- a/Arduino/libraries/ST_Anything/IS_DoorControl.h +++ b/Arduino/libraries/ST_Anything/IS_DoorControl.h @@ -56,7 +56,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_DoorControl(const char *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime); + IS_DoorControl(const __FlashStringHelper *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic, unsigned long delayTime); //destructor virtual ~IS_DoorControl(); diff --git a/Arduino/libraries/ST_Anything/IS_Motion.cpp b/Arduino/libraries/ST_Anything/IS_Motion.cpp index 4925f36b..404ad021 100644 --- a/Arduino/libraries/ST_Anything/IS_Motion.cpp +++ b/Arduino/libraries/ST_Anything/IS_Motion.cpp @@ -34,7 +34,7 @@ namespace st //public //constructor - IS_Motion::IS_Motion(const char *name, byte pin, bool iState, bool pullup) : + IS_Motion::IS_Motion(const __FlashStringHelper *name, byte pin, bool iState, bool pullup) : InterruptSensor(name, pin, iState, pullup), //use parent class' constructor calibrated(false) { diff --git a/Arduino/libraries/ST_Anything/IS_Motion.h b/Arduino/libraries/ST_Anything/IS_Motion.h index e293b6dc..600c0e5b 100644 --- a/Arduino/libraries/ST_Anything/IS_Motion.h +++ b/Arduino/libraries/ST_Anything/IS_Motion.h @@ -40,7 +40,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - IS_Motion(const char *name, byte pin, bool iState, bool internalPullup = false); //(defaults to NOT using internal pullup resistors) + IS_Motion(const __FlashStringHelper *name, byte pin, bool iState, bool internalPullup = false); //(defaults to NOT using internal pullup resistors) //destructor virtual ~IS_Motion(); diff --git a/Arduino/libraries/ST_Anything/InterruptSensor.cpp b/Arduino/libraries/ST_Anything/InterruptSensor.cpp index cbeabb85..d2a04511 100755 --- a/Arduino/libraries/ST_Anything/InterruptSensor.cpp +++ b/Arduino/libraries/ST_Anything/InterruptSensor.cpp @@ -54,7 +54,7 @@ namespace st //public //constructor - InterruptSensor::InterruptSensor(const char *name, byte pin, bool iState, bool pullup, long numReqCounts) : + InterruptSensor::InterruptSensor(const __FlashStringHelper *name, byte pin, bool iState, bool pullup, long numReqCounts) : Sensor(name), m_bInterruptState(iState), m_bStatus(false), diff --git a/Arduino/libraries/ST_Anything/InterruptSensor.h b/Arduino/libraries/ST_Anything/InterruptSensor.h index 0b85701f..be4f14c4 100755 --- a/Arduino/libraries/ST_Anything/InterruptSensor.h +++ b/Arduino/libraries/ST_Anything/InterruptSensor.h @@ -39,7 +39,7 @@ namespace st public: //constructor - InterruptSensor(const char *name, byte pin, bool iState, bool internalPullup=false, long numReqCounts=0); //(defaults to NOT using internal pullup resistors, and required counts = 0) + InterruptSensor(const __FlashStringHelper *name, byte pin, bool iState, bool internalPullup=false, long numReqCounts=0); //(defaults to NOT using internal pullup resistors, and required counts = 0) //destructor virtual ~InterruptSensor(); diff --git a/Arduino/libraries/ST_Anything/PS_Illuminance.cpp b/Arduino/libraries/ST_Anything/PS_Illuminance.cpp index d8eda9bc..5c89df91 100755 --- a/Arduino/libraries/ST_Anything/PS_Illuminance.cpp +++ b/Arduino/libraries/ST_Anything/PS_Illuminance.cpp @@ -50,7 +50,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_Illuminance::PS_Illuminance(const char *name, unsigned int interval, int offset, byte analogInputPin, int s_l, int s_h, int m_l, int m_h): + PS_Illuminance::PS_Illuminance(const __FlashStringHelper *name, unsigned int interval, int offset, byte analogInputPin, int s_l, int s_h, int m_l, int m_h): PollingSensor(name, interval, offset), m_nSensorValue(0), SENSOR_LOW(s_l), diff --git a/Arduino/libraries/ST_Anything/PS_Illuminance.h b/Arduino/libraries/ST_Anything/PS_Illuminance.h index 988456c4..422e9dba 100755 --- a/Arduino/libraries/ST_Anything/PS_Illuminance.h +++ b/Arduino/libraries/ST_Anything/PS_Illuminance.h @@ -54,7 +54,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_Illuminance(const char *name, unsigned int interval, int offset, byte analogInputPin, int s_l=0, int s_h=1024, int m_l=1000, int m_h=0); + PS_Illuminance(const __FlashStringHelper *name, unsigned int interval, int offset, byte analogInputPin, int s_l=0, int s_h=1024, int m_l=1000, int m_h=0); //destructor virtual ~PS_Illuminance(); diff --git a/Arduino/libraries/ST_Anything/PS_Water.cpp b/Arduino/libraries/ST_Anything/PS_Water.cpp index 46ffedc5..281ab654 100644 --- a/Arduino/libraries/ST_Anything/PS_Water.cpp +++ b/Arduino/libraries/ST_Anything/PS_Water.cpp @@ -42,7 +42,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_Water::PS_Water(const char *name, unsigned int interval, int offset, byte analogInputPin): + PS_Water::PS_Water(const __FlashStringHelper *name, unsigned int interval, int offset, byte analogInputPin): PollingSensor(name, interval, offset), m_nSensorValue(0) { diff --git a/Arduino/libraries/ST_Anything/PS_Water.h b/Arduino/libraries/ST_Anything/PS_Water.h index ca03f5e2..0060adbb 100644 --- a/Arduino/libraries/ST_Anything/PS_Water.h +++ b/Arduino/libraries/ST_Anything/PS_Water.h @@ -45,7 +45,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_Water(const char *name, unsigned int interval, int offset, byte analogInputPin); + PS_Water(const __FlashStringHelper *name, unsigned int interval, int offset, byte analogInputPin); //destructor virtual ~PS_Water(); diff --git a/Arduino/libraries/ST_Anything/PollingSensor.cpp b/Arduino/libraries/ST_Anything/PollingSensor.cpp index 89ee7f36..1f447891 100755 --- a/Arduino/libraries/ST_Anything/PollingSensor.cpp +++ b/Arduino/libraries/ST_Anything/PollingSensor.cpp @@ -66,7 +66,7 @@ namespace st //public //constructor - PollingSensor::PollingSensor(const char *name, long interval, long offset): + PollingSensor::PollingSensor(const __FlashStringHelper *name, long interval, long offset): Sensor(name), m_nPreviousTime(0), m_nDeltaTime(0), diff --git a/Arduino/libraries/ST_Anything/PollingSensor.h b/Arduino/libraries/ST_Anything/PollingSensor.h index 6337061d..38cc60ff 100755 --- a/Arduino/libraries/ST_Anything/PollingSensor.h +++ b/Arduino/libraries/ST_Anything/PollingSensor.h @@ -40,7 +40,7 @@ namespace st public: //constructor - PollingSensor(const char *name, long interval, long offset=0); + PollingSensor(const __FlashStringHelper *name, long interval, long offset=0); //destructor virtual ~PollingSensor(); diff --git a/Arduino/libraries/ST_Anything/Sensor.cpp b/Arduino/libraries/ST_Anything/Sensor.cpp index f79bc3c7..fe77850e 100755 --- a/Arduino/libraries/ST_Anything/Sensor.cpp +++ b/Arduino/libraries/ST_Anything/Sensor.cpp @@ -26,7 +26,7 @@ namespace st //public //constructor - Sensor::Sensor(const char *name): + Sensor::Sensor(const __FlashStringHelper *name): Device(name) { diff --git a/Arduino/libraries/ST_Anything/Sensor.h b/Arduino/libraries/ST_Anything/Sensor.h index b6166ad3..2d3738b4 100755 --- a/Arduino/libraries/ST_Anything/Sensor.h +++ b/Arduino/libraries/ST_Anything/Sensor.h @@ -29,7 +29,7 @@ namespace st public: //constructor - Sensor(const char *name); + Sensor(const __FlashStringHelper *name); //destructor virtual ~Sensor(); diff --git a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp index 0001a827..94d28f96 100644 --- a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp +++ b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.cpp @@ -18,7 +18,7 @@ // - int8_t pinCS - REQUIRED - the Arduino Pin to be used as the MAX31855 CS // - int8_t pinMISO - REQUIRED - the Arduino Pin to be used as the MAX31855 MISO // -// This class supports receiving configuiration data from the SmartThings cloud via the ST App. A user preference +// This class supports receiving configuration data from the SmartThings cloud via the ST App. A user preference // can be configured in your phone's ST App, and then the "Configure" tile will send the data for all sensors to // the ST Shield. For PollingSensors, this data is handled in the beSMart() function. // @@ -47,7 +47,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_AdafruitThermocouple::PS_AdafruitThermocouple(const char *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO): + PS_AdafruitThermocouple::PS_AdafruitThermocouple(const __FlashStringHelper *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO): PollingSensor(name, interval, offset), m_dblTemperatureSensorValue(0.0), m_Adafruit_MAX31855(Adafruit_MAX31855(pinSCLK, pinCS, pinMISO)) diff --git a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h index 56c2a24c..f0485202 100644 --- a/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h +++ b/Arduino/libraries/ST_Anything_AdafruitThermocouple/PS_AdafruitThermocouple.h @@ -18,7 +18,7 @@ // - int8_t pinCS - REQUIRED - the Arduino Pin to be used as the MAX31855 CS // - int8_t pinMISO - REQUIRED - the Arduino Pin to be used as the MAX31855 MISO // -// This class supports receiving configuiration data from the SmartThings cloud via the ST App. A user preference +// This class supports receiving configuration data from the SmartThings cloud via the ST App. A user preference // can be configured in your phone's ST App, and then the "Configure" tile will send the data for all sensors to // the ST Shield. For PollingSensors, this data is handled in the beSMart() function. // @@ -51,7 +51,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - PS_AdafruitThermocouple(const char *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO); + PS_AdafruitThermocouple(const __FlashStringHelper *name, unsigned int interval, int offset, int8_t pinSCLK, int8_t pinCS, int8_t pinMISO); //destructor virtual ~PS_AdafruitThermocouple(); diff --git a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp index 60314d8b..98192541 100644 --- a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp +++ b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.cpp @@ -50,7 +50,7 @@ namespace st //public //constructor - EX_RCSwitch::EX_RCSwitch(const char *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState) : + EX_RCSwitch::EX_RCSwitch(const __FlashStringHelper *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState) : Executor(name), m_bCurrentState(startingState), m_myRCSwitch(RCSwitch()), diff --git a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h index 3deef137..aa59059c 100644 --- a/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h +++ b/Arduino/libraries/ST_Anything_RCSwitch/EX_RCSwitch.h @@ -48,7 +48,7 @@ namespace st public: //constructor - called in your sketch's global variable declaration section - EX_RCSwitch(const char *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState = LOW); + EX_RCSwitch(const __FlashStringHelper *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, bool startingState = LOW); //destructor virtual ~EX_RCSwitch(); diff --git a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp index a8801b2a..a638ed82 100644 --- a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp +++ b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp @@ -19,7 +19,7 @@ // - String strTemp - OPTIONAL - name of temperature sensor to send to ST Cloud (defaults to "temperature") // - String strHumid - OPTIONAL - name of humidity sensor to send to ST Cloud (defaults to "humidity") // -// This class supports receiving configuiration data from the SmartThings cloud via the ST App. A user preference +// This class supports receiving configuration data from the SmartThings cloud via the ST App. A user preference // can be configured in your phone's ST App, and then the "Configure" tile will send the data for all sensors to // the ST Shield. For PollingSensors, this data is handled in the beSMart() function. // @@ -49,7 +49,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_TemperatureHumidity::PS_TemperatureHumidity(const char *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp, String strHumid) : + PS_TemperatureHumidity::PS_TemperatureHumidity(const __FlashStringHelper *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp, String strHumid) : PollingSensor(name, interval, offset), m_nTemperatureSensorValue(0), m_nHumiditySensorValue(0), diff --git a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h index 06701e6e..ee62935a 100644 --- a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h +++ b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.h @@ -19,7 +19,7 @@ // - String strTemp - OPTIONAL - name of temperature sensor to send to ST Cloud (defaults to "temperature") // - String strHumid - OPTIONAL - name of humidity sensor to send to ST Cloud (defaults to "humidity") // -// This class supports receiving configuiration data from the SmartThings cloud via the ST App. A user preference +// This class supports receiving configuration data from the SmartThings cloud via the ST App. A user preference // can be configured in your phone's ST App, and then the "Configure" tile will send the data for all sensors to // the ST Shield. For PollingSensors, this data is handled in the beSMart() function. // @@ -61,7 +61,7 @@ namespace st enum DHT_SENSOR { DHT11, DHT21, DHT22, DHT33, DHT44 }; //constructor - called in your sketch's global variable declaration section - PS_TemperatureHumidity(const char *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp="temperature", String strHumid="humidity"); + PS_TemperatureHumidity(const __FlashStringHelper *name, unsigned int interval, int offset, byte digitalInputPin, DHT_SENSOR DHTSensorType, String strTemp="temperature", String strHumid="humidity"); //destructor virtual ~PS_TemperatureHumidity(); From e08abed065ce401b8c0681674634c65d1af04c57 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 21:59:04 -0400 Subject: [PATCH 03/11] cleaned up some things --- Arduino/libraries/ST_Anything/Device.cpp | 5 ++++- Arduino/libraries/ST_Anything/Everything.cpp | 9 --------- Arduino/libraries/ST_Anything/Everything.h | 3 +-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Arduino/libraries/ST_Anything/Device.cpp b/Arduino/libraries/ST_Anything/Device.cpp index 5a4cfac7..87b62da4 100755 --- a/Arduino/libraries/ST_Anything/Device.cpp +++ b/Arduino/libraries/ST_Anything/Device.cpp @@ -52,7 +52,10 @@ namespace st const String Device::getName() const { - return Everything::progmemToString(m_pName); + char tmp[Constants::MAX_NAME_LENGTH]; + strcpy_P(tmp, (const char*)m_pName); + + return String(tmp); } diff --git a/Arduino/libraries/ST_Anything/Everything.cpp b/Arduino/libraries/ST_Anything/Everything.cpp index 4c4422fe..517832fd 100755 --- a/Arduino/libraries/ST_Anything/Everything.cpp +++ b/Arduino/libraries/ST_Anything/Everything.cpp @@ -338,15 +338,6 @@ namespace st return true; } - String Everything::progmemToString(const __FlashStringHelper *s) - { - char tmp[Constants::MAX_NAME_LENGTH]; - strcpy_P(tmp, (const char*)s); - - String rStr(tmp); - return rStr; - } - //friends! void receiveSmartString(String message) { diff --git a/Arduino/libraries/ST_Anything/Everything.h b/Arduino/libraries/ST_Anything/Everything.h index 012df749..acdb2a33 100755 --- a/Arduino/libraries/ST_Anything/Everything.h +++ b/Arduino/libraries/ST_Anything/Everything.h @@ -90,8 +90,7 @@ namespace st static bool debug; //debug flag to determine if debug print statements are executed - set value in your sketch's setup() routine - static String progmemToString(const __FlashStringHelper *s); //conveniently converts a string stored in progmem into a String object - + friend SmartThingsCallout_t receiveSmartString; //callback function to act on data received from SmartThings Shield - called from SmartThings Shield Library From 6ffe866b73bea3fb36164ef20eb66727cc61145e Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 22:10:14 -0400 Subject: [PATCH 04/11] modified Doors sketch to support new optimizations --- .../ST_Anything_Doors/ST_Anything_Doors.ino | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino b/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino index 3380a527..8e1eaa1a 100644 --- a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino +++ b/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino @@ -39,7 +39,7 @@ // 2015-01-03 Dan & Daniel Original Creation // 2015-01-07 Dan Ogorchock Modified for Door Monitoring and Garage Door Control // 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** @@ -49,6 +49,7 @@ #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield #include //DHT Temperature and Humidity Library +#include //****************************************************************************************** // ST_Anything Library @@ -108,20 +109,7 @@ // particular sensor is sent to the ST Shield in two separate updates, one for // "temperature" and one for "humidity") //****************************************************************************************** -//Polling Sensors -st::PS_TemperatureHumidity sensor1("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); - -//Interrupt Sensors -st::IS_Motion sensor2("motion", PIN_MOTION, HIGH, false); -st::IS_DoorControl sensor3("leftDoor", PIN_CONTACT_LEFTGARAGE_DOOR, LOW, true, PIN_RELAY_LEFTGARAGE_DOOR, LOW, true, 1000); -st::IS_DoorControl sensor4("rightDoor", PIN_CONTACT_RIGHTGARAGE_DOOR, LOW, true, PIN_RELAY_RIGHTGARAGE_DOOR, LOW, true, 1000); -st::IS_Contact sensor5("garagesideDoor", PIN_CONTACT_SIDEGARAGE_DOOR, LOW, true); -st::IS_Contact sensor6("frontDoor", PIN_CONTACT_FRONT_DOOR, LOW, true); -st::IS_Contact sensor7("backDoor", PIN_CONTACT_BACK_DOOR, LOW, true); -st::IS_Contact sensor8("kitchenDoor", PIN_CONTACT_KITCHEN_DOOR, LOW, true); -//Executors -//st::EX_Switch executor1("sampleEX", PIN_sampleEX, LOW, true); //****************************************************************************************** @@ -148,14 +136,16 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); - st::Everything::addSensor(&sensor7); - st::Everything::addSensor(&sensor8); + //polling sensors + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22)); + //interrupt sensors + st::Everything::addSensor(new st::IS_Motion(F("motion"), PIN_MOTION, HIGH, false)); + st::Everything::addSensor(new st::IS_DoorControl(F("leftDoor"), PIN_CONTACT_LEFTGARAGE_DOOR, LOW, true, PIN_RELAY_LEFTGARAGE_DOOR, LOW, true, 1000)); + st::Everything::addSensor(new st::IS_DoorControl(F("rightDoor"), PIN_CONTACT_RIGHTGARAGE_DOOR, LOW, true, PIN_RELAY_RIGHTGARAGE_DOOR, LOW, true, 1000)); + st::Everything::addSensor(new st::IS_Contact(F("garagesideDoor"), PIN_CONTACT_SIDEGARAGE_DOOR, LOW, true)); + st::Everything::addSensor(new st::IS_Contact(F("frontDoor"), PIN_CONTACT_FRONT_DOOR, LOW, true)); + st::Everything::addSensor(new st::IS_Contact(F("backDoor"), PIN_CONTACT_BACK_DOOR, LOW, true)); + st::Everything::addSensor(new st::IS_Contact(F("kitchenDoor"), PIN_CONTACT_KITCHEN_DOOR, LOW, true)); //***************************************************************************** //Add each executor to the "Everything" Class @@ -177,4 +167,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} From 7792b90c46656fdf1536240f5b534586b37f21b1 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 22:16:24 -0400 Subject: [PATCH 05/11] updated FurnaceAlarm sketch to work with optimizations --- .../ST_Anything_FurnaceAlarm.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino b/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino index 58a33d43..a4494b0b 100644 --- a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino +++ b/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino @@ -33,7 +33,7 @@ // 2015-01-03 Dan & Daniel Original Creation // 2015-03-10 Dan Modified to monitor furnace alarm // 2015-03-14 Dan Added LED capability for visual status of the FurnaceAlarm -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** @@ -42,6 +42,7 @@ //****************************************************************************************** #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield +#include //****************************************************************************************** // ST_Anything Library @@ -87,9 +88,7 @@ //Polling Sensors //Interrupt Sensors -st::IS_Contact sensor1("contact", PIN_CONTACT, LOW, true, 20000); - -//Executors +st::IS_Contact *sensor1; //Global Variables @@ -100,6 +99,8 @@ bool lastStatus; //Hold the last status of the Furnace Alarm to prevent updatin //****************************************************************************************** void setup() { + sensor1=new st::IS_Contact(F("contact"), PIN_CONTACT, LOW, true, 20000); + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -119,7 +120,7 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - st::Everything::addSensor(&sensor1); + st::Everything::addSensor(sensor1); //***************************************************************************** //Add each executor to the "Everything" Class @@ -131,7 +132,7 @@ void setup() //***************************************************************************** //Set the lastStatus variable to force the LED update the first time through the loop() - lastStatus = !sensor1.getStatus(); + lastStatus = !sensor1->getStatus(); } @@ -147,18 +148,18 @@ void loop() //Check to see if the Furnace is in Alarm. If true, set the Smart Thing Shield //LED to Red. If false, set the LED to Green. - if (sensor1.getStatus() && !lastStatus) + if (sensor1->getStatus() && !lastStatus) { //ALARM!!! (Red) st::Everything::setLED(2,0,0); lastStatus = true; } - else if (!sensor1.getStatus() && lastStatus) + else if (!sensor1->getStatus() && lastStatus) { //NORMAL (Green) st::Everything::setLED(0,2,0); lastStatus = false; } -} +} From 0c8a7c7c5982cf52b6458e59d4fd9f43644b8b51 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 22:21:05 -0400 Subject: [PATCH 06/11] updated RCSwitch sketch --- .../ST_Anything_RCSwitch.ino | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino b/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino index 7ef52655..b14dabfa 100644 --- a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino +++ b/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino @@ -27,7 +27,7 @@ // 2015-01-03 Dan & Daniel Original Creation // 2015-01-26 Dan Added RCSwitch support/example // 2015-01-30 Dan Cleaned up specificailly for RCSwitch use exclusively for size -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** @@ -37,6 +37,7 @@ #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield #include //Library to provide support for RCSwitch devices +#include //****************************************************************************************** // ST_Anything Library @@ -74,14 +75,7 @@ // - The name assigned to each device (1st argument below) must match the Groovy // DeviceType Tile name in your custom DeviceType code. //****************************************************************************************** -//Polling Sensors - -//Interrupt Sensors -//Executors -st::EX_RCSwitch executor1("rcswitch1", PIN_RCSWITCH, 35754004, 26, 18976788, 26); -st::EX_RCSwitch executor2("rcswitch2", PIN_RCSWITCH, 35751956, 26, 18974740, 26); -st::EX_RCSwitch executor3("rcswitch3", PIN_RCSWITCH, 35756052, 26, 18978836, 26); //****************************************************************************************** //Arduino Setup() routine @@ -109,9 +103,9 @@ void setup() //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(&executor1); - st::Everything::addExecutor(&executor2); - st::Everything::addExecutor(&executor3); + st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch1"), PIN_RCSWITCH, 35754004, 26, 18976788, 26)); + st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch2"), PIN_RCSWITCH, 35751956, 26, 18974740, 26)); + st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch3"), PIN_RCSWITCH, 35756052, 26, 18978836, 26)); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class @@ -128,4 +122,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} From 18d06cce5c24a870d937766c085813557f22f45c Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 22:30:12 -0400 Subject: [PATCH 07/11] updated Relays sketch --- .../ST_Anything_Relays/ST_Anything_Relays.ino | 108 +++++++++--------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino b/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino index 7bdc9d96..801dc55f 100644 --- a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino +++ b/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino @@ -32,7 +32,7 @@ // ---- --- ---- // 2015-01-03 Dan & Daniel Original Creation // 2015-03-27 Dan Ogorchock Modified for 16 Relay + 16 Pushbuttons Design -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** @@ -52,6 +52,7 @@ #include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications #include //Implements an Executor (EX) via a digital output to a relay +#include //****************************************************************************************** //Define which Arduino Pins will be used for each device @@ -131,31 +132,32 @@ st::EX_Switch* swArray[MAX_PUSHBUTTONS]; //need an array of the executors so we //Interrupt Sensors -//Executors - - //EX_Switch arguments(name, pin, starting state, invert logic) change last 2 args as needed for your application -st::EX_Switch executor1("switch1", PIN_RELAY1, LOW, false); -st::EX_Switch executor2("switch2", PIN_RELAY2, LOW, false); -st::EX_Switch executor3("switch3", PIN_RELAY3, LOW, false); -st::EX_Switch executor4("switch4", PIN_RELAY4, LOW, false); -st::EX_Switch executor5("switch5", PIN_RELAY5, LOW, false); -st::EX_Switch executor6("switch6", PIN_RELAY6, LOW, false); -st::EX_Switch executor7("switch7", PIN_RELAY7, LOW, false); -st::EX_Switch executor8("switch8", PIN_RELAY8, LOW, false); -st::EX_Switch executor9("switch9", PIN_RELAY9, LOW, false); -st::EX_Switch executor10("switch10", PIN_RELAY10, LOW, false); -st::EX_Switch executor11("switch11", PIN_RELAY11, LOW, false); -st::EX_Switch executor12("switch12", PIN_RELAY12, LOW, false); -st::EX_Switch executor13("switch13", PIN_RELAY13, LOW, false); -st::EX_Switch executor14("switch14", PIN_RELAY14, LOW, false); -st::EX_Switch executor15("switch15", PIN_RELAY15, LOW, false); -st::EX_Switch executor16("switch16", PIN_RELAY16, LOW, false); + //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //Executors + //EX_Switch arguments(name, pin, starting state, invert logic) change last 2 args as needed for your application + st::EX_Switch *executor1=new st::EX_Switch(F("switch1"), PIN_RELAY1, LOW, false); + st::EX_Switch *executor2=new st::EX_Switch(F("switch2"), PIN_RELAY2, LOW, false); + st::EX_Switch *executor3=new st::EX_Switch(F("switch3"), PIN_RELAY3, LOW, false); + st::EX_Switch *executor4=new st::EX_Switch(F("switch4"), PIN_RELAY4, LOW, false); + st::EX_Switch *executor5=new st::EX_Switch(F("switch5"), PIN_RELAY5, LOW, false); + st::EX_Switch *executor6=new st::EX_Switch(F("switch6"), PIN_RELAY6, LOW, false); + st::EX_Switch *executor7=new st::EX_Switch(F("switch7"), PIN_RELAY7, LOW, false); + st::EX_Switch *executor8=new st::EX_Switch(F("switch8"), PIN_RELAY8, LOW, false); + st::EX_Switch *executor9=new st::EX_Switch(F("switch9"), PIN_RELAY9, LOW, false); + st::EX_Switch *executor10=new st::EX_Switch(F("switch10"), PIN_RELAY10, LOW, false); + st::EX_Switch *executor11=new st::EX_Switch(F("switch11"), PIN_RELAY11, LOW, false); + st::EX_Switch *executor12=new st::EX_Switch(F("switch12"), PIN_RELAY12, LOW, false); + st::EX_Switch *executor13=new st::EX_Switch(F("switch13"), PIN_RELAY13, LOW, false); + st::EX_Switch *executor14=new st::EX_Switch(F("switch14"), PIN_RELAY14, LOW, false); + st::EX_Switch *executor15=new st::EX_Switch(F("switch15"), PIN_RELAY15, LOW, false); + st::EX_Switch *executor16=new st::EX_Switch(F("switch16"), PIN_RELAY16, LOW, false); + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -177,22 +179,22 @@ void setup() //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(&executor1); - st::Everything::addExecutor(&executor2); - st::Everything::addExecutor(&executor3); - st::Everything::addExecutor(&executor4); - st::Everything::addExecutor(&executor5); - st::Everything::addExecutor(&executor6); - st::Everything::addExecutor(&executor7); - st::Everything::addExecutor(&executor8); - st::Everything::addExecutor(&executor9); - st::Everything::addExecutor(&executor10); - st::Everything::addExecutor(&executor11); - st::Everything::addExecutor(&executor12); - st::Everything::addExecutor(&executor13); - st::Everything::addExecutor(&executor14); - st::Everything::addExecutor(&executor15); - st::Everything::addExecutor(&executor16); + st::Everything::addExecutor(executor1); + st::Everything::addExecutor(executor2); + st::Everything::addExecutor(executor3); + st::Everything::addExecutor(executor4); + st::Everything::addExecutor(executor5); + st::Everything::addExecutor(executor6); + st::Everything::addExecutor(executor7); + st::Everything::addExecutor(executor8); + st::Everything::addExecutor(executor9); + st::Everything::addExecutor(executor10); + st::Everything::addExecutor(executor11); + st::Everything::addExecutor(executor12); + st::Everything::addExecutor(executor13); + st::Everything::addExecutor(executor14); + st::Everything::addExecutor(executor15); + st::Everything::addExecutor(executor16); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class @@ -203,22 +205,22 @@ void setup() //Add User Customized Setup Code Here (instead of modifying standard library files) //***************************************************************************** //---Begin Push Button initialization section--- - swArray[0]=&executor1; - swArray[1]=&executor2; - swArray[2]=&executor3; - swArray[3]=&executor4; - swArray[4]=&executor5; - swArray[5]=&executor6; - swArray[6]=&executor7; - swArray[7]=&executor8; - swArray[8]=&executor9; - swArray[9]=&executor10; - swArray[10]=&executor11; - swArray[11]=&executor12; - swArray[12]=&executor13; - swArray[13]=&executor14; - swArray[14]=&executor15; - swArray[15]=&executor16; + swArray[0]=executor1; + swArray[1]=executor2; + swArray[2]=executor3; + swArray[3]=executor4; + swArray[4]=executor5; + swArray[5]=executor6; + swArray[6]=executor7; + swArray[7]=executor8; + swArray[8]=executor9; + swArray[9]=executor10; + swArray[10]=executor11; + swArray[11]=executor12; + swArray[12]=executor13; + swArray[13]=executor14; + swArray[14]=executor15; + swArray[15]=executor16; //Allocate strCommand buffer one time to prevent Heap Fragmentation. strCommand.reserve(20); @@ -271,4 +273,4 @@ void loop() nBtnVals[nBtnIndex][1] = nCurrentVal; //keep last value for proper debounce logic } //---End Push Button execution section--- -} +} From d476eaeec20aa275e9305f7ad84e84650b2e3b68 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 31 Mar 2015 22:37:31 -0400 Subject: [PATCH 08/11] updated temperatures sketch --- .../ST_Anything_Temperatures.ino | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino b/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino index c5c9d356..d5a3b330 100644 --- a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino +++ b/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino @@ -56,7 +56,7 @@ // ---- --- ---- // 2015-01-03 Dan & Daniel Original Creation // 2015-03-24 Dan Ogorchock Modified to just monitor multiple DTHT Temp/Humid sensors -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** @@ -81,7 +81,7 @@ #include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library #include //Implements a Polling Sensor (PS) to measure Temperature via Adafruit_MAX31855 library - +#include //****************************************************************************************** //Define which Arduino Pins will be used for each device // Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 @@ -124,12 +124,12 @@ // //****************************************************************************************** //Polling Sensors -st::PS_TemperatureHumidity sensor1("th_Freezer", 30, 3, PIN_TEMPHUMID_FREEZER, st::PS_TemperatureHumidity::DHT22, "t_Freezer", "h_Freezer"); -st::PS_TemperatureHumidity sensor2("th_Fridge", 30, 5, PIN_TEMPHUMID_FRIDGE, st::PS_TemperatureHumidity::DHT22, "t_Fridge", "h_Fridge"); -st::PS_TemperatureHumidity sensor3("th_Moistcrisp", 30, 7, PIN_TEMPHUMID_MOISTCRISP, st::PS_TemperatureHumidity::DHT22, "t_Moistcrisp", "h_Moistcrisp"); -st::PS_TemperatureHumidity sensor4("th_Othercrisp", 30, 9, PIN_TEMPHUMID_OTHERCRISP, st::PS_TemperatureHumidity::DHT22, "t_Othercrisp", "h_Othercrisp"); -st::PS_AdafruitThermocouple sensor5("t_Oven", 10, 0, PIN_SCLK, PIN_CS, PIN_MISO_OVEN); -st::PS_AdafruitThermocouple sensor6("t_Broiler", 10, 2, PIN_SCLK, PIN_CS, PIN_MISO_BROILER); +; +; +; +; +; +; //Interrupt Sensors @@ -160,12 +160,12 @@ void setup() //Add each sensor to the "Everything" Class // TODO: Customize based on sensors defined in global section above //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Freezer"), 30, 3, PIN_TEMPHUMID_FREEZER, st::PS_TemperatureHumidity::DHT22, "t_Freezer", "h_Freezer")); + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Fridge"), 30, 5, PIN_TEMPHUMID_FRIDGE, st::PS_TemperatureHumidity::DHT22, "t_Fridge", "h_Fridge")); + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Moistcrisp"), 30, 7, PIN_TEMPHUMID_MOISTCRISP, st::PS_TemperatureHumidity::DHT22, "t_Moistcrisp", "h_Moistcrisp")); + st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Othercrisp"), 30, 9, PIN_TEMPHUMID_OTHERCRISP, st::PS_TemperatureHumidity::DHT22, "t_Othercrisp", "h_Othercrisp")); + st::Everything::addSensor(new st::PS_AdafruitThermocouple(F("t_Oven"), 10, 0, PIN_SCLK, PIN_CS, PIN_MISO_OVEN)); + st::Everything::addSensor(new st::PS_AdafruitThermocouple(F("t_Broiler"), 10, 2, PIN_SCLK, PIN_CS, PIN_MISO_BROILER)); //***************************************************************************** //Add each executor to the "Everything" Class @@ -187,4 +187,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} From 7b4ebee134ef07fd6180dd9b24f5eb702dcad701 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 14 Apr 2015 23:10:41 -0400 Subject: [PATCH 09/11] debug info for having too many sensors/executors --- Arduino/libraries/ST_Anything/Everything.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Arduino/libraries/ST_Anything/Everything.cpp b/Arduino/libraries/ST_Anything/Everything.cpp index 517832fd..81809985 100755 --- a/Arduino/libraries/ST_Anything/Everything.cpp +++ b/Arduino/libraries/ST_Anything/Everything.cpp @@ -298,6 +298,12 @@ namespace st { if(m_nSensorCount>=Constants::MAX_SENSOR_COUNT) { + if(debug) + { + Serial.print(F("Did not add sensor named ")); + Serial.print(sensor->getName()); + Serial.println(F("(You've exceeded maximum number of sensors; edit Constants.h)")); + } return false; } else @@ -320,6 +326,12 @@ namespace st { if(m_nExecutorCount>=Constants::MAX_EXECUTOR_COUNT) { + if(debug) + { + Serial.print(F("Did not add executor named ")); + Serial.print(executor->getName()); + Serial.println(F("(You've exceeded maximum number of executors; edit Constants.h)")); + } return false; } else From 844253939997c1b93c2125f6fa5592b12f90f93a Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 14 Apr 2015 23:11:27 -0400 Subject: [PATCH 10/11] sketches now declare objects on stack again (far more stable) --- Arduino/Sketches/ST_Anything/ST_Anything.ino | 67 ++++----- .../ST_Anything_Doors/ST_Anything_Doors.ino | 59 ++++---- .../ST_Anything_FurnaceAlarm.ino | 52 +++---- .../ST_Anything_RCSwitch.ino | 36 +++-- .../ST_Anything_Relays/ST_Anything_Relays.ino | 128 +++++++++--------- .../ST_Anything_Temperatures.ino | 68 +++++----- 6 files changed, 219 insertions(+), 191 deletions(-) diff --git a/Arduino/Sketches/ST_Anything/ST_Anything.ino b/Arduino/Sketches/ST_Anything/ST_Anything.ino index 5d51c9f1..5d0f1abb 100755 --- a/Arduino/Sketches/ST_Anything/ST_Anything.ino +++ b/Arduino/Sketches/ST_Anything/ST_Anything.ino @@ -32,10 +32,9 @@ // ---- --- ---- // 2015-01-03 Dan & Daniel Original Creation // 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// +// 2015-03-31 Daniel O. Memory optimizations utilizing progmem // //****************************************************************************************** - //****************************************************************************************** // SmartThings Library for Arduino Shield //****************************************************************************************** @@ -86,36 +85,39 @@ #define PIN_ALARM 9 #define PIN_CONTACT 11 -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name. (Note: "temphumid" below is the exception to this rule -// as the DHT sensors produce both "temperature" and "humidity". Data from that -// particular sensor is sent to the ST Shield in two separate updates, one for -// "temperature" and one for "humidity") -//****************************************************************************************** -//Polling Sensors -//st::PS_Illuminance sensor1("illuminance", 120, 0, PIN_ILLUMINANCE); -//st::PS_TemperatureHumidity sensor2("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); -//st::PS_Water sensor3("water", 60, 20, PIN_WATER); -//Interrupt Sensors -//st::IS_Motion sensor4("motion", PIN_MOTION, HIGH, false); -//st::IS_Contact sensor5("contact", PIN_CONTACT, LOW, true); -//Executors -//st::EX_Switch executor1("switch", PIN_SWITCH, LOW, true); -//st::EX_Alarm executor2("alarm", PIN_ALARM, LOW, true); //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Shield in two separate updates, one for + // "temperature" and one for "humidity") + //****************************************************************************************** + //Polling Sensors + static st::PS_Illuminance sensor1(F("illuminance"), 120, 0, PIN_ILLUMINANCE); + static st::PS_TemperatureHumidity sensor2(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); + static st::PS_Water sensor3(F("water"), 60, 20, PIN_WATER); + + //Interrupt Sensors + static st::IS_Motion sensor4(F("motion"), PIN_MOTION, HIGH, false); + static st::IS_Contact sensor5(F("contact"), PIN_CONTACT, LOW, true); + + //Executors + static st::EX_Switch executor1(F("switch"), PIN_SWITCH, LOW, true); + static st::EX_Alarm executor2(F("alarm"), PIN_ALARM, LOW, true); + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -126,6 +128,7 @@ void setup() st::Device::debug=true; st::PollingSensor::debug=true; st::InterruptSensor::debug=true; + //***************************************************************************** //Initialize the "Everything" Class //***************************************************************************** @@ -134,19 +137,17 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - //polling sensors - st::Everything::addSensor(new st::PS_Illuminance(F("illuminance"), 120, 0, PIN_ILLUMINANCE)); - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22)); - st::Everything::addSensor(new st::PS_Water(F("water"), 60, 20, PIN_WATER)); - //interrupt sensors - st::Everything::addSensor(new st::IS_Motion(F("motion"), PIN_MOTION, HIGH, false)); - st::Everything::addSensor(new st::IS_Contact(F("contact"), PIN_CONTACT, LOW, true)); + st::Everything::addSensor(&sensor1); + st::Everything::addSensor(&sensor2); + st::Everything::addSensor(&sensor3); + st::Everything::addSensor(&sensor4); + st::Everything::addSensor(&sensor5); //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(new st::EX_Switch(F("switch"), PIN_SWITCH, LOW, true)); - st::Everything::addExecutor(new st::EX_Alarm(F("alarm"), PIN_ALARM, LOW, true)); + st::Everything::addExecutor(&executor1); + st::Everything::addExecutor(&executor2); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class diff --git a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino b/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino index 8e1eaa1a..6c941a81 100644 --- a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino +++ b/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino @@ -97,19 +97,6 @@ #define PIN_CONTACT_KITCHEN_DOOR 12 #define PIN_CONTACT_SIDEGARAGE_DOOR 13 -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name. (Note: "temphumid" below is the exception to this rule -// as the DHT sensors produce both "temperature" and "humidity". Data from that -// particular sensor is sent to the ST Shield in two separate updates, one for -// "temperature" and one for "humidity") -//****************************************************************************************** - //****************************************************************************************** @@ -117,6 +104,34 @@ //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Shield in two separate updates, one for + // "temperature" and one for "humidity") + //****************************************************************************************** + //Polling Sensors + static st::PS_TemperatureHumidity sensor1(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); + + //Interrupt Sensors + static st::IS_Motion sensor2(F("motion"), PIN_MOTION, HIGH, false); + static st::IS_DoorControl sensor3(F("leftDoor"), PIN_CONTACT_LEFTGARAGE_DOOR, LOW, true, PIN_RELAY_LEFTGARAGE_DOOR, LOW, true, 1000); + static st::IS_DoorControl sensor4(F("rightDoor"), PIN_CONTACT_RIGHTGARAGE_DOOR, LOW, true, PIN_RELAY_RIGHTGARAGE_DOOR, LOW, true, 1000); + static st::IS_Contact sensor5(F("garagesideDoor"), PIN_CONTACT_SIDEGARAGE_DOOR, LOW, true); + static st::IS_Contact sensor6(F("frontDoor"), PIN_CONTACT_FRONT_DOOR, LOW, true); + static st::IS_Contact sensor7(F("backDoor"), PIN_CONTACT_BACK_DOOR, LOW, true); + static st::IS_Contact sensor8(F("kitchenDoor"), PIN_CONTACT_KITCHEN_DOOR, LOW, true); + + //Executors + //static st::EX_Switch executor1(F("sampleEX"), PIN_sampleEX, LOW, true); + + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -136,16 +151,14 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - //polling sensors - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22)); - //interrupt sensors - st::Everything::addSensor(new st::IS_Motion(F("motion"), PIN_MOTION, HIGH, false)); - st::Everything::addSensor(new st::IS_DoorControl(F("leftDoor"), PIN_CONTACT_LEFTGARAGE_DOOR, LOW, true, PIN_RELAY_LEFTGARAGE_DOOR, LOW, true, 1000)); - st::Everything::addSensor(new st::IS_DoorControl(F("rightDoor"), PIN_CONTACT_RIGHTGARAGE_DOOR, LOW, true, PIN_RELAY_RIGHTGARAGE_DOOR, LOW, true, 1000)); - st::Everything::addSensor(new st::IS_Contact(F("garagesideDoor"), PIN_CONTACT_SIDEGARAGE_DOOR, LOW, true)); - st::Everything::addSensor(new st::IS_Contact(F("frontDoor"), PIN_CONTACT_FRONT_DOOR, LOW, true)); - st::Everything::addSensor(new st::IS_Contact(F("backDoor"), PIN_CONTACT_BACK_DOOR, LOW, true)); - st::Everything::addSensor(new st::IS_Contact(F("kitchenDoor"), PIN_CONTACT_KITCHEN_DOOR, LOW, true)); + st::Everything::addSensor(&sensor1); + st::Everything::addSensor(&sensor2); + st::Everything::addSensor(&sensor3); + st::Everything::addSensor(&sensor4); + st::Everything::addSensor(&sensor5); + st::Everything::addSensor(&sensor6); + st::Everything::addSensor(&sensor7); + st::Everything::addSensor(&sensor8); //***************************************************************************** //Add each executor to the "Everything" Class diff --git a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino b/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino index a4494b0b..5b476075 100644 --- a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino +++ b/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino @@ -42,7 +42,7 @@ //****************************************************************************************** #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield -#include +#include //****************************************************************************************** // ST_Anything Library @@ -73,34 +73,37 @@ #define PIN_CONTACT 11 -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name. (Note: "temphumid" below is the exception to this rule -// as the DHT sensors produce both "temperature" and "humidity". Data from that -// particular sensor is sent to the ST Shield in two separate updates, one for -// "temperature" and one for "humidity") -//****************************************************************************************** -//Polling Sensors - -//Interrupt Sensors -st::IS_Contact *sensor1; - //Global Variables bool lastStatus; //Hold the last status of the Furnace Alarm to prevent updating the LED too frequently +st::IS_Contact *sensor1p; //pointer for use in main loop //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { - sensor1=new st::IS_Contact(F("contact"), PIN_CONTACT, LOW, true, 20000); + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Shield in two separate updates, one for + // "temperature" and one for "humidity") + //****************************************************************************************** + //Polling Sensors + //Interrupt Sensors + static st::IS_Contact sensor1(F("contact"), PIN_CONTACT, LOW, true, 20000); + sensor1p=&sensor1; + + //Executors + + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -120,7 +123,7 @@ void setup() //***************************************************************************** //Add each sensor to the "Everything" Class //***************************************************************************** - st::Everything::addSensor(sensor1); + st::Everything::addSensor(&sensor1); //***************************************************************************** //Add each executor to the "Everything" Class @@ -132,7 +135,7 @@ void setup() //***************************************************************************** //Set the lastStatus variable to force the LED update the first time through the loop() - lastStatus = !sensor1->getStatus(); + lastStatus = !sensor1.getStatus(); } @@ -148,18 +151,19 @@ void loop() //Check to see if the Furnace is in Alarm. If true, set the Smart Thing Shield //LED to Red. If false, set the LED to Green. - if (sensor1->getStatus() && !lastStatus) + if (sensor1p->getStatus() && !lastStatus) { //ALARM!!! (Red) st::Everything::setLED(2,0,0); lastStatus = true; } - else if (!sensor1->getStatus() && lastStatus) + else if (!sensor1p->getStatus() && lastStatus) { //NORMAL (Green) st::Everything::setLED(0,2,0); lastStatus = false; } -} +} + diff --git a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino b/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino index b14dabfa..654e24f5 100644 --- a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino +++ b/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino @@ -37,7 +37,7 @@ #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield #include //Library to provide support for RCSwitch devices -#include +#include //****************************************************************************************** // ST_Anything Library @@ -66,22 +66,30 @@ #define PIN_RCSWITCH 12 -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// main comments in the corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name in your custom DeviceType code. -//****************************************************************************************** - //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // main comments in the corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name in your custom DeviceType code. + //****************************************************************************************** + //Polling Sensors + + //Interrupt Sensors + + //Executors + static st::EX_RCSwitch executor1(F("rcswitch1"), PIN_RCSWITCH, 35754004, 26, 18976788, 26); + static st::EX_RCSwitch executor2(F("rcswitch2"), PIN_RCSWITCH, 35751956, 26, 18974740, 26); + static st::EX_RCSwitch executor3(F("rcswitch3"), PIN_RCSWITCH, 35756052, 26, 18978836, 26); + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -103,9 +111,9 @@ void setup() //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch1"), PIN_RCSWITCH, 35754004, 26, 18976788, 26)); - st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch2"), PIN_RCSWITCH, 35751956, 26, 18974740, 26)); - st::Everything::addExecutor(new st::EX_RCSwitch(F("rcswitch3"), PIN_RCSWITCH, 35756052, 26, 18978836, 26)); + st::Everything::addExecutor(&executor1); + st::Everything::addExecutor(&executor2); + st::Everything::addExecutor(&executor3); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class diff --git a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino b/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino index 801dc55f..9f25ef60 100644 --- a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino +++ b/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino @@ -41,6 +41,7 @@ //****************************************************************************************** #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield +#include //****************************************************************************************** // ST_Anything Library @@ -52,7 +53,6 @@ #include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications #include //Implements an Executor (EX) via a digital output to a relay -#include //****************************************************************************************** //Define which Arduino Pins will be used for each device @@ -119,45 +119,45 @@ unsigned long lngBtnLastMillis[MAX_PUSHBUTTONS]; //needed to properly debounce t st::EX_Switch* swArray[MAX_PUSHBUTTONS]; //need an array of the executors so we can togle the correct one //---End Push Button declarations--- -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// main comments in the corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name in your custom DeviceType code. -//****************************************************************************************** -//Polling Sensors - -//Interrupt Sensors - - //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // main comments in the corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name in your custom DeviceType code. + //****************************************************************************************** + //Polling Sensors + + //Interrupt Sensors + //Executors + //EX_Switch arguments(name, pin, starting state, invert logic) change last 2 args as needed for your application - st::EX_Switch *executor1=new st::EX_Switch(F("switch1"), PIN_RELAY1, LOW, false); - st::EX_Switch *executor2=new st::EX_Switch(F("switch2"), PIN_RELAY2, LOW, false); - st::EX_Switch *executor3=new st::EX_Switch(F("switch3"), PIN_RELAY3, LOW, false); - st::EX_Switch *executor4=new st::EX_Switch(F("switch4"), PIN_RELAY4, LOW, false); - st::EX_Switch *executor5=new st::EX_Switch(F("switch5"), PIN_RELAY5, LOW, false); - st::EX_Switch *executor6=new st::EX_Switch(F("switch6"), PIN_RELAY6, LOW, false); - st::EX_Switch *executor7=new st::EX_Switch(F("switch7"), PIN_RELAY7, LOW, false); - st::EX_Switch *executor8=new st::EX_Switch(F("switch8"), PIN_RELAY8, LOW, false); - st::EX_Switch *executor9=new st::EX_Switch(F("switch9"), PIN_RELAY9, LOW, false); - st::EX_Switch *executor10=new st::EX_Switch(F("switch10"), PIN_RELAY10, LOW, false); - st::EX_Switch *executor11=new st::EX_Switch(F("switch11"), PIN_RELAY11, LOW, false); - st::EX_Switch *executor12=new st::EX_Switch(F("switch12"), PIN_RELAY12, LOW, false); - st::EX_Switch *executor13=new st::EX_Switch(F("switch13"), PIN_RELAY13, LOW, false); - st::EX_Switch *executor14=new st::EX_Switch(F("switch14"), PIN_RELAY14, LOW, false); - st::EX_Switch *executor15=new st::EX_Switch(F("switch15"), PIN_RELAY15, LOW, false); - st::EX_Switch *executor16=new st::EX_Switch(F("switch16"), PIN_RELAY16, LOW, false); - + static st::EX_Switch executor1(F("switch1"), PIN_RELAY1, LOW, false); + static st::EX_Switch executor2(F("switch2"), PIN_RELAY2, LOW, false); + static st::EX_Switch executor3(F("switch3"), PIN_RELAY3, LOW, false); + static st::EX_Switch executor4(F("switch4"), PIN_RELAY4, LOW, false); + static st::EX_Switch executor5(F("switch5"), PIN_RELAY5, LOW, false); + static st::EX_Switch executor6(F("switch6"), PIN_RELAY6, LOW, false); + static st::EX_Switch executor7(F("switch7"), PIN_RELAY7, LOW, false); + static st::EX_Switch executor8(F("switch8"), PIN_RELAY8, LOW, false); + static st::EX_Switch executor9(F("switch9"), PIN_RELAY9, LOW, false); + static st::EX_Switch executor10(F("switch10"), PIN_RELAY10, LOW, false); + static st::EX_Switch executor11(F("switch11"), PIN_RELAY11, LOW, false); + static st::EX_Switch executor12(F("switch12"), PIN_RELAY12, LOW, false); + static st::EX_Switch executor13(F("switch13"), PIN_RELAY13, LOW, false); + static st::EX_Switch executor14(F("switch14"), PIN_RELAY14, LOW, false); + static st::EX_Switch executor15(F("switch15"), PIN_RELAY15, LOW, false); + static st::EX_Switch executor16(F("switch16"), PIN_RELAY16, LOW, false); + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -179,22 +179,22 @@ void setup() //***************************************************************************** //Add each executor to the "Everything" Class //***************************************************************************** - st::Everything::addExecutor(executor1); - st::Everything::addExecutor(executor2); - st::Everything::addExecutor(executor3); - st::Everything::addExecutor(executor4); - st::Everything::addExecutor(executor5); - st::Everything::addExecutor(executor6); - st::Everything::addExecutor(executor7); - st::Everything::addExecutor(executor8); - st::Everything::addExecutor(executor9); - st::Everything::addExecutor(executor10); - st::Everything::addExecutor(executor11); - st::Everything::addExecutor(executor12); - st::Everything::addExecutor(executor13); - st::Everything::addExecutor(executor14); - st::Everything::addExecutor(executor15); - st::Everything::addExecutor(executor16); + st::Everything::addExecutor(&executor1); + st::Everything::addExecutor(&executor2); + st::Everything::addExecutor(&executor3); + st::Everything::addExecutor(&executor4); + st::Everything::addExecutor(&executor5); + st::Everything::addExecutor(&executor6); + st::Everything::addExecutor(&executor7); + st::Everything::addExecutor(&executor8); + st::Everything::addExecutor(&executor9); + st::Everything::addExecutor(&executor10); + st::Everything::addExecutor(&executor11); + st::Everything::addExecutor(&executor12); + st::Everything::addExecutor(&executor13); + st::Everything::addExecutor(&executor14); + st::Everything::addExecutor(&executor15); + st::Everything::addExecutor(&executor16); //***************************************************************************** //Initialize each of the devices which were added to the Everything Class @@ -205,22 +205,22 @@ void setup() //Add User Customized Setup Code Here (instead of modifying standard library files) //***************************************************************************** //---Begin Push Button initialization section--- - swArray[0]=executor1; - swArray[1]=executor2; - swArray[2]=executor3; - swArray[3]=executor4; - swArray[4]=executor5; - swArray[5]=executor6; - swArray[6]=executor7; - swArray[7]=executor8; - swArray[8]=executor9; - swArray[9]=executor10; - swArray[10]=executor11; - swArray[11]=executor12; - swArray[12]=executor13; - swArray[13]=executor14; - swArray[14]=executor15; - swArray[15]=executor16; + swArray[0]=&executor1; + swArray[1]=&executor2; + swArray[2]=&executor3; + swArray[3]=&executor4; + swArray[4]=&executor5; + swArray[5]=&executor6; + swArray[6]=&executor7; + swArray[7]=&executor8; + swArray[8]=&executor9; + swArray[9]=&executor10; + swArray[10]=&executor11; + swArray[11]=&executor12; + swArray[12]=&executor13; + swArray[13]=&executor14; + swArray[14]=&executor15; + swArray[15]=&executor16; //Allocate strCommand buffer one time to prevent Heap Fragmentation. strCommand.reserve(20); diff --git a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino b/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino index d5a3b330..5194ece7 100644 --- a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino +++ b/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino @@ -68,6 +68,7 @@ #include //DHT Temperature and Humidity Library (*** Rob Tillaart's version ***) #include //thermocouple additions #include //thermocouple additions +#include //****************************************************************************************** // ST_Anything Library //****************************************************************************************** @@ -81,7 +82,7 @@ #include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library #include //Implements a Polling Sensor (PS) to measure Temperature via Adafruit_MAX31855 library -#include + //****************************************************************************************** //Define which Arduino Pins will be used for each device // Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 @@ -108,38 +109,39 @@ #define PIN_MISO_OVEN 4 #define PIN_MISO_BROILER 5 -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name. (Note: "temphumid" below is the exception to this rule -// as the DHT sensors produce both "temperature" and "humidity". Data from that -// particular sensor is sent to the ST Shield in two separate updates, one for -// "temperature" and one for "humidity") -// -// TODO: Customize based on what devices the user needs attached to the Arduino -// -//****************************************************************************************** -//Polling Sensors -; -; -; -; -; -; - -//Interrupt Sensors - -//Executors //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Shield in two separate updates, one for + // "temperature" and one for "humidity") + // + // TODO: Customize based on what devices the user needs attached to the Arduino + // + //****************************************************************************************** + //Polling Sensors + static st::PS_TemperatureHumidity sensor1(F("th_Freezer"), 30, 3, PIN_TEMPHUMID_FREEZER, st::PS_TemperatureHumidity::DHT22, "t_Freezer", "h_Freezer"); + static st::PS_TemperatureHumidity sensor2(F("th_Fridge"), 30, 5, PIN_TEMPHUMID_FRIDGE, st::PS_TemperatureHumidity::DHT22, "t_Fridge", "h_Fridge"); + static st::PS_TemperatureHumidity sensor3(F("th_Moistcrisp"), 30, 7, PIN_TEMPHUMID_MOISTCRISP, st::PS_TemperatureHumidity::DHT22, "t_Moistcrisp", "h_Moistcrisp"); + static st::PS_TemperatureHumidity sensor4(F("th_Othercrisp"), 30, 9, PIN_TEMPHUMID_OTHERCRISP, st::PS_TemperatureHumidity::DHT22, "t_Othercrisp", "h_Othercrisp"); + static st::PS_AdafruitThermocouple sensor5(F("t_Oven"), 10, 0, PIN_SCLK, PIN_CS, PIN_MISO_OVEN); + static st::PS_AdafruitThermocouple sensor6(F("t_Broiler"), 10, 2, PIN_SCLK, PIN_CS, PIN_MISO_BROILER); + + //Interrupt Sensors + + //Executors + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -160,12 +162,12 @@ void setup() //Add each sensor to the "Everything" Class // TODO: Customize based on sensors defined in global section above //***************************************************************************** - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Freezer"), 30, 3, PIN_TEMPHUMID_FREEZER, st::PS_TemperatureHumidity::DHT22, "t_Freezer", "h_Freezer")); - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Fridge"), 30, 5, PIN_TEMPHUMID_FRIDGE, st::PS_TemperatureHumidity::DHT22, "t_Fridge", "h_Fridge")); - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Moistcrisp"), 30, 7, PIN_TEMPHUMID_MOISTCRISP, st::PS_TemperatureHumidity::DHT22, "t_Moistcrisp", "h_Moistcrisp")); - st::Everything::addSensor(new st::PS_TemperatureHumidity(F("th_Othercrisp"), 30, 9, PIN_TEMPHUMID_OTHERCRISP, st::PS_TemperatureHumidity::DHT22, "t_Othercrisp", "h_Othercrisp")); - st::Everything::addSensor(new st::PS_AdafruitThermocouple(F("t_Oven"), 10, 0, PIN_SCLK, PIN_CS, PIN_MISO_OVEN)); - st::Everything::addSensor(new st::PS_AdafruitThermocouple(F("t_Broiler"), 10, 2, PIN_SCLK, PIN_CS, PIN_MISO_BROILER)); + st::Everything::addSensor(&sensor1); + st::Everything::addSensor(&sensor2); + st::Everything::addSensor(&sensor3); + st::Everything::addSensor(&sensor4); + st::Everything::addSensor(&sensor5); + st::Everything::addSensor(&sensor6); //***************************************************************************** //Add each executor to the "Everything" Class From 4631c47e55e16c0e68791b1aa8a13d4c1672b561 Mon Sep 17 00:00:00 2001 From: Daniel Ogorchock Date: Tue, 14 Apr 2015 23:27:18 -0400 Subject: [PATCH 11/11] added memory optimization support to new PulseCounter class --- .../ST_Anything_Power/ST_Anything_Power.ino | 43 ++++++++++--------- .../libraries/ST_Anything/PS_PulseCounter.cpp | 2 +- .../libraries/ST_Anything/PS_PulseCounter.h | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino b/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino index a7c8f581..52580dec 100644 --- a/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino +++ b/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino @@ -40,7 +40,7 @@ // ---- --- ---- // 2015-01-03 Dan & Daniel Original Creation (ST_Anything demo) // 2015-03-31 Dan Ogorchock Modified for a Pulse Counter / Energy Meter -// +// 2015-04-14 Daniel O. Support for memory optimizations // //****************************************************************************************** @@ -49,6 +49,7 @@ //****************************************************************************************** #include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library #include //Library to provide API to the SmartThings Shield +#include //****************************************************************************************** // ST_Anything Library @@ -86,31 +87,31 @@ #define PULSE_SLOPE 1.0 //Linear conversion slope (eng units = PULSE_SLOPE * counts + PULSE_OFFSET) #define PULSE_OFFSET 0.0 //Linear conversion offset (eng units = PULSE_SLOPE * counts + PULSE_OFFSET) -//****************************************************************************************** -//Declare each Device that is attached to the Arduino -// Notes: - For each device, there is typically a corresponding "tile" defined in your -// SmartThings DeviceType Groovy code -// - For details on each device's constructor arguments below, please refer to the -// corresponding header (.h) and program (.cpp) files. -// - The name assigned to each device (1st argument below) must match the Groovy -// DeviceType Tile name. (Note: "temphumid" below is the exception to this rule -// as the DHT sensors produce both "temperature" and "humidity". Data from that -// particular sensor is sent to the ST Shield in two separate updates, one for -// "temperature" and one for "humidity") -//****************************************************************************************** -//Polling Sensors -st::PS_PulseCounter sensor1("power", PULSE_POLL_INTRVL, PULSE_POLL_OFFSET, PULSE_PIN, PULSE_INTTYPE, PULE_INPUTMODE, PULSE_SLOPE, PULSE_OFFSET); - -//Interrupt Sensors - -//Executors - //****************************************************************************************** //Arduino Setup() routine //****************************************************************************************** void setup() { + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Shield in two separate updates, one for + // "temperature" and one for "humidity") + //****************************************************************************************** + //Polling Sensors + static st::PS_PulseCounter sensor1(F("power"), PULSE_POLL_INTRVL, PULSE_POLL_OFFSET, PULSE_PIN, PULSE_INTTYPE, PULE_INPUTMODE, PULSE_SLOPE, PULSE_OFFSET); + + //Interrupt Sensors + + //Executors + //***************************************************************************** // Configure debug print output from each main class // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 @@ -152,4 +153,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} diff --git a/Arduino/libraries/ST_Anything/PS_PulseCounter.cpp b/Arduino/libraries/ST_Anything/PS_PulseCounter.cpp index 6f54c346..eaa9ad15 100644 --- a/Arduino/libraries/ST_Anything/PS_PulseCounter.cpp +++ b/Arduino/libraries/ST_Anything/PS_PulseCounter.cpp @@ -73,7 +73,7 @@ namespace st //public //constructor - called in your sketch's global variable declaration section - PS_PulseCounter::PS_PulseCounter(const String &name, unsigned int interval, int offset, byte inputpin, byte inttype, byte inputmode, float cnvslope, float cnvoffset) : + PS_PulseCounter::PS_PulseCounter(const __FlashStringHelper *name, unsigned int interval, int offset, byte inputpin, byte inttype, byte inputmode, float cnvslope, float cnvoffset) : PollingSensor(name, interval, offset), m_nInputMode(inputmode), m_nSensorValue(0), diff --git a/Arduino/libraries/ST_Anything/PS_PulseCounter.h b/Arduino/libraries/ST_Anything/PS_PulseCounter.h index 6f4ee8e3..f2021c61 100644 --- a/Arduino/libraries/ST_Anything/PS_PulseCounter.h +++ b/Arduino/libraries/ST_Anything/PS_PulseCounter.h @@ -60,7 +60,7 @@ namespace st //constructor - called in your sketch's global variable declaration section - PS_PulseCounter(const String &name, unsigned int interval, int offset, byte inputpin, byte inttype, byte inputmode, float cnvslope, float cnvoffset); + PS_PulseCounter(const __FlashStringHelper *name, unsigned int interval, int offset, byte inputpin, byte inttype, byte inputmode, float cnvslope, float cnvoffset); //destructor virtual ~PS_PulseCounter();