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