How can I monitor the status of the power connection through the pogo pins on the Bottom2 module? Are there any specific methods or code examples for detecting power presence or absence?
M5.Lcd.setCursor(startX, currentY);
float vinVoltage = M5.Axp.GetVinVoltage();
bool hasUsbPower = (vinVoltage > 4.5);
bool hasBackPower = M5.Axp.isCharging(); // Check if charging via any source
M5.Lcd.setTextColor(WHITE);
M5.Lcd.print(F("USB-C: "));
M5.Lcd.setTextColor(hasUsbPower ? PAL_GREEN : RED);
M5.Lcd.printf("%.1fV", vinVoltage);
currentY += lineSpacing;
M5.Lcd.setCursor(startX, currentY);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.print(F("Back: "));
M5.Lcd.setTextColor(hasBackPower ? PAL_GREEN : RED);
if (hasBackPower && !hasUsbPower) { // Only show back power if it's the source
M5.Lcd.printf("%.1fV", M5.Axp.GetVBusVoltage());
} else {
M5.Lcd.print(" --");
}
currentY += lineSpacing;
// Check battery level
M5.Lcd.setCursor(startX, currentY);
float batteryLevel = M5.Axp.GetBatteryLevel();
M5.Lcd.setTextColor(WHITE);
M5.Lcd.print(F("Battery: "));
M5.Lcd.setTextColor(batteryLevel > 20 ? PAL_GREEN : RED);
M5.Lcd.printf("%d%%", (int)batteryLevel);
currentY += lineSpacing;