Skip to content

Commit

Permalink
Fix battery monitor stuff for non battery things
Browse files Browse the repository at this point in the history
  • Loading branch information
justcallmekoko committed Dec 15, 2024
1 parent 006e750 commit 79f8c0e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 45 deletions.
89 changes: 46 additions & 43 deletions esp32_marauder/BatteryInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions esp32_marauder/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79f8c0e

Please sign in to comment.