mirror of
https://github.com/ddv2005/AirsoftTracker.git
synced 2026-01-10 04:57:25 +00:00
54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
#pragma once
|
|
#include "concurrency/PeriodicTask.h"
|
|
#include "PowerStatus.h"
|
|
#ifdef USE_XPOWERSLIB
|
|
#include <XPowersLib.h>
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef HAS_AXP20X
|
|
#include "axp20x.h"
|
|
#endif
|
|
|
|
class Power : public concurrency::PeriodicTask
|
|
{
|
|
#ifdef HAS_AXP20X
|
|
protected:
|
|
AXP20X_Class axp;
|
|
#endif
|
|
#ifdef USE_XPOWERSLIB
|
|
XPowersLibInterface *m_power;
|
|
bool m_pmuFound;
|
|
#endif
|
|
public:
|
|
Observable<const PowerStatus *> newStatus;
|
|
|
|
void readPowerStatus();
|
|
int loop();
|
|
virtual bool setup();
|
|
virtual void doTask();
|
|
void setStatusHandler(PowerStatus *handler)
|
|
{
|
|
statusHandler = handler;
|
|
}
|
|
|
|
void gpsOff();
|
|
void gpsOn();
|
|
void shutdown();
|
|
#ifdef HAS_AXP20X
|
|
AXP20X_Class &getAXP()
|
|
{
|
|
return axp;
|
|
}
|
|
#endif
|
|
protected:
|
|
PowerStatus *statusHandler;
|
|
#ifdef HAS_AXP20X
|
|
virtual void axp192Init();
|
|
#endif
|
|
};
|