From 79f8c0ec52e744dce5f2b67702c372ba028c36b0 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Sat, 14 Dec 2024 22:15:58 -0500 Subject: [PATCH] Fix battery monitor stuff for non battery things --- esp32_marauder/BatteryInterface.cpp | 89 +++++++++++++++-------------- esp32_marauder/configs.h | 4 +- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/esp32_marauder/BatteryInterface.cpp b/esp32_marauder/BatteryInterface.cpp index 816b915f3..d6b566544 100644 --- a/esp32_marauder/BatteryInterface.cpp +++ b/esp32_marauder/BatteryInterface.cpp @@ -24,65 +24,68 @@ void BatteryInterface::RunSetup() { byte error; byte addr; - Wire.begin(I2C_SDA, I2C_SCL); + #ifdef HAS_BATTERY - Serial.println("Checking for battery monitors..."); + Wire.begin(I2C_SDA, I2C_SCL); - Wire.beginTransmission(IP5306_ADDR); - error = Wire.endTransmission(); + Serial.println("Checking for battery monitors..."); - if (error == 0) { - Serial.println("Detected IP5306"); - this->has_ip5306 = true; - this->i2c_supported = true; - } - - Wire.beginTransmission(MAX17048_ADDR); - error = Wire.endTransmission(); + Wire.beginTransmission(IP5306_ADDR); + error = Wire.endTransmission(); - if (error == 0) { - if (maxlipo.begin()) { - Serial.println("Detected MAX17048"); - this->has_max17048 = true; + if (error == 0) { + Serial.println("Detected IP5306"); + this->has_ip5306 = true; this->i2c_supported = true; } - } - /*for(addr = 1; addr < 127; addr++ ) { - Wire.beginTransmission(addr); + Wire.beginTransmission(MAX17048_ADDR); error = Wire.endTransmission(); - if (error == 0) - { - Serial.print("I2C device found at address 0x"); - - if (addr<16) - Serial.print("0"); - - Serial.println(addr,HEX); - - if (addr == IP5306_ADDR) { - this->has_ip5306 = true; + if (error == 0) { + if (maxlipo.begin()) { + Serial.println("Detected MAX17048"); + this->has_max17048 = true; this->i2c_supported = true; } + } - if (addr == MAX17048_ADDR) { - if (maxlipo.begin()) { - Serial.println("Detected MAX17048"); - this->has_max17048 = true; + /*for(addr = 1; addr < 127; addr++ ) { + Wire.beginTransmission(addr); + error = Wire.endTransmission(); + + if (error == 0) + { + Serial.print("I2C device found at address 0x"); + + if (addr<16) + Serial.print("0"); + + Serial.println(addr,HEX); + + if (addr == IP5306_ADDR) { + this->has_ip5306 = true; this->i2c_supported = true; } + + if (addr == MAX17048_ADDR) { + if (maxlipo.begin()) { + Serial.println("Detected MAX17048"); + this->has_max17048 = true; + this->i2c_supported = true; + } + } } - } - }*/ + }*/ - /*if (this->maxlipo.begin()) { - Serial.println("Detected MAX17048"); - this->has_max17048 = true; - this->i2c_supported = true; - }*/ - - this->initTime = millis(); + /*if (this->maxlipo.begin()) { + Serial.println("Detected MAX17048"); + this->has_max17048 = true; + this->i2c_supported = true; + }*/ + + this->initTime = millis(); + #endif } int8_t BatteryInterface::getBatteryLevel() { diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index a6ade7365..872a5fab3 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -12,10 +12,10 @@ //#define MARAUDER_V4 //#define MARAUDER_V6 //#define MARAUDER_V6_1 - #define MARAUDER_V7 + //#define MARAUDER_V7 //#define MARAUDER_KIT //#define GENERIC_ESP32 - //#define MARAUDER_FLIPPER + #define MARAUDER_FLIPPER //#define ESP32_LDDB //#define MARAUDER_DEV_BOARD_PRO //#define XIAO_ESP32_S3