78 lines
3.6 KiB
C++
78 lines
3.6 KiB
C++
//******************************************************************************************
|
|
// File: PS_Illuminance.h
|
|
// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
|
|
//
|
|
// Summary: PS_Illuminance is a class which implements the SmartThings "Illuminance Measurement" device capability.
|
|
// It inherits from the st::PollingSensor class. The current version uses an analog input to measure the
|
|
// value of a simple photo resistor.
|
|
//
|
|
// The last four arguments of the constructor are used as arguments to an Arduino map() function which
|
|
// is used to scale the analog input readings (0 to 1024) to Lux before sending to SmartThings. The
|
|
// defaults for this sensor are based on the device used during testing.
|
|
//
|
|
// Create an instance of this class in your sketch's global variable section
|
|
// For Example: st::PS_Illuminance sensor1(F("illuminance1"), 120, 0, PIN_ILLUMINANCE, 0, 1023, 0, 1000);
|
|
//
|
|
// st::PS_Illuminance() constructor requires the following arguments
|
|
// - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
|
|
// - long interval - REQUIRED - the polling interval in seconds
|
|
// - long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
|
|
// - byte pin - REQUIRED - the Arduino Pin to be used as a digital output
|
|
// - int s_l - OPTIONAL - first argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
|
|
// - int s_h - OPTIONAL - second argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
|
|
// - int m_l - OPTIONAL - third argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
|
|
// - int m_h - OPTIONAL - fourth argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
|
|
//
|
|
// 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.
|
|
//
|
|
// TODO: Determine a method to persist the ST Cloud's Polling Interval data
|
|
//
|
|
// Change History:
|
|
//
|
|
// Date Who What
|
|
// ---- --- ----
|
|
// 2015-01-03 Dan & Daniel Original Creation
|
|
// 2018-08-30 Dan Ogorchock Modified comment section above to comply with new Parent/Child Device Handler requirements
|
|
//
|
|
//
|
|
//******************************************************************************************
|
|
|
|
#ifndef ST_PS_ILLUMINANCE_H
|
|
#define ST_PS_ILLUMINANCE_H
|
|
|
|
#include "PollingSensor.h"
|
|
|
|
namespace st
|
|
{
|
|
class PS_Illuminance: public PollingSensor
|
|
{
|
|
private:
|
|
byte m_nAnalogInputPin;
|
|
int m_nSensorValue;
|
|
const int SENSOR_LOW, SENSOR_HIGH, MAPPED_LOW, MAPPED_HIGH;
|
|
|
|
public:
|
|
//constructor - called in your sketch's global variable declaration section
|
|
PS_Illuminance(const __FlashStringHelper *name, unsigned int interval, int offset, byte analogInputPin, int s_l=0, int s_h=1023, int m_l=1000, int m_h=0);
|
|
|
|
//destructor
|
|
virtual ~PS_Illuminance();
|
|
|
|
//SmartThings Shield data handler (receives configuration data from ST - polling interval, and adjusts on the fly)
|
|
virtual void beSmart(const String &str);
|
|
|
|
//function to get data from sensor and queue results for transfer to ST Cloud
|
|
virtual void getData();
|
|
|
|
//gets
|
|
inline byte getPin() const {return m_nAnalogInputPin;}
|
|
inline byte getSensorValue() const {return m_nSensorValue;}
|
|
|
|
//sets
|
|
void setPin(byte pin);
|
|
};
|
|
}
|
|
#endif
|