File tree Expand file tree Collapse file tree 5 files changed +13
-13
lines changed Expand file tree Collapse file tree 5 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -1083,8 +1083,8 @@ void WipperSnapper_Component_I2C::update() {
10831083 // Number of events which occured for this driver
10841084 msgi2cResponse.payload .resp_i2c_device_event .sensor_event_count = 0 ;
10851085
1086- // Event struct
1087- sensors_event_t event;
1086+ // Event struct - zero-initialise on each iteration
1087+ sensors_event_t event = { 0 } ;
10881088
10891089 // AMBIENT_TEMPERATURE sensor (°C)
10901090 sensorEventRead (
Original file line number Diff line number Diff 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
118118protected:
119- Adafruit_PM25AQI *_pm25; // /< PM25 driver object
119+ Adafruit_PM25AQI *_pm25 = nullptr ; // /< PM25 driver object
120120};
121121
122122#endif // WipperSnapper_I2C_Driver_PM25
Original file line number Diff line number Diff line change @@ -161,11 +161,11 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
161161 }
162162
163163protected:
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
Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments