Public Access
Add M0 services: settings, battery, clock, storage, power
lib/services holds the host-tested logic: - Settings: typed, validated, persisted, SettingChanged events, transmit gated on a confirmed Region - BatteryEstimator: LiPo curve, median smoothing against TX sags - ClockModel: source priority GNSS > NTP > mesh, relative ages, Europe/Brussels local time via POSIX TZ - StorageMonitor: warning once per boot at 80%, Logs stop at 90%, Captures stop with < 2 MiB left - PowerPolicy / PowerButton: dim/off timeouts, wake key swallowed only when the screen was off, G0 long press src/services wires them to the hardware (NVS, battery ADC, SD on the shared SPI bus with the LoRa CS held high, backlight, deep sleep), and main.cpp is a temporary diagnostics screen for the hardware checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "event_bus.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
struct StorageState {
|
||||
bool present = false;
|
||||
uint64_t totalBytes = 0;
|
||||
uint64_t usedBytes = 0;
|
||||
int usedPercent = 0;
|
||||
int level = 0; // 0, 80, 90 or 100 (full)
|
||||
bool logsAllowed = false;
|
||||
bool capturesAllowed = false;
|
||||
};
|
||||
|
||||
// Applies the SD card rules (see CONTEXT.md): Storage Warning once per boot past 80 %, Logs stop
|
||||
// past 90 % to keep room for Captures, Captures stop when the card is full.
|
||||
class StorageMonitor {
|
||||
public:
|
||||
static constexpr uint64_t kFullReserveBytes = 2ull * 1024 * 1024;
|
||||
|
||||
explicit StorageMonitor(EventBus& bus) : bus_(bus) {}
|
||||
|
||||
void update(bool present, uint64_t totalBytes, uint64_t usedBytes);
|
||||
const StorageState& state() const { return state_; }
|
||||
|
||||
private:
|
||||
EventBus& bus_;
|
||||
StorageState state_;
|
||||
bool warned_ = false;
|
||||
};
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user