Grelet Jacques
/
Ni-MH_V3
example code using statis library for temperature measurement with LM35 and LM335
temperatureSensor.h@1:5821fa15d6ca, 2012-11-20 (annotated)
- Committer:
- greletj
- Date:
- Tue Nov 20 12:10:39 2012 +0000
- Revision:
- 1:5821fa15d6ca
- Child:
- 2:9517837c642d
add temperatureSensor class and format code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
greletj | 1:5821fa15d6ca | 1 | /*-------------------------------------------------------------------------*/ |
greletj | 1:5821fa15d6ca | 2 | /* TemperatureSensor header class declaration */ |
greletj | 1:5821fa15d6ca | 3 | /*-------------------------------------------------------------------------*/ |
greletj | 1:5821fa15d6ca | 4 | /* Ni-MH charger project US191 IRD */ |
greletj | 1:5821fa15d6ca | 5 | /*-------------------------------------------------------------------------*/ |
greletj | 1:5821fa15d6ca | 6 | /* Nov 2012 | J Grelet */ |
greletj | 1:5821fa15d6ca | 7 | /*-------------------------------------------------------------------------*/ |
greletj | 1:5821fa15d6ca | 8 | |
greletj | 1:5821fa15d6ca | 9 | #ifndef temperatureSensor_H |
greletj | 1:5821fa15d6ca | 10 | #define temperatureSensor_H |
greletj | 1:5821fa15d6ca | 11 | |
greletj | 1:5821fa15d6ca | 12 | #include <iostream> |
greletj | 1:5821fa15d6ca | 13 | #include "mbed.h" // include mbed library |
greletj | 1:5821fa15d6ca | 14 | |
greletj | 1:5821fa15d6ca | 15 | class temperatureSensor { |
greletj | 1:5821fa15d6ca | 16 | |
greletj | 1:5821fa15d6ca | 17 | private: |
greletj | 1:5821fa15d6ca | 18 | Ticker _ticker; |
greletj | 1:5821fa15d6ca | 19 | AnalogIn _pin; |
greletj | 1:5821fa15d6ca | 20 | float _convertion; |
greletj | 1:5821fa15d6ca | 21 | float _scaleFactor; |
greletj | 1:5821fa15d6ca | 22 | float _temperature; |
greletj | 1:5821fa15d6ca | 23 | |
greletj | 1:5821fa15d6ca | 24 | public: |
greletj | 1:5821fa15d6ca | 25 | // Constructor |
greletj | 1:5821fa15d6ca | 26 | temperatureSensor(PinName pin, float delay, float convertion); |
greletj | 1:5821fa15d6ca | 27 | |
greletj | 1:5821fa15d6ca | 28 | // Destructor |
greletj | 1:5821fa15d6ca | 29 | virtual ~temperatureSensor(); |
greletj | 1:5821fa15d6ca | 30 | |
greletj | 1:5821fa15d6ca | 31 | // method that give the temperature measure of the sensor |
greletj | 1:5821fa15d6ca | 32 | float read(void); |
greletj | 1:5821fa15d6ca | 33 | |
greletj | 1:5821fa15d6ca | 34 | // A shorthand for read() |
greletj | 1:5821fa15d6ca | 35 | operator float() { |
greletj | 1:5821fa15d6ca | 36 | return read(); |
greletj | 1:5821fa15d6ca | 37 | } |
greletj | 1:5821fa15d6ca | 38 | |
greletj | 1:5821fa15d6ca | 39 | private: |
greletj | 1:5821fa15d6ca | 40 | // method that convert voltage measure in temperature |
greletj | 1:5821fa15d6ca | 41 | void toDo(void); |
greletj | 1:5821fa15d6ca | 42 | |
greletj | 1:5821fa15d6ca | 43 | }; |
greletj | 1:5821fa15d6ca | 44 | |
greletj | 1:5821fa15d6ca | 45 | #endif // temperatureSensor_H |
greletj | 1:5821fa15d6ca | 46 |