From a0ace8bbf0bcd85a55ff29b38b1b60b088c24645 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Sat, 7 Dec 2024 01:02:18 -0500 Subject: [PATCH] Only check for know i2c addrs --- esp32_marauder/BatteryInterface.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/esp32_marauder/BatteryInterface.cpp b/esp32_marauder/BatteryInterface.cpp index 8289988..816b915 100644 --- a/esp32_marauder/BatteryInterface.cpp +++ b/esp32_marauder/BatteryInterface.cpp @@ -28,7 +28,27 @@ void BatteryInterface::RunSetup() { Serial.println("Checking for battery monitors..."); - for(addr = 1; addr < 127; addr++ ) { + Wire.beginTransmission(IP5306_ADDR); + error = Wire.endTransmission(); + + if (error == 0) { + Serial.println("Detected IP5306"); + this->has_ip5306 = true; + this->i2c_supported = true; + } + + Wire.beginTransmission(MAX17048_ADDR); + error = Wire.endTransmission(); + + if (error == 0) { + if (maxlipo.begin()) { + Serial.println("Detected MAX17048"); + this->has_max17048 = true; + this->i2c_supported = true; + } + } + + /*for(addr = 1; addr < 127; addr++ ) { Wire.beginTransmission(addr); error = Wire.endTransmission(); @@ -54,7 +74,7 @@ void BatteryInterface::RunSetup() { } } } - } + }*/ /*if (this->maxlipo.begin()) { Serial.println("Detected MAX17048");