Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update I2C initialisation of locals #694

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
10 changes: 5 additions & 5 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading