feat: Add OLED size build flag support and implement PowerManager for enhanced power management
This commit is contained in:
26
src/power/PowerManager.h
Normal file
26
src/power/PowerManager.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../sensors/BatterySensor.h"
|
||||
#include "../ui/Display.h"
|
||||
|
||||
class PowerManager {
|
||||
public:
|
||||
void begin(unsigned long bootMs);
|
||||
void setBatteryAwakeWindowMs(unsigned long windowMs);
|
||||
void loop(const BatterySensor& battery);
|
||||
|
||||
bool isPluggedIn() const { return _pluggedIn; }
|
||||
bool batteryWindowElapsed(unsigned long nowMs) const;
|
||||
|
||||
void deepSleepForSeconds(uint32_t seconds, const char* reason, Display* display = nullptr) const;
|
||||
|
||||
private:
|
||||
bool detectPluggedIn(const BatterySensor& battery) const;
|
||||
|
||||
bool _pluggedIn = true;
|
||||
bool _plugStateInitialized = false;
|
||||
unsigned long _bootMs = 0;
|
||||
unsigned long _onBatterySinceMs = 0;
|
||||
unsigned long _batteryAwakeWindowMs = 2UL * 60UL * 1000UL;
|
||||
};
|
||||
Reference in New Issue
Block a user