From 1fde1e72fbc84f8da494a9dd13cef081852fc7cd Mon Sep 17 00:00:00 2001 From: peacemakerv2 Date: Sun, 3 Aug 2025 19:12:28 +0400 Subject: [PATCH 1/3] Update "begin" with optional i2c-pins --- Beastdevices_INA3221.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Beastdevices_INA3221.cpp b/Beastdevices_INA3221.cpp index 04f6d2f..418d29b 100644 --- a/Beastdevices_INA3221.cpp +++ b/Beastdevices_INA3221.cpp @@ -49,9 +49,10 @@ void Beastdevices_INA3221::_write(ina3221_reg_t reg, uint16_t *val) { _i2c->endTransmission(); } -void Beastdevices_INA3221::begin(TwoWire *theWire) { +bool Beastdevices_INA3221::begin(TwoWire *theWire, int sdaPin, int sclPin) { _i2c = theWire; - + + // Initialize shunt resistors with default values _shuntRes[0] = 10; _shuntRes[1] = 10; _shuntRes[2] = 10; @@ -60,7 +61,11 @@ void Beastdevices_INA3221::begin(TwoWire *theWire) { _filterRes[1] = 0; _filterRes[2] = 0; - _i2c->begin(); + if (sdaPin != -1 && sclPin != -1) { + return _i2c->begin(sdaPin, sclPin); + } else { + return _i2c->begin(); + } } void Beastdevices_INA3221::setShuntRes(uint32_t res_ch1, uint32_t res_ch2, uint32_t res_ch3) { From e659cf5944b4acd6ca4a59063416ed36ba755066 Mon Sep 17 00:00:00 2001 From: peacemakerv2 Date: Sun, 3 Aug 2025 19:12:39 +0400 Subject: [PATCH 2/3] Update "begin" with optional i2c-pins --- Beastdevices_INA3221.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Beastdevices_INA3221.h b/Beastdevices_INA3221.h index 4293d56..e2f3939 100644 --- a/Beastdevices_INA3221.h +++ b/Beastdevices_INA3221.h @@ -156,7 +156,7 @@ class Beastdevices_INA3221 { Beastdevices_INA3221(ina3221_addr_t addr) : _i2c_addr(addr) {}; // Initializes INA3221 - void begin(TwoWire *theWire = &Wire); + bool begin(TwoWire *theWire, int sdaPin = -1, int sclPin = -1); // Sets shunt resistor value in mOhm void setShuntRes(uint32_t res_ch1, uint32_t res_ch2, uint32_t res_ch3); @@ -308,4 +308,4 @@ class Beastdevices_INA3221 { float getVoltage(ina3221_ch_t channel); }; -#endif \ No newline at end of file +#endif From 40cf4321e66a024cc014ac912cdb90942256bc54 Mon Sep 17 00:00:00 2001 From: peacemakerv2 Date: Sun, 3 Aug 2025 20:52:55 +0400 Subject: [PATCH 3/3] Update "begin" for custom i2c GPIO numbers --- Beastdevices_INA3221.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Beastdevices_INA3221.h b/Beastdevices_INA3221.h index e2f3939..fad950c 100644 --- a/Beastdevices_INA3221.h +++ b/Beastdevices_INA3221.h @@ -156,7 +156,7 @@ class Beastdevices_INA3221 { Beastdevices_INA3221(ina3221_addr_t addr) : _i2c_addr(addr) {}; // Initializes INA3221 - bool begin(TwoWire *theWire, int sdaPin = -1, int sclPin = -1); + bool begin(TwoWire *theWire, int sdaPin = -1, int sclPin = -1); //Update "begin" for custom i2c GPIO numbers // Sets shunt resistor value in mOhm void setShuntRes(uint32_t res_ch1, uint32_t res_ch2, uint32_t res_ch3);