//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@0:aca019487653, 2014-02-13 (annotated)
- Committer:
- nleoni
- Date:
- Thu Feb 13 07:59:09 2014 +0000
- Revision:
- 0:aca019487653
- Child:
- 1:8ec88bb8425f
1st Checkin. Temperature recording class is working and one liner tests were performed and reported in the file. Circular buffer for stoarge is still not implemented
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 | 0:aca019487653 | 33 | bool recordingEnabled,resetTemperatureFlag,sensorValid,temperatureInFarenheit; |
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 | 0:aca019487653 | 38 | |
nleoni | 0:aca019487653 | 39 | //public Methods |
nleoni | 0:aca019487653 | 40 | public: |
nleoni | 0:aca019487653 | 41 | //default constructor, required |
nleoni | 0:aca019487653 | 42 | temperatureRecorder(); |
nleoni | 0:aca019487653 | 43 | //commonly used constructor: this is the constructor that should be used. |
nleoni | 0:aca019487653 | 44 | temperatureRecorder(int bufferSize,LM75B *ptrTsensor); |
nleoni | 0:aca019487653 | 45 | |
nleoni | 0:aca019487653 | 46 | void makeReading(void); |
nleoni | 0:aca019487653 | 47 | |
nleoni | 0:aca019487653 | 48 | float getTemperature(void); |
nleoni | 0:aca019487653 | 49 | float getMaxTemperature(void); |
nleoni | 0:aca019487653 | 50 | float getMinTemperature(void); |
nleoni | 0:aca019487653 | 51 | |
nleoni | 0:aca019487653 | 52 | void setTemperatureToCelsius(void); |
nleoni | 0:aca019487653 | 53 | void setTemperatureToFarenheit(void); |
nleoni | 0:aca019487653 | 54 | bool isTemperatureInFarenheit(void); |
nleoni | 0:aca019487653 | 55 | float convertToCelsius(float); |
nleoni | 0:aca019487653 | 56 | float convertToFarenheit(float); |
nleoni | 0:aca019487653 | 57 | |
nleoni | 0:aca019487653 | 58 | //private Methods |
nleoni | 0:aca019487653 | 59 | private: |
nleoni | 0:aca019487653 | 60 | void resetTemperatureExtremes(void); |
nleoni | 0:aca019487653 | 61 | }; |
nleoni | 0:aca019487653 | 62 | |
nleoni | 0:aca019487653 | 63 | #endif |