Voltage and sleep fix for NRF52

Dont let the NRF52 go to SDS Super Deep Sleep
Show bat percentage on NRF52 when above 4210 mV
This commit is contained in:
claes
2021-08-10 09:23:26 +02:00
parent b2524ceaff
commit 04c5ac0d7c
2 changed files with 8 additions and 2 deletions

View File

@@ -82,10 +82,13 @@ class AnalogBatteryLevel : public HasBatteryLevel
if (v < noBatVolt)
return -1; // If voltage is super low assume no battery installed
#ifndef NRF52_SERIES
// This does not work on a RAK4631 with battery connected
if (v > chargingVolt)
return 0; // While charging we can't report % full on the battery
#endif
return 100 * (v - emptyVolt) / (fullVolt - emptyVolt);
return clamp((int)(100 * (v - emptyVolt) / (fullVolt - emptyVolt)), 0, 100);
}
/**