EXT_PWR_DETECT pin to detect external power source for boards without the power management chip

This commit is contained in:
Vladislav Osmanov
2023-04-02 11:35:25 +02:00
committed by Thomas Göttgens
co-authored by Thomas Göttgens
parent 713b5fbe96
commit 6bf538e26f
3 changed files with 14 additions and 0 deletions
+10
View File
@@ -160,8 +160,18 @@ class AnalogBatteryLevel : public HasBatteryLevel
/// If we see a battery voltage higher than physics allows - assume charger is pumping
/// in power
/// On some boards we don't have the power management chip (like AXPxxxx)
/// so we use EXT_PWR_DETECT GPIO pin to detect external power source
virtual bool isVbusIn() override
{
#ifdef EXT_PWR_DETECT
// if external powered that pin will be pulled up
if (digitalRead(EXT_PWR_DETECT) == HIGH) {
return true;
}
// if it's not HIGH - check the battery
#endif
return getBattVoltage() > chargingVolt;
}