bug #279 change battery voltage to millivolts

This commit is contained in:
geeksville 2020-08-13 11:23:27 -07:00
parent 8c7aa07c70
commit 3de1607cea

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