Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
thermostat.h
00001 //Thermostat class 00002 //Napoleon Leoni 00003 //Thermostat with Joystick control input 00004 //Class Thermostat: 00005 //Has a control loop enable/disable(I will refer to this as Heater on/off), an over-ride enable/disable. 00006 //an object TemperatureRecording (keeps current temperature, max and min since last reset 00007 //and circular buffer with recorded data) 00008 //Functions to check user input on joystick 00009 //sets interrupt on accelerometer (To be implemented) 00010 00011 //***************************** TESTING ********************************************************// 00012 // TEST TEST DESCRIPTION STATUS // 00013 // 1 Time display is inceremented in seconds and date shown PASS // 00014 // corresponds to date set in code // 00015 // 2 Joystick input works as expected up/down to increase PASS // 00016 // decrease the temperature settting by the selected // 00017 // granularity and left/right to turn heater on/off // 00018 // LCD display shows correct changes in values as well // 00019 // 3 Automated thermostatCycle test includes feeding a known PASS // 00020 // array of temperatures and verifying sample by sample that // 00021 // the thermostat loop is enabled when it should be. this loop // 00022 // also checks what happens when the heater is set to on or off // 00023 // this test issues a PASS status only if the results are correct // 00024 // for every sample 00025 //**********************************************************************************************// 00026 00027 #include "mbed.h" 00028 #include "LM75B.h" 00029 #include "temperatureRecorder.h" 00030 #include "joystickAppBoard.h" 00031 00032 #ifndef THERMOSTAT 00033 #define THERMOSTAT 00034 #define DEFAULTHYSTERESYS 5 //degrees F, dead band of controller to prevent excessive turn on/off 00035 #define DEFAULTGRANULARITY 2 //degrees F, increment in temperaure setting per joystick click 00036 #define DEFAULTTEMPSETTING 60 //degrees F, default setting for thermostat 00037 #define DEFAULTMAXTEMPSETTING 96 //degrees F, max temperature setting to avoid user over shooting setting with joystick 00038 #define DEFAULTMINTEMPSETTING 44 //degrees F, min temperature setting to avoid user under shooting setting with joystick 00039 #define DEFAULTTIME 00040 00041 class thermostat{ 00042 //public members 00043 public: 00044 //private members 00045 private: 00046 temperatureRecorder *trecord; //pointer to TemperatureRecordeObject 00047 joystickAppBoard *inputJoystick; //pointer to input joystick object 00048 DigitalOut *actuatorOutput; //pointer to Digital Output for actuator, this would run the relay for the heater 00049 //temporarily we could use an LED as output so that the heating action is signaled 00050 //by the turning on and off of an LED 00051 struct tm timeKeeper; //structure to hold date/time type 00052 time_t timeInSeconds; //variable to keep absolute time 00053 float hysteresisGap, temperatureGranularity, defaultTemperature, maxTemperature, minTemperature; 00054 bool heaterEnabled; //This flag corresponds to whether the thermostat control is on 00055 bool heatingActionOn; //this flag corresponds to whether the thermostat has turned the heating action (relay) on 00056 //public methods 00057 public: 00058 thermostat();//default constructor 00059 thermostat(temperatureRecorder *,joystickAppBoard *,DigitalOut *);//regular constructor 00060 void enableHeater(void); 00061 void disableHeater(void); 00062 void checkJoystickInput(void); 00063 void runThermostatControlCycle(void); 00064 float getTemperature(void);//Read current temperature 00065 float getMaxTemperature(void);//read Maximum Temperature 00066 float getMinTemperature(void);//read Maximum Temperature 00067 float getTemperatureSetting(void); //read temperature setting 00068 bool getThermostatStatus(void); //returns true if heaterEnabled, that is thermostat control is on 00069 void setDay(int,int,int); 00070 void setTime(int,int,int); 00071 void getDateandTime(char*,int); //return Date and time as a formatted string in the provided char buffer 00072 void ThermostatUnitTest(char *,int);//unit test for thermostat class, injects a synthetic temperature to test the operation 00073 //private methods 00074 private: 00075 }; //end of thermostat class prototype 00076 #endif
Generated on Tue Jul 12 2022 19:53:53 by
1.7.2