refactor(api)!: one namespace per feature, screen split out
Namespaces were shared across features: `settings` was written by core, the
panel and touch, and `input` by touch and buttons. That made "does this
firmware implement the whole feature?" a question no pointer could answer.
Each namespace now belongs to exactly one feature or to core, so a feature is
a provider pointer and the compiler validates completeness:
gui, node -> screen, tree, under the screen feature
settings -> screen (rotation, theme), sys (timezone),
touch (calibration)
input -> touch, buttons
Runtime::open() no longer requires a GuiProvider; a firmware without one runs
with no screen/tree globals and reports sys.hasFeature("screen") false.
Rotation is one value again: GuiProvider::setRotation applies and persists, so
an app rotating the panel transiently puts the old value back itself.
This commit is contained in:
@@ -35,19 +35,6 @@ struct MemoryInfo {
|
||||
int32_t largestFreeBlock;
|
||||
};
|
||||
|
||||
class SettingsProvider {
|
||||
public:
|
||||
virtual ~SettingsProvider() = default;
|
||||
virtual int32_t rotation() const = 0;
|
||||
virtual Status setRotation(int32_t degrees) = 0;
|
||||
virtual std::string timezone() const = 0;
|
||||
virtual Status setTimezone(const std::string& timezone) = 0;
|
||||
// Only the name of a palette; the colours themselves live in Lua, so the
|
||||
// firmware can read the saved theme before a lua_State exists.
|
||||
virtual std::string theme() const = 0;
|
||||
virtual Status setTheme(const std::string& theme) = 0;
|
||||
};
|
||||
|
||||
// Only what the firmware alone can answer. App identity, titles, data paths,
|
||||
// feature reporting and navigation are the runtime's, because it owns app
|
||||
// loading and knows which providers exist.
|
||||
@@ -57,6 +44,8 @@ public:
|
||||
virtual int32_t millis() const = 0;
|
||||
virtual MemoryInfo memory() const = 0;
|
||||
virtual bool isClockSynced() const = 0;
|
||||
virtual std::string timezone() const = 0;
|
||||
virtual Status setTimezone(const std::string& timezone) = 0;
|
||||
};
|
||||
|
||||
// Scripts are streamed rather than slurped: a whole module in one buffer needs
|
||||
@@ -115,7 +104,13 @@ public:
|
||||
virtual int32_t width() const = 0;
|
||||
virtual int32_t height() const = 0;
|
||||
virtual int32_t rotation() const = 0;
|
||||
virtual void setRotation(int32_t degrees) = 0;
|
||||
// Applies the rotation and persists it, so the panel comes back the way the
|
||||
// user left it with no second call to forget.
|
||||
virtual Status setRotation(int32_t degrees) = 0;
|
||||
// Only the name of a palette; the colours themselves live in Lua, so the
|
||||
// firmware can read the saved theme before a lua_State exists.
|
||||
virtual std::string theme() const = 0;
|
||||
virtual Status setTheme(const std::string& theme) = 0;
|
||||
virtual int32_t color(int32_t r, int32_t g, int32_t b) const = 0;
|
||||
virtual void clear(int32_t color) = 0;
|
||||
virtual void fillRect(int32_t x, int32_t y, int32_t w, int32_t h,
|
||||
|
||||
@@ -25,15 +25,14 @@ constexpr const char* MAIN_PATH = "/.lua/main.lua";
|
||||
// registered.
|
||||
struct Providers {
|
||||
LogProvider* log = nullptr;
|
||||
SettingsProvider* settings = nullptr;
|
||||
SysProvider* sys = nullptr;
|
||||
FsProvider* fs = nullptr;
|
||||
GuiProvider* gui = nullptr;
|
||||
HttpProvider* http = nullptr;
|
||||
TimerProvider* timer = nullptr;
|
||||
WifiProvider* wifi = nullptr;
|
||||
BleProvider* ble = nullptr;
|
||||
|
||||
GuiProvider* gui = nullptr;
|
||||
TouchProvider* touch = nullptr;
|
||||
ButtonsProvider* buttons = nullptr;
|
||||
};
|
||||
@@ -82,7 +81,6 @@ public:
|
||||
bool applyPendingNavigation();
|
||||
|
||||
LogProvider& log() const { return *providers_.log; }
|
||||
SettingsProvider& settings() const { return *providers_.settings; }
|
||||
SysProvider& sys() const { return *providers_.sys; }
|
||||
FsProvider& fs() const { return *providers_.fs; }
|
||||
GuiProvider& gui() const { return *providers_.gui; }
|
||||
|
||||
Reference in New Issue
Block a user