@@ -37,9 +37,8 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
37
37
7-bit device address.
38
38
*/
39
39
/* ******************************************************************************/
40
- WipperSnapper_I2C_Driver_SCD30 (TwoWire *i2c, uint16_t sensorAddress)
41
- : WipperSnapper_I2C_Driver(i2c, sensorAddress)
42
- {
40
+ WipperSnapper_I2C_Driver_SCD30 (TwoWire* i2c, uint16_t sensorAddress)
41
+ : WipperSnapper_I2C_Driver(i2c, sensorAddress) {
43
42
_i2c = i2c;
44
43
_sensorAddress = sensorAddress;
45
44
}
@@ -50,8 +49,7 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
50
49
@returns True if initialized successfully, False otherwise.
51
50
*/
52
51
/* ******************************************************************************/
53
- bool begin ()
54
- {
52
+ bool begin () {
55
53
_scd = new Adafruit_SCD30 ();
56
54
return _scd->begin ((uint8_t )_sensorAddress, _i2c);
57
55
}
@@ -62,26 +60,21 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
62
60
@returns True if the sensor was read successfully, False otherwise.
63
61
*/
64
62
/* ******************************************************************************/
65
- bool readSensor ()
66
- {
63
+ bool readSensor () {
67
64
// dont read sensor more than once per second
68
- if (_lastRead != 0 && millis () - _lastRead < 1000 )
69
- {
65
+ if (_lastRead != 0 && millis () - _lastRead < 1000 ) {
70
66
return true ;
71
67
}
72
68
73
- if (!_scd->dataReady ())
74
- {
69
+ if (!_scd->dataReady ()) {
75
70
delay (100 );
76
- if (!_scd->dataReady ())
77
- {
71
+ if (!_scd->dataReady ()) {
78
72
return false ;
79
73
}
80
74
}
81
75
sensors_event_t tempEvent;
82
76
sensors_event_t humidEvent;
83
- if (!_scd->getEvent (&humidEvent, &tempEvent))
84
- {
77
+ if (!_scd->getEvent (&humidEvent, &tempEvent)) {
85
78
return false ;
86
79
}
87
80
_temperature = tempEvent.temperature ;
@@ -100,11 +93,9 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
100
93
otherwise.
101
94
*/
102
95
/* ******************************************************************************/
103
- bool getEventAmbientTemp (sensors_event_t *tempEvent)
104
- {
96
+ bool getEventAmbientTemp (sensors_event_t * tempEvent) {
105
97
// check if sensor is enabled and data is available
106
- if (!readSensor ())
107
- {
98
+ if (!readSensor ()) {
108
99
return false ;
109
100
}
110
101
@@ -121,11 +112,9 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
121
112
otherwise.
122
113
*/
123
114
/* ******************************************************************************/
124
- bool getEventRelativeHumidity (sensors_event_t *humidEvent)
125
- {
115
+ bool getEventRelativeHumidity (sensors_event_t * humidEvent) {
126
116
// check if sensor is enabled and data is available
127
- if (!readSensor ())
128
- {
117
+ if (!readSensor ()) {
129
118
return false ;
130
119
}
131
120
@@ -142,11 +131,9 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
142
131
otherwise.
143
132
*/
144
133
/* ******************************************************************************/
145
- bool getEventCO2 (sensors_event_t *co2Event)
146
- {
134
+ bool getEventCO2 (sensors_event_t * co2Event) {
147
135
// check if sensor is enabled and data is available
148
- if (!readSensor ())
149
- {
136
+ if (!readSensor ()) {
150
137
return false ;
151
138
}
152
139
@@ -155,7 +142,7 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver
155
142
}
156
143
157
144
protected:
158
- Adafruit_SCD30 * _scd = nullptr ; // /< SCD30 driver object
145
+ Adafruit_SCD30* _scd = nullptr ; // /< SCD30 driver object
159
146
ulong _lastRead = 0 ; // /< Last time the sensor was read
160
147
float _temperature = 0 ; // /< Temperature
161
148
float _humidity = 0 ; // /< Relative Humidity
0 commit comments