mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 21:17:43 +00:00
Battery info switcher (#2230)
This commit is contained in:
@@ -27,6 +27,10 @@
|
||||
|
||||
namespace battery {
|
||||
|
||||
#define BATTERY_MIN_VOLTAGE 3000.0
|
||||
#define BATTERY_MAX_VOLTAGE 4170.0
|
||||
#define BATTERY_DESIGN_CAP 2500
|
||||
|
||||
class BatteryManagement {
|
||||
public:
|
||||
enum BatteryModules {
|
||||
@@ -39,8 +43,9 @@ class BatteryManagement {
|
||||
BATT_VALID_NONE = 0,
|
||||
BATT_VALID_VOLTAGE = 1,
|
||||
BATT_VALID_CURRENT = 2,
|
||||
BATT_VALID_PERCENT = 4,
|
||||
};
|
||||
static void init();
|
||||
static void init(bool override = false);
|
||||
static void detect();
|
||||
static bool isDetected() { return detected_ != BATT_NONE; }
|
||||
static BatteryModules detectedModule() { return detected_; }
|
||||
@@ -49,12 +54,15 @@ class BatteryManagement {
|
||||
static uint8_t getPercent();
|
||||
static uint16_t read_register(const uint8_t reg);
|
||||
static bool write_register(const uint8_t reg, const uint16_t value);
|
||||
static void set_calc_override(bool override);
|
||||
static uint8_t calc_percent_voltage(uint16_t); // calculates battery percentage from the voltage
|
||||
|
||||
private:
|
||||
static void create_thread();
|
||||
static msg_t timer_fn(void* arg);
|
||||
static Thread* thread;
|
||||
static BatteryModules detected_; // if there is any batt management system
|
||||
static bool calcOverride; // if set to true, it'll override the battery percent calculation based on current voltage.
|
||||
};
|
||||
}; // namespace battery
|
||||
#endif
|
Reference in New Issue
Block a user