Public Access
Fn+h on any screen, text fields included, and ? outside Text Entry, open a panel over the content area: the screen's own keys, then the ones that work everywhere. Every App declares its keys for the state it is in (pages, viewers, dialogs and text fields answer for themselves); the App manager opens the panel and takes every key while it is open. About 30 hint lines are gone, from every App. What stays on a screen is state. The first-start Setup keeps its hints and teaches the key; a device set up before gets one Toast, once. The guide and the FAQ open with it. `key help` over the consoles. 476 host tests (8 new). Checked on the device with key help and screenshots: the Launcher, all nine Apps and several of their states. 8.5 KB of flash and 40 bytes of static RAM. Decisions Q196 to Q203 in docs/milestones/U1.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
77 lines
3.1 KiB
C++
77 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
|
|
#include "event_bus.h"
|
|
#include "key_value_store.h"
|
|
|
|
namespace roro {
|
|
|
|
enum class Setting : uint8_t {
|
|
SetupDone, // bool: first-boot wizard completed
|
|
LongName, // string, 1..39 bytes
|
|
ShortName, // string, 1..4 bytes
|
|
Region, // string, a known Region ("EU868")
|
|
RegionConfirmed, // bool: nothing transmits until true
|
|
Timezone, // string, POSIX TZ
|
|
Brightness, // int, 10..100 %
|
|
DimTimeoutS, // int, 5..600, below OffTimeoutS
|
|
OffTimeoutS, // int, 10..3600, above DimTimeoutS
|
|
Sound, // bool
|
|
ProbeMacRaw, // bool: probe-request Logs keep raw MAC addresses
|
|
WifiEnabled, // bool: the Wi-Fi Service stays Connected when a Saved Network is in range
|
|
GnssEnabled, // bool: the GNSS Service reads the receiver (M2, Q58)
|
|
CoordinatesDms, // bool: show degrees, minutes and seconds instead of decimal degrees (Q64)
|
|
LoraPreset, // int: the LoRa Scanner's Meshtastic preset, an index into the EU868 list (M3, Q95)
|
|
Dns1, // string: the first DNS server, an IPv4 address (S1, Q108, Q109)
|
|
Dns2, // string: the second, or empty
|
|
DnsAlways, // bool: use them on Automatic (DHCP) networks too, instead of DHCP's
|
|
Ntp1, // string: the first NTP server, a host name or an IPv4 address (S1, Q110)
|
|
Ntp2, // string: the second, or empty
|
|
GnssQuietForLora, // bool: put the GNSS receiver in standby while the LoRa radio listens (issue #20)
|
|
CheckUpdates, // bool: look for a newer release on Gitea once a day (R1, Q165)
|
|
DebugConsole, // bool: the Debug Console listens on Wi-Fi (ADR 0010, Q189: off unless switched on)
|
|
DebugToken, // string: its token, tidied (debug_auth.h); empty until the console is first switched on
|
|
HelpTold, // bool: this device has been told about the help key once (issue #69, Q201)
|
|
Count
|
|
};
|
|
|
|
// Typed, validated settings in internal flash. Every accepted change is persisted immediately and
|
|
// announced with a SettingChanged event; rejected values leave the current value untouched.
|
|
class Settings {
|
|
public:
|
|
Settings(KeyValueStore& store, EventBus& bus);
|
|
|
|
// Reads every setting; missing or invalid stored values fall back to defaults.
|
|
void load();
|
|
|
|
int32_t getInt(Setting s) const;
|
|
bool getBool(Setting s) const;
|
|
const std::string& getString(Setting s) const;
|
|
|
|
bool setInt(Setting s, int32_t value);
|
|
bool setBool(Setting s, bool value);
|
|
bool setString(Setting s, const std::string& value);
|
|
|
|
bool canTransmit() const { return getBool(Setting::RegionConfirmed); }
|
|
|
|
static const char* key(Setting s);
|
|
|
|
private:
|
|
struct Value {
|
|
int32_t i = 0;
|
|
std::string str;
|
|
};
|
|
|
|
bool validInt(Setting s, int32_t value) const;
|
|
bool validString(Setting s, const std::string& value) const;
|
|
void changed(Setting s);
|
|
|
|
KeyValueStore& store_;
|
|
EventBus& bus_;
|
|
std::array<Value, static_cast<size_t>(Setting::Count)> values_;
|
|
};
|
|
|
|
} // namespace roro
|