Public Access
Add core runtime: event bus, services, app lifecycle
lib/core is hardware-independent and unit-tested on the host: - EventBus: fixed-size thread-safe queue, delivered on the UI task by dispatch(); drops newest when full and counts drops - Service / ServiceManager: cooperative ticking at per-service intervals, no catch-up bursts, safe across millis() wraparound - App / AppManager: one foreground App, Home always to Launcher, Back offered to the App first, hidden Apps, redraw requests - KeyEvent: logical keys for the upcoming input layer Firmware main loop now ticks services and dispatches events. 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,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace roro {
|
||||
|
||||
// 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 = threshold crossed (80 / 90 / 100)
|
||||
SettingChanged, // text = setting 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
|
||||
Reference in New Issue
Block a user