File tree 3 files changed +24
-5
lines changed
3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,13 @@ float EnvClass::readTemperature(int units /*= CELSIUS*/)
102
102
{
103
103
if (_revision == BOARD_REVISION_2) {
104
104
while (!iaqSensor->run ()){ }
105
- return iaqSensor->temperature ;
105
+ float reading = iaqSensor->temperature ;
106
+ if (units == FAHRENHEIT){
107
+ reading = iaqSensor->temperature ;
108
+ return (reading * 9.0 / 5.0 ) + 32.0 ;
109
+ } else {
110
+ return reading;
111
+ }
106
112
}
107
113
return HTS221->readTemperature (units);
108
114
}
Original file line number Diff line number Diff line change @@ -101,16 +101,29 @@ float PressureClass::readPressure(int units)
101
101
{
102
102
if (_revision == BOARD_REVISION_2) {
103
103
while (!iaqSensor->run ()){ }
104
- return iaqSensor->pressure /1000 ;
104
+ float reading = iaqSensor->pressure /1000 ;
105
+ if (units == MILLIBAR) { // 1 kPa = 10 millibar
106
+ return reading * 10 ;
107
+ } else if (units == PSI) { // 1 kPa = 0.145038 PSI
108
+ return reading * 0.145038 ;
109
+ } else {
110
+ return reading;
111
+ }
105
112
}
106
113
return LPS22HB->readPressure (units);
107
114
}
108
115
109
- float PressureClass::readTemperature ()
116
+ float PressureClass::readTemperature (int units /* = CELSIUS */ )
110
117
{
111
118
if (_revision == BOARD_REVISION_2) {
112
119
while (!iaqSensor->run ()){}
113
- return iaqSensor->temperature ;
120
+ float reading = iaqSensor->temperature ;
121
+ if (units == FAHRENHEIT){
122
+ reading = iaqSensor->temperature ;
123
+ return (reading * 9.0 / 5.0 ) + 32.0 ;
124
+ } else {
125
+ return reading;
126
+ }
114
127
}
115
128
return LPS22HB->readTemperature ();
116
129
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class PressureClass {
13
13
void end ();
14
14
15
15
float readPressure (int units = KILOPASCAL);
16
- float readTemperature (void );
16
+ float readTemperature (int units = CELSIUS );
17
17
18
18
private:
19
19
// Helper functions declarations
You can’t perform that action at this time.
0 commit comments