From a4ad0e5b98fc048865e19ee6f3e8b4cf10ad3575 Mon Sep 17 00:00:00 2001 From: Jason Carmi Date: Tue, 5 Jan 2021 05:47:45 -0800 Subject: [PATCH 1/5] Update Adafruit_INA219.cpp --- Adafruit_INA219.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Adafruit_INA219.cpp b/Adafruit_INA219.cpp index 6c01933..07ef887 100644 --- a/Adafruit_INA219.cpp +++ b/Adafruit_INA219.cpp @@ -46,7 +46,9 @@ Adafruit_INA219::Adafruit_INA219(uint8_t addr) { * @return true: success false: Failed to start I2C */ bool Adafruit_INA219::begin(TwoWire *theWire) { - i2c_dev = new Adafruit_I2CDevice(ina219_i2caddr, theWire); + if (!i2c_dev) { + i2c_dev = new Adafruit_I2CDevice(ina219_i2caddr, theWire); + } if (!i2c_dev->begin()) { return false; From 0b72d3e98dc8ede541ec6f367cf7c343a4ffb80e Mon Sep 17 00:00:00 2001 From: Jason Carmi Date: Tue, 5 Jan 2021 06:04:50 -0800 Subject: [PATCH 2/5] Update Adafruit_INA219.cpp --- Adafruit_INA219.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Adafruit_INA219.cpp b/Adafruit_INA219.cpp index 07ef887..ee5366f 100644 --- a/Adafruit_INA219.cpp +++ b/Adafruit_INA219.cpp @@ -40,6 +40,13 @@ Adafruit_INA219::Adafruit_INA219(uint8_t addr) { ina219_powerMultiplier_mW = 0.0f; } +/*! + * @brief INA219 class destructor + */ +Adafruit_INA219::~Adafruit_INA219() { + delete i2c_dev; +} + /*! * @brief Sets up the HW (defaults to 32V and 2A for calibration values) * @param theWire the TwoWire object to use From aaf800d9c7cb3b084047c43df11c4bf285590e77 Mon Sep 17 00:00:00 2001 From: Jason Carmi Date: Tue, 5 Jan 2021 06:31:21 -0800 Subject: [PATCH 3/5] Declare destructor --- Adafruit_INA219.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Adafruit_INA219.h b/Adafruit_INA219.h index c04651d..791e06a 100644 --- a/Adafruit_INA219.h +++ b/Adafruit_INA219.h @@ -149,6 +149,7 @@ enum { class Adafruit_INA219 { public: Adafruit_INA219(uint8_t addr = INA219_ADDRESS); + ~Adafruit_INA219(); bool begin(TwoWire *theWire = &Wire); void setCalibration_32V_2A(); void setCalibration_32V_1A(); From 9036b467d50b40e880b5ad3dbef3d640e88e93cb Mon Sep 17 00:00:00 2001 From: Jason Carmi Date: Tue, 5 Jan 2021 08:04:46 -0800 Subject: [PATCH 4/5] clang format --- Adafruit_INA219.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Adafruit_INA219.cpp b/Adafruit_INA219.cpp index ee5366f..974f7aa 100644 --- a/Adafruit_INA219.cpp +++ b/Adafruit_INA219.cpp @@ -43,9 +43,7 @@ Adafruit_INA219::Adafruit_INA219(uint8_t addr) { /*! * @brief INA219 class destructor */ -Adafruit_INA219::~Adafruit_INA219() { - delete i2c_dev; -} +Adafruit_INA219::~Adafruit_INA219() { delete i2c_dev; } /*! * @brief Sets up the HW (defaults to 32V and 2A for calibration values) From 0fe9d91db719456e682ded80737e2284c5fd48a9 Mon Sep 17 00:00:00 2001 From: Jason Carmi Date: Tue, 5 Jan 2021 08:27:21 -0800 Subject: [PATCH 5/5] one more once --- Adafruit_INA219.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_INA219.cpp b/Adafruit_INA219.cpp index 974f7aa..590a87c 100644 --- a/Adafruit_INA219.cpp +++ b/Adafruit_INA219.cpp @@ -42,7 +42,7 @@ Adafruit_INA219::Adafruit_INA219(uint8_t addr) { /*! * @brief INA219 class destructor - */ + */ Adafruit_INA219::~Adafruit_INA219() { delete i2c_dev; } /*!