fix: Remove BQ27220 battery current USB detection for X3 (#3809)
Fix X3 startup I²C errors by routing USB/charging detection through the SDK’s `BatteryMonitor`, which initializes the bus before reading the fuel gauge. Removes duplicate raw Wire helpers and keeps GPIO20 reserved for I²C on X3. Battery percentage calculation and the positive-current charging rule remain unchanged We already read **actual battery current** from the X3’s BQ27220 **fuel gauge**. It’s separate from the charging circuit. The fix keeps the same reading: register `0x0C`, interpreted as signed milliamps. It just routes that read through the SDK so I²C is initialized first. The distinction is **battery current versus USB connection**: - Positive current → battery charging. - Negative current → battery discharging. - Near zero → little battery current; USB could be connected or disconnected. So the current reading but we can't reliably infer from it is whether a cable is attached especially when the battery is full. The UI currently calls this “USB connected,” but the X3 implementation actually means “battery current is positive."
J
Justin Mitchell committed
e2dfdeaf92431a67925fff6dc7d6c4b9c3e4a75e
Parent: 099e89b
Committed by GitHub <noreply@github.com>
on 10/1/2026, 5:45:17 AM