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,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <Preferences.h>
|
||||
|
||||
#include "key_value_store.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
// Settings persistence in the ESP32's internal flash (NVS).
|
||||
class NvsStore : public KeyValueStore {
|
||||
public:
|
||||
void begin() { prefs_.begin("roro", false); }
|
||||
|
||||
bool getInt(const char* key, int32_t& out) override {
|
||||
if (!prefs_.isKey(key)) return false;
|
||||
out = prefs_.getInt(key);
|
||||
return true;
|
||||
}
|
||||
bool getString(const char* key, std::string& out) override {
|
||||
if (!prefs_.isKey(key)) return false;
|
||||
out = prefs_.getString(key).c_str();
|
||||
return true;
|
||||
}
|
||||
void putInt(const char* key, int32_t value) override { prefs_.putInt(key, value); }
|
||||
void putString(const char* key, const std::string& value) override {
|
||||
prefs_.putString(key, value.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
Preferences prefs_;
|
||||
};
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user