2020-11-08 13:14:56 +00:00
|
|
|
#ifndef POWER_MANAGEMENT_H_
|
|
|
|
#define POWER_MANAGEMENT_H_
|
|
|
|
|
2023-09-09 21:13:48 +00:00
|
|
|
#include <Wire.h>
|
|
|
|
#include <XPowersLibInterface.hpp>
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
class PowerManagement {
|
2020-11-08 13:14:56 +00:00
|
|
|
public:
|
2023-09-09 21:13:48 +00:00
|
|
|
~PowerManagement() {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool begin(TwoWire &port) = 0;
|
|
|
|
|
|
|
|
virtual void activateLoRa() = 0;
|
|
|
|
virtual void deactivateLoRa() = 0;
|
|
|
|
|
|
|
|
virtual void activateGPS() = 0;
|
|
|
|
virtual void deactivateGPS() = 0;
|
|
|
|
|
|
|
|
virtual void activateOLED() = 0;
|
|
|
|
virtual void deactivateOLED() = 0;
|
|
|
|
|
|
|
|
virtual void activateMeasurement() = 0;
|
|
|
|
virtual void deactivateMeasurement() = 0;
|
|
|
|
|
|
|
|
virtual double getBatteryVoltage() = 0;
|
|
|
|
|
|
|
|
virtual double getBatteryChargeDischargeCurrent() = 0;
|
|
|
|
|
|
|
|
virtual bool isBatteryConnect() = 0;
|
|
|
|
virtual bool isCharging() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
XPowersLibInterface *_pmu = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AXP192 : public PowerManagement {
|
|
|
|
public:
|
|
|
|
AXP192();
|
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
bool begin(TwoWire &port);
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
void activateLoRa();
|
|
|
|
void deactivateLoRa();
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
void activateGPS();
|
|
|
|
void deactivateGPS();
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
void activateOLED();
|
2023-09-09 21:13:48 +00:00
|
|
|
void deactivateOLED();
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2022-05-13 18:32:38 +00:00
|
|
|
void enableChgLed();
|
|
|
|
void disableChgLed();
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
void activateMeasurement();
|
|
|
|
void deactivateMeasurement();
|
2020-11-09 22:09:41 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
double getBatteryVoltage();
|
|
|
|
double getBatteryChargeDischargeCurrent();
|
2020-11-08 13:14:56 +00:00
|
|
|
|
2021-10-14 21:31:56 +00:00
|
|
|
bool isBatteryConnect();
|
2023-09-09 21:13:48 +00:00
|
|
|
bool isCharging();
|
|
|
|
};
|
|
|
|
|
|
|
|
class AXP2101 : public PowerManagement {
|
|
|
|
public:
|
|
|
|
AXP2101();
|
|
|
|
|
|
|
|
bool begin(TwoWire &port);
|
2021-04-19 20:34:04 +00:00
|
|
|
|
2023-09-09 21:13:48 +00:00
|
|
|
void activateLoRa();
|
|
|
|
void deactivateLoRa();
|
|
|
|
|
|
|
|
void activateGPS();
|
|
|
|
void deactivateGPS();
|
|
|
|
|
|
|
|
void activateOLED();
|
|
|
|
void deactivateOLED();
|
|
|
|
|
|
|
|
void enableChgLed();
|
|
|
|
void disableChgLed();
|
|
|
|
|
|
|
|
void activateMeasurement();
|
|
|
|
void deactivateMeasurement();
|
|
|
|
|
|
|
|
double getBatteryVoltage();
|
|
|
|
double getBatteryChargeDischargeCurrent();
|
|
|
|
|
|
|
|
bool isBatteryConnect();
|
|
|
|
bool isCharging();
|
2020-11-08 13:14:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|