Thermostat class implements basic functionality of a thermostat

Committer:
nleoni
Date:
Thu Feb 13 08:07:46 2014 +0000
Revision:
0:cd3a00aa2dbc
Child:
1:909cb1aef872
Thermostat class for mbed application board; 1st checkin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nleoni 0:cd3a00aa2dbc 1 //Thermostat class
nleoni 0:cd3a00aa2dbc 2 //Napoleon Leoni
nleoni 0:cd3a00aa2dbc 3 //Thermostat with Joystick control input
nleoni 0:cd3a00aa2dbc 4 //Class Thermostat:
nleoni 0:cd3a00aa2dbc 5 //Has a control loop enable/disable(I will refer to this as Heater on/off), an over-ride enable/disable.
nleoni 0:cd3a00aa2dbc 6 //an object TemperatureRecording (keeps current temperature, max and min since last reset
nleoni 0:cd3a00aa2dbc 7 //and circular buffer with recorded data)
nleoni 0:cd3a00aa2dbc 8 //Functions to check user input on joystick
nleoni 0:cd3a00aa2dbc 9 //sets interrupt on accelerometer (To be implemented)
nleoni 0:cd3a00aa2dbc 10
nleoni 0:cd3a00aa2dbc 11 #include "mbed.h"
nleoni 0:cd3a00aa2dbc 12 #include "LM75B.h"
nleoni 0:cd3a00aa2dbc 13 #include "temperatureRecorder.h"
nleoni 0:cd3a00aa2dbc 14 #include "joystickAppBoard.h"
nleoni 0:cd3a00aa2dbc 15
nleoni 0:cd3a00aa2dbc 16 #ifndef THERMOSTAT
nleoni 0:cd3a00aa2dbc 17 #define THERMOSTAT
nleoni 0:cd3a00aa2dbc 18 #define DEFAULTHYSTERESYS 5 //degrees F, dead band of controller to prevent excessive turn on/off
nleoni 0:cd3a00aa2dbc 19 #define DEFAULTGRANULARITY 2 //degrees F, increment in temperaure setting per joystick click
nleoni 0:cd3a00aa2dbc 20 #define DEFAULTTEMPSETTING 60 //degrees F, default setting for thermostat
nleoni 0:cd3a00aa2dbc 21 #define DEFAULTMAXTEMPSETTING 96 //degrees F, max temperature setting to avoid user over shooting setting with joystick
nleoni 0:cd3a00aa2dbc 22 #define DEFAULTMINTEMPSETTING 44 //degrees F, min temperature setting to avoid user under shooting setting with joystick
nleoni 0:cd3a00aa2dbc 23 #define DEFAULTTIME
nleoni 0:cd3a00aa2dbc 24
nleoni 0:cd3a00aa2dbc 25 class thermostat{
nleoni 0:cd3a00aa2dbc 26 //public members
nleoni 0:cd3a00aa2dbc 27 public:
nleoni 0:cd3a00aa2dbc 28 //private members
nleoni 0:cd3a00aa2dbc 29 private:
nleoni 0:cd3a00aa2dbc 30 temperatureRecorder *trecord; //pointer to TemperatureRecordeObject
nleoni 0:cd3a00aa2dbc 31 joystickAppBoard *inputJoystick; //pointer to input joystick object
nleoni 0:cd3a00aa2dbc 32 DigitalOut *actuatorOutput; //pointer to Digital Output for actuator, this would run the relay for the heater
nleoni 0:cd3a00aa2dbc 33 //temporarily we could use an LED as output so that the heating action is signaled
nleoni 0:cd3a00aa2dbc 34 //by the turning on and off of an LED
nleoni 0:cd3a00aa2dbc 35 struct tm timeKeeper; //structure to hold date/time type
nleoni 0:cd3a00aa2dbc 36 time_t timeInSeconds; //variable to keep absolute time
nleoni 0:cd3a00aa2dbc 37 float hysteresisGap, temperatureGranularity, defaultTemperature, maxTemperature, minTemperature;
nleoni 0:cd3a00aa2dbc 38 bool heaterEnabled; //This flag corresponds to whether the thermostat control is on
nleoni 0:cd3a00aa2dbc 39 bool heatingActionOn; //this flag corresponds to whether the thermostat has turned the heating action (relay) on
nleoni 0:cd3a00aa2dbc 40 //public methods
nleoni 0:cd3a00aa2dbc 41 public:
nleoni 0:cd3a00aa2dbc 42 thermostat();//default constructor
nleoni 0:cd3a00aa2dbc 43 thermostat(temperatureRecorder *,joystickAppBoard *,DigitalOut *);//regular constructor
nleoni 0:cd3a00aa2dbc 44 void enableHeater(void);
nleoni 0:cd3a00aa2dbc 45 void disableHeater(void);
nleoni 0:cd3a00aa2dbc 46 void checkJoystickInput(void);
nleoni 0:cd3a00aa2dbc 47 void runThermostatControlCycle(void);
nleoni 0:cd3a00aa2dbc 48 float getTemperature(void);//Read current temperature
nleoni 0:cd3a00aa2dbc 49 float getMaxTemperature(void);//read Maximum Temperature
nleoni 0:cd3a00aa2dbc 50 float getMinTemperature(void);//read Maximum Temperature
nleoni 0:cd3a00aa2dbc 51 float getTemperatureSetting(void); //read temperature setting
nleoni 0:cd3a00aa2dbc 52 bool getThermostatStatus(void); //returns true if heaterEnabled, that is thermostat control is on
nleoni 0:cd3a00aa2dbc 53 void setDay(int,int,int);
nleoni 0:cd3a00aa2dbc 54 void setTime(int,int,int);
nleoni 0:cd3a00aa2dbc 55 void getDateandTime(char*,int); //return Date and time as a formatted string in the provided char buffer
nleoni 0:cd3a00aa2dbc 56 //private methods
nleoni 0:cd3a00aa2dbc 57 private:
nleoni 0:cd3a00aa2dbc 58 }; //end of thermostat class prototype
nleoni 0:cd3a00aa2dbc 59 #endif