//TemperatureRecorder class //Written by Napoleon Leoni, February 2014 //This class takes a pointer to an LM75B sensor on the MBED //application board and reads it temperature value, keeps track //of the max and min values (since a last reset of the values) and also //keeps a circular buffer of recorded temperature values
temperatureRecorder.h@1:8ec88bb8425f, 2014-02-21 (annotated)
- Committer:
- nleoni
- Date:
- Fri Feb 21 06:57:23 2014 +0000
- Revision:
- 1:8ec88bb8425f
- Parent:
- 0:aca019487653
Updated testing of class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nleoni | 0:aca019487653 | 1 | #include "mbed.h" |
nleoni | 0:aca019487653 | 2 | #include "LM75B.h" |
nleoni | 0:aca019487653 | 3 | |
nleoni | 0:aca019487653 | 4 | #ifndef TRECORDER |
nleoni | 0:aca019487653 | 5 | #define TRECORDER |
nleoni | 0:aca019487653 | 6 | #define MAXRECORDINGBUFFER 1024 //max size of buffer that can be specified for recording temperatures |
nleoni | 0:aca019487653 | 7 | |
nleoni | 0:aca019487653 | 8 | //TemperatureRecorder class |
nleoni | 0:aca019487653 | 9 | //Written by Napoleon Leoni, February 2014 |
nleoni | 0:aca019487653 | 10 | //This class takes a pointer to an LM75B sensor |
nleoni | 0:aca019487653 | 11 | //and reads it temperature value, keeps track of the max and |
nleoni | 0:aca019487653 | 12 | //min values (since a last reset of the values) and also keeps |
nleoni | 0:aca019487653 | 13 | //a circular buffer of recorded temperature values |
nleoni | 0:aca019487653 | 14 | |
nleoni | 0:aca019487653 | 15 | //***************************** TESTING ********************************************************// |
nleoni | 0:aca019487653 | 16 | // TEST TEST DESCRIPTION STATUS // |
nleoni | 0:aca019487653 | 17 | // 1 Time display is inceremented in seconds and date shown PASS // |
nleoni | 0:aca019487653 | 18 | // corresponds to date set in code // |
nleoni | 0:aca019487653 | 19 | // 2 Max temperature displayed is highest reached PASS // |
nleoni | 0:aca019487653 | 20 | // during a heating event (finger touch) // |
nleoni | 0:aca019487653 | 21 | // 3 Min Temperature displayed is lowest reached PASS // |
nleoni | 0:aca019487653 | 22 | // during a cooling event // |
nleoni | 0:aca019487653 | 23 | // 4 Changing from degrees C to degress F and back retains PASS // |
nleoni | 0:aca019487653 | 24 | // Max and min values and displays proper conversion // |
nleoni | 0:aca019487653 | 25 | //**********************************************************************************************// |
nleoni | 0:aca019487653 | 26 | |
nleoni | 0:aca019487653 | 27 | |
nleoni | 0:aca019487653 | 28 | class temperatureRecorder |
nleoni | 0:aca019487653 | 29 | { |
nleoni | 0:aca019487653 | 30 | public: |
nleoni | 0:aca019487653 | 31 | |
nleoni | 0:aca019487653 | 32 | private: |
nleoni | 1:8ec88bb8425f | 33 | bool recordingEnabled,resetTemperatureFlag,sensorValid,temperatureInFarenheit,externalSensor; |
nleoni | 0:aca019487653 | 34 | int recordingBufferSize; |
nleoni | 0:aca019487653 | 35 | static const int maxRecordingBufferSize=MAXRECORDINGBUFFER; |
nleoni | 0:aca019487653 | 36 | float currentTemperature,maxTemperature,minTemperature; |
nleoni | 0:aca019487653 | 37 | LM75B *tsensor;//pointer to temperature sensor type |
nleoni | 1:8ec88bb8425f | 38 | float externalSensorTemperatureInC; |
nleoni | 0:aca019487653 | 39 | |
nleoni | 0:aca019487653 | 40 | //public Methods |
nleoni | 0:aca019487653 | 41 | public: |
nleoni | 0:aca019487653 | 42 | //default constructor, required |
nleoni | 0:aca019487653 | 43 | temperatureRecorder(); |
nleoni | 0:aca019487653 | 44 | //commonly used constructor: this is the constructor that should be used. |
nleoni | 0:aca019487653 | 45 | temperatureRecorder(int bufferSize,LM75B *ptrTsensor); |
nleoni | 0:aca019487653 | 46 | |
nleoni | 0:aca019487653 | 47 | void makeReading(void); |
nleoni | 1:8ec88bb8425f | 48 | void makeReading(float); |
nleoni | 0:aca019487653 | 49 | |
nleoni | 0:aca019487653 | 50 | float getTemperature(void); |
nleoni | 0:aca019487653 | 51 | float getMaxTemperature(void); |
nleoni | 0:aca019487653 | 52 | float getMinTemperature(void); |
nleoni | 0:aca019487653 | 53 | |
nleoni | 1:8ec88bb8425f | 54 | void enableExternalSensor(void) |
nleoni | 1:8ec88bb8425f | 55 | void disableExternalSensor(void); |
nleoni | 1:8ec88bb8425f | 56 | |
nleoni | 0:aca019487653 | 57 | void setTemperatureToCelsius(void); |
nleoni | 0:aca019487653 | 58 | void setTemperatureToFarenheit(void); |
nleoni | 0:aca019487653 | 59 | bool isTemperatureInFarenheit(void); |
nleoni | 0:aca019487653 | 60 | float convertToCelsius(float); |
nleoni | 0:aca019487653 | 61 | float convertToFarenheit(float); |
nleoni | 0:aca019487653 | 62 | |
nleoni | 0:aca019487653 | 63 | //private Methods |
nleoni | 0:aca019487653 | 64 | private: |
nleoni | 0:aca019487653 | 65 | void resetTemperatureExtremes(void); |
nleoni | 0:aca019487653 | 66 | }; |
nleoni | 0:aca019487653 | 67 | |
nleoni | 0:aca019487653 | 68 | #endif |