diff --git a/src/components/i2c/WipperSnapper_I2C.cpp b/src/components/i2c/WipperSnapper_I2C.cpp index dfae4db42..ec86126df 100644 --- a/src/components/i2c/WipperSnapper_I2C.cpp +++ b/src/components/i2c/WipperSnapper_I2C.cpp @@ -1072,8 +1072,8 @@ void WipperSnapper_Component_I2C::update() { // Number of events which occured for this driver msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count = 0; - // Event struct - sensors_event_t event; + // Event struct - zero-initialise on each iteration + sensors_event_t event = {0}; // AMBIENT_TEMPERATURE sensor (°C) sensorEventRead( diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h index 47b311fa0..e901a4603 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h @@ -71,7 +71,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver { */ /*******************************************************************************/ bool getEventPM10_STD(sensors_event_t *pm10StdEvent) { - PM25_AQI_Data data; + PM25_AQI_Data data = {0}; if (!_pm25->read(&data)) return false; // couldn't read data @@ -89,7 +89,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver { */ /*******************************************************************************/ bool getEventPM25_STD(sensors_event_t *pm25StdEvent) { - PM25_AQI_Data data; + PM25_AQI_Data data = {0}; if (!_pm25->read(&data)) return false; // couldn't read data @@ -107,7 +107,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver { */ /*******************************************************************************/ bool getEventPM100_STD(sensors_event_t *pm100StdEvent) { - PM25_AQI_Data data; + PM25_AQI_Data data = {0}; if (!_pm25->read(&data)) return false; // couldn't read data @@ -116,7 +116,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver { } protected: - Adafruit_PM25AQI *_pm25; ///< PM25 driver object + Adafruit_PM25AQI *_pm25 = nullptr; ///< PM25 driver object }; #endif // WipperSnapper_I2C_Driver_PM25 \ No newline at end of file diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h index fcaa1d94d..0dc9f4109 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h @@ -161,11 +161,11 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver { } protected: - Adafruit_SCD30 *_scd = nullptr; ///< SCD30 driver object - ulong _lastRead = 0; ///< Last time the sensor was read - sensors_event_t _temperature; ///< Temperature - sensors_event_t _humidity; ///< Relative Humidity - sensors_event_t _CO2; ///< CO2 + Adafruit_SCD30 *_scd = nullptr; ///< SCD30 driver object + ulong _lastRead = 0ul; ///< Last time the sensor was read + sensors_event_t _temperature = {0}; ///< Temperature + sensors_event_t _humidity = {0}; ///< Relative Humidity + sensors_event_t _CO2 = {0}; ///< CO2 }; #endif // WipperSnapper_I2C_Driver_SCD30 \ No newline at end of file diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h index 95c18d701..4a667b921 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h @@ -112,7 +112,7 @@ class WipperSnapper_I2C_Driver_VL53L4CD : public WipperSnapper_I2C_Driver { /*******************************************************************************/ bool getEventProximity(sensors_event_t *proximityEvent) { uint8_t NewDataReady = 0; - VL53L4CD_Result_t results; + VL53L4CD_Result_t results = {0}; uint8_t status; // Start fresh reading, seemed to be accepting stale value _VL53L4CD->VL53L4CD_ClearInterrupt(); diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h index ef8307256..b95ce09f0 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h @@ -129,7 +129,7 @@ class WipperSnapper_I2C_Driver_VL53L4CX : public WipperSnapper_I2C_Driver { */ /*******************************************************************************/ bool getProximity(sensors_event_t *proximityEvent, int whichObject = 0) { - VL53L4CX_MultiRangingData_t MultiRangingData; + VL53L4CX_MultiRangingData_t MultiRangingData = {0}; VL53L4CX_MultiRangingData_t *pMultiRangingData = &MultiRangingData; uint8_t NewDataReady = 0; int status;