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,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "app.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
struct AppInfo {
|
||||
const char* id;
|
||||
const char* title;
|
||||
bool hidden; // not listed in the Launcher, but can still be opened
|
||||
App* app;
|
||||
};
|
||||
|
||||
// Owns which App is in the foreground and routes keys. Home always returns to the Launcher;
|
||||
// Back is offered to the App first and returns to the Launcher if the App doesn't consume it.
|
||||
class AppManager {
|
||||
public:
|
||||
explicit AppManager(App& launcher);
|
||||
|
||||
void registerApp(const AppInfo& info);
|
||||
std::vector<const AppInfo*> visibleApps() const;
|
||||
|
||||
void begin();
|
||||
bool open(const char* id);
|
||||
void home();
|
||||
|
||||
void handleKey(const KeyEvent& event);
|
||||
|
||||
App& foreground() const { return *foreground_; }
|
||||
|
||||
// True once after the screen needs redrawing (App switch, or the App asked for it).
|
||||
bool takeRedraw();
|
||||
|
||||
private:
|
||||
void switchTo(App& app);
|
||||
|
||||
App& launcher_;
|
||||
App* foreground_;
|
||||
std::vector<AppInfo> apps_;
|
||||
bool redraw_ = true;
|
||||
};
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user