Files
roro9stack/lib/core/src/event.h
T
twislaandClaude Opus 5.5 987406fa7c 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
2026-10-02 09:47:36 +02:00

44 lines
1.1 KiB
C++

#pragma once
#include <cstdint>
#include <cstring>
namespace roro {
enum class NotificationLevel : int32_t { Info, Warning, Message };
// Everything Services announce to the UI. Add new kinds before Count.
enum class EventType : uint8_t {
BatteryChanged, // a = percent, b = millivolts
Notification, // text = message, a = NotificationLevel
StorageThreshold, // a = usage percent, b = level now in effect (0 / 80 / 90 / 100)
SettingChanged, // a = Setting, text = storage key
Count
};
// Small, fixed-size and copyable so it can cross tasks through a queue without allocating.
struct Event {
static constexpr size_t kTextCapacity = 48;
EventType type;
int32_t a = 0;
int32_t b = 0;
char text[kTextCapacity] = {};
static Event withValues(EventType type, int32_t a, int32_t b = 0) {
Event e{type};
e.a = a;
e.b = b;
return e;
}
static Event withText(EventType type, const char* text, int32_t a = 0) {
Event e{type};
e.a = a;
std::strncpy(e.text, text, kTextCapacity - 1);
return e;
}
};
} // namespace roro