Merge pull request #316 from geeksville/master

for bug #279
This commit is contained in:
Kevin Hester 2020-08-13 11:30:25 -07:00 committed by GitHub
commit cba9546a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,22 +33,22 @@ class AnalogBatteryLevel : public HasBatteryLevel
*/
virtual int getBattPercentage()
{
float v = getBattVoltage();
float v = getBattVoltage() / 1000;
if (v < 2.1)
return -1;
return 100 * (getBattVoltage() - 3.27) / (4.2 - 3.27);
return 100 * (v - 3.27) / (4.2 - 3.27);
}
/**
* The raw voltage of the battery or NAN if unknown
* The raw voltage of the batteryin millivolts or NAN if unknown
*/
virtual float getBattVoltage()
{
return
#ifdef BATTERY_PIN
analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);
1000.0 * analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);
#else
NAN;
#endif
@ -213,7 +213,6 @@ bool Power::axp192Init()
#endif
}
void Power::loop()
{
#ifdef PMU_IRQ