feat: Add OLED size build flag support and implement PowerManager for enhanced power management

This commit is contained in:
Joshua King
2026-03-03 08:41:49 -05:00
parent 16b9471107
commit b60f44f99f
8 changed files with 310 additions and 22 deletions

26
src/power/PowerManager.h Normal file
View 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;
};