2020-03-26 16:24:53 +00:00
|
|
|
#pragma once
|
2020-07-06 19:53:10 +00:00
|
|
|
#include "concurrency/PeriodicTask.h"
|
2020-06-28 04:19:49 +00:00
|
|
|
#include "PowerStatus.h"
|
2020-03-26 16:24:53 +00:00
|
|
|
|
2020-06-21 23:21:34 +00:00
|
|
|
/**
|
|
|
|
* Per @spattinson
|
|
|
|
* MIN_BAT_MILLIVOLTS seems high. Typical 18650 are different chemistry to LiPo, even for LiPos that chart seems a bit off, other
|
|
|
|
* charts put 3690mV at about 30% for a lipo, for 18650 i think 10% remaining iis in the region of 3.2-3.3V. Reference 1st graph
|
|
|
|
* in [this test report](https://lygte-info.dk/review/batteries2012/Samsung%20INR18650-30Q%203000mAh%20%28Pink%29%20UK.html)
|
|
|
|
* looking at the red line - discharge at 0.2A - he gets a capacity of 2900mah, 90% of 2900 = 2610, that point in the graph looks
|
|
|
|
* to be a shade above 3.2V
|
|
|
|
*/
|
|
|
|
#define MIN_BAT_MILLIVOLTS 3250 // millivolts. 10% per https://blog.ampow.com/lipo-voltage-chart/
|
|
|
|
|
|
|
|
#define BAT_MILLIVOLTS_FULL 4100
|
|
|
|
#define BAT_MILLIVOLTS_EMPTY 3500
|
|
|
|
|
2020-07-06 19:53:10 +00:00
|
|
|
class Power : public concurrency::PeriodicTask
|
2020-03-26 16:24:53 +00:00
|
|
|
{
|
|
|
|
|
2020-06-28 04:19:49 +00:00
|
|
|
public:
|
|
|
|
|
2020-06-29 01:17:52 +00:00
|
|
|
Observable<const meshtastic::PowerStatus *> newStatus;
|
2020-03-26 16:24:53 +00:00
|
|
|
|
2020-06-28 04:19:49 +00:00
|
|
|
void readPowerStatus();
|
|
|
|
void loop();
|
|
|
|
virtual bool setup();
|
|
|
|
virtual void doTask();
|
2020-06-29 01:17:52 +00:00
|
|
|
void setStatusHandler(meshtastic::PowerStatus *handler)
|
2020-06-28 04:19:49 +00:00
|
|
|
{
|
|
|
|
statusHandler = handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-06-29 01:17:52 +00:00
|
|
|
meshtastic::PowerStatus *statusHandler;
|
2020-06-28 04:19:49 +00:00
|
|
|
virtual void axp192Init();
|
|
|
|
|
|
|
|
};
|
2020-04-24 21:55:51 +00:00
|
|
|
|
2020-06-28 04:19:49 +00:00
|
|
|
extern Power *power;
|