From 01dfc4b4587617b99d71db309b1e0a0bd29c683d Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Sun, 2 Aug 2026 13:20:19 -0400 Subject: [PATCH] refactor: capitalize app directory names The directory name is what the status bar and the launcher cards display, so Home, Hello and Settings read as titles without a lookup table. Updates the firmware's home path, the launcher's self-exclusion and the host tests that load the settings app. Also brings the bar's next repaint forward when an app renames itself or the frame rotates. The bar still decides what changed; this only stops the answer waiting most of a second for the next tick. --- AGENTS.md | 2 +- README.md | 4 ++-- sdcard/apps/{hello => Hello}/main.lua | 0 sdcard/apps/{home => Home}/main.lua | 2 +- sdcard/apps/{settings => Settings}/main.lua | 0 src/lua/bindings/gui.cpp | 1 + src/lua/bindings/settings.cpp | 1 + src/lua/bindings/sys.cpp | 1 + src/lua/lua_app.h | 5 +++++ src/main.cpp | 4 ++-- test/settings_busy.lua | 2 +- test/settings_calibration.lua | 2 +- 12 files changed, 16 insertions(+), 8 deletions(-) rename sdcard/apps/{hello => Hello}/main.lua (100%) rename sdcard/apps/{home => Home}/main.lua (96%) rename sdcard/apps/{settings => Settings}/main.lua (100%) diff --git a/AGENTS.md b/AGENTS.md index 5edd73d..ff2467e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -61,7 +61,7 @@ invalidation flags on the C++ side; the facts that drive the bar are only knowab Full instructions in `.pi/skills/test-e32r40t-firmware/SKILL.md`. Two things that cost time: -- The launcher logs `[lua] home ready`, not "launcher ready". It is `/apps/home`, an app like +- The launcher logs `[lua] home ready`, not "launcher ready". It is `/apps/Home`, an app like any other. - `wait-frame` is an e-ink command and hangs on this board, and `sleep` is not a command at all -- a script using either stops silently. Use `wait-idle SECONDS` between captures and diff --git a/README.md b/README.md index d49219f..34503d3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ docs/ lua-api-parity.md, the crosspoint-reader comparison ``` Copy `sdcard/` to the SD card root: apps live in `/apps//main.lua` and shared -Lua modules in `/lib`. Home is itself an app (`/apps/home/main.lua`); the firmware only +Lua modules in `/lib`. Home is itself an app (`/apps/Home/main.lua`); the firmware only draws a fallback screen if it cannot start. ## Lua API @@ -86,7 +86,7 @@ return { } ``` -Missing file means the built-in defaults are used. `apps/settings` walks two +Missing file means the built-in defaults are used. `apps/Settings` walks two crosshairs and saves the result via `settings.setCalibration()`, cycles `rotation` through 0, 90, 180 and 270 degrees, and scans/selects Wi-Fi networks with an on-screen password keyboard. A saved network reconnects at boot. diff --git a/sdcard/apps/hello/main.lua b/sdcard/apps/Hello/main.lua similarity index 100% rename from sdcard/apps/hello/main.lua rename to sdcard/apps/Hello/main.lua diff --git a/sdcard/apps/home/main.lua b/sdcard/apps/Home/main.lua similarity index 96% rename from sdcard/apps/home/main.lua rename to sdcard/apps/Home/main.lua index d3c47cd..c09dc4b 100644 --- a/sdcard/apps/home/main.lua +++ b/sdcard/apps/Home/main.lua @@ -17,7 +17,7 @@ end function init() local names = {} for _, name in ipairs(fs.listDirs("/apps")) do - if name ~= "home" then names[#names + 1] = name end + if name ~= "Home" then names[#names + 1] = name end end table.sort(names) diff --git a/sdcard/apps/settings/main.lua b/sdcard/apps/Settings/main.lua similarity index 100% rename from sdcard/apps/settings/main.lua rename to sdcard/apps/Settings/main.lua diff --git a/src/lua/bindings/gui.cpp b/src/lua/bindings/gui.cpp index 720cba6..2ccb462 100644 --- a/src/lua/bindings/gui.cpp +++ b/src/lua/bindings/gui.cpp @@ -131,6 +131,7 @@ static int l_gui_setRotation(lua_State* L) { luaL_argcheck(L, degrees % 90 == 0 && degrees >= 0 && degrees <= 270, 1, "0, 90, 180 or 270"); app(L)->tft.setRotation((degrees / 90) & 3); app(L)->applyViewport(); + app(L)->refreshStatusBar(); // every slot in the bar just moved return 0; } diff --git a/src/lua/bindings/settings.cpp b/src/lua/bindings/settings.cpp index f7dbe50..dba930e 100644 --- a/src/lua/bindings/settings.cpp +++ b/src/lua/bindings/settings.cpp @@ -24,6 +24,7 @@ static int l_settings_setRotation(lua_State* L) { } app(L)->tft.setRotation(settings.rotationIndex()); app(L)->applyViewport(); + app(L)->refreshStatusBar(); // every slot in the bar just moved lua_pushboolean(L, settings.save()); return 1; } diff --git a/src/lua/bindings/sys.cpp b/src/lua/bindings/sys.cpp index 7c83d87..0683735 100644 --- a/src/lua/bindings/sys.cpp +++ b/src/lua/bindings/sys.cpp @@ -39,6 +39,7 @@ static int l_sys_setAppName(lua_State* L) { const char* name = luaL_checklstring(L, 1, &length); if (!length || length > MAX_APP_NAME) return luaL_error(L, "app name must be 1 to 32 bytes"); app(L)->setName(String(name, length)); + app(L)->refreshStatusBar(); return 0; } diff --git a/src/lua/lua_app.h b/src/lua/lua_app.h index 1d31781..3ae9515 100644 --- a/src/lua/lua_app.h +++ b/src/lua/lua_app.h @@ -34,6 +34,11 @@ class LuaApp { // leaves the previous viewport metrics behind. void applyViewport(); + // Brings the bar's next repaint forward. Not an invalidation: the bar still decides for + // itself what changed, this only says the answer is worth asking for before the next + // tick, so a rename or a rotation is not left sitting for most of a second. + void refreshStatusBar() { nextBarMs = 0; } + // Set by sys.launch(); the host loop reads both once the app has torn down. void requestLaunch(const char* path, const char* arg); String takePendingLaunch(); diff --git a/src/main.cpp b/src/main.cpp index e2100c8..e5decb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,7 @@ static constexpr int SD_MOSI = 23; static constexpr int SD_MISO = 19; static constexpr int TOUCH_CS = 33; -static const char* HOME = "/apps/home/main.lua"; +static const char* HOME = "/apps/Home/main.lua"; static constexpr uint32_t ERROR_HOLD_MS = 5000; // Arduino's default 8KB loop stack is not enough once a TLS handshake runs inside a @@ -45,7 +45,7 @@ void fallbackScreen(const char* message) { tft.setTextColor(TFT_RED, TFT_WHITE); tft.drawString(message, 10, 10); tft.setTextColor(TFT_BLACK, TFT_WHITE); - tft.drawString("expected /apps/home/main.lua", 10, 30); + tft.drawString("expected /apps/Home/main.lua", 10, 30); Serial.printf("halted: %s\n", message); halted = true; } diff --git a/test/settings_busy.lua b/test/settings_busy.lua index 5d07401..ac2770a 100644 --- a/test/settings_busy.lua +++ b/test/settings_busy.lua @@ -7,7 +7,7 @@ package.path = "sdcard/lib/?.lua;test/?.lua;" .. package.path local device = require("fake_device").install() -dofile("sdcard/apps/settings/main.lua") +dofile("sdcard/apps/Settings/main.lua") local function tapRow(prefix) device.painted = {} diff --git a/test/settings_calibration.lua b/test/settings_calibration.lua index 3ff2e9e..2c9fe38 100644 --- a/test/settings_calibration.lua +++ b/test/settings_calibration.lua @@ -4,7 +4,7 @@ package.path = "sdcard/lib/?.lua;test/?.lua;" .. package.path local device = require("fake_device").install() -dofile("sdcard/apps/settings/main.lua") +dofile("sdcard/apps/Settings/main.lua") local function tap(point) on_touch_down(point.x, point.y)