mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-02 10:50:40 +00:00
bug #279 change battery voltage to millivolts
This commit is contained in:
parent
8c7aa07c70
commit
3de1607cea
@ -33,22 +33,22 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
*/
|
*/
|
||||||
virtual int getBattPercentage()
|
virtual int getBattPercentage()
|
||||||
{
|
{
|
||||||
float v = getBattVoltage();
|
float v = getBattVoltage() / 1000;
|
||||||
|
|
||||||
if (v < 2.1)
|
if (v < 2.1)
|
||||||
return -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()
|
virtual float getBattVoltage()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
#ifdef BATTERY_PIN
|
#ifdef BATTERY_PIN
|
||||||
analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);
|
1000.0 * analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);
|
||||||
#else
|
#else
|
||||||
NAN;
|
NAN;
|
||||||
#endif
|
#endif
|
||||||
@ -213,7 +213,6 @@ bool Power::axp192Init()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Power::loop()
|
void Power::loop()
|
||||||
{
|
{
|
||||||
#ifdef PMU_IRQ
|
#ifdef PMU_IRQ
|
||||||
|
Loading…
Reference in New Issue
Block a user