Skip to content

Commit 923428a

Browse files
committed
Update I2C initialisation of locals
1 parent 7ab9e78 commit 923428a

5 files changed

+13
-13
lines changed

src/components/i2c/WipperSnapper_I2C.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,8 @@ void WipperSnapper_Component_I2C::update() {
10721072
// Number of events which occured for this driver
10731073
msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count = 0;
10741074

1075-
// Event struct
1076-
sensors_event_t event;
1075+
// Event struct - zero-initialise on each iteration
1076+
sensors_event_t event = {0};
10771077

10781078
// AMBIENT_TEMPERATURE sensor (°C)
10791079
sensorEventRead(

src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
7171
*/
7272
/*******************************************************************************/
7373
bool getEventPM10_STD(sensors_event_t *pm10StdEvent) {
74-
PM25_AQI_Data data;
74+
PM25_AQI_Data data = {0};
7575
if (!_pm25->read(&data))
7676
return false; // couldn't read data
7777

@@ -89,7 +89,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
8989
*/
9090
/*******************************************************************************/
9191
bool getEventPM25_STD(sensors_event_t *pm25StdEvent) {
92-
PM25_AQI_Data data;
92+
PM25_AQI_Data data = {0};
9393
if (!_pm25->read(&data))
9494
return false; // couldn't read data
9595

@@ -107,7 +107,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
107107
*/
108108
/*******************************************************************************/
109109
bool getEventPM100_STD(sensors_event_t *pm100StdEvent) {
110-
PM25_AQI_Data data;
110+
PM25_AQI_Data data = {0};
111111
if (!_pm25->read(&data))
112112
return false; // couldn't read data
113113

@@ -116,7 +116,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
116116
}
117117

118118
protected:
119-
Adafruit_PM25AQI *_pm25; ///< PM25 driver object
119+
Adafruit_PM25AQI *_pm25 = nullptr; ///< PM25 driver object
120120
};
121121

122122
#endif // WipperSnapper_I2C_Driver_PM25

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
161161
}
162162

163163
protected:
164-
Adafruit_SCD30 *_scd = nullptr; ///< SCD30 driver object
165-
ulong _lastRead = 0; ///< Last time the sensor was read
166-
sensors_event_t _temperature; ///< Temperature
167-
sensors_event_t _humidity; ///< Relative Humidity
168-
sensors_event_t _CO2; ///< CO2
164+
Adafruit_SCD30 *_scd = nullptr; ///< SCD30 driver object
165+
ulong _lastRead = 0ul; ///< Last time the sensor was read
166+
sensors_event_t _temperature = {0}; ///< Temperature
167+
sensors_event_t _humidity = {0}; ///< Relative Humidity
168+
sensors_event_t _CO2 = {0}; ///< CO2
169169
};
170170

171171
#endif // WipperSnapper_I2C_Driver_SCD30

src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class WipperSnapper_I2C_Driver_VL53L4CD : public WipperSnapper_I2C_Driver {
112112
/*******************************************************************************/
113113
bool getEventProximity(sensors_event_t *proximityEvent) {
114114
uint8_t NewDataReady = 0;
115-
VL53L4CD_Result_t results;
115+
VL53L4CD_Result_t results = {0};
116116
uint8_t status;
117117
// Start fresh reading, seemed to be accepting stale value
118118
_VL53L4CD->VL53L4CD_ClearInterrupt();

src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class WipperSnapper_I2C_Driver_VL53L4CX : public WipperSnapper_I2C_Driver {
129129
*/
130130
/*******************************************************************************/
131131
bool getProximity(sensors_event_t *proximityEvent, int whichObject = 0) {
132-
VL53L4CX_MultiRangingData_t MultiRangingData;
132+
VL53L4CX_MultiRangingData_t MultiRangingData = {0};
133133
VL53L4CX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;
134134
uint8_t NewDataReady = 0;
135135
int status;

0 commit comments

Comments
 (0)