Support multi-I2C and fix ESP32-S3 USB logging
Add dynamic I2C bus selection for battery gauge to support boards with multiple I2C controllers (e.g., Sticky uses Wire1 to avoid conflicts with GT911 touch). Fix logging on ESP32-S3 USB-Serial-JTAG by using esp_rom_printf instead of Serial, which incorrectly reports disconnected state.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Logging.h"
|
||||
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#define MAX_ENTRY_LEN 256
|
||||
@@ -59,9 +61,18 @@ void logPrintf(const char* level, const char* origin, const char* format, ...) {
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
// ESP32-S3 over USB-Serial-JTAG (HWCDC): Serial's `operator bool` reads false under a
|
||||
// host monitor (and HWCDC.write itself drops when it thinks it's disconnected), so the
|
||||
// `if (logSerial)` path below silently swallows every line. esp_rom_printf writes to the
|
||||
// always-on ROM/IDF console — the same channel that carries the boot banner and ARDUHAL
|
||||
// logs — so output is actually visible. `buf` is already fully formatted; pass via %s.
|
||||
esp_rom_printf("%s", buf);
|
||||
#else
|
||||
if (logSerial) {
|
||||
logSerial.print(buf);
|
||||
}
|
||||
#endif
|
||||
addToLogRingBuffer(buf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user