The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(harness-pro): habitat on the square, and a glyph cache that fits its atlases
0xdiego25c8b6bf0cb263
diff --git a/devices/harness-device/firmware/main/CMakeLists.txt b/devices/harness-device/firmware/main/CMakeLists.txtindex 35854acda..e6543f246 100644--- a/devices/harness-device/firmware/main/CMakeLists.txt+++ b/devices/harness-device/firmware/main/CMakeLists.txt@@ -33,6 +33,7 @@ if(IDF_TARGET STREQUAL "esp32p4")"board/power_pro.c""ui/display.c""ui/panel_pro.c"+ "ui/pro_panel_bus.c""ui/touch.c""ui/touch_gt911.c"# the screens, and the faces they are drawn in — identical files on both boards@@ -149,13 +150,26 @@ endif()list(APPEND BOARD_SRCS "cable_scroll.c" "cable_json_guard.c" "cable_features.c""voice_buffer.c" "audio_probe.c" "ui/ui_perf.c")-# Habitat replaces the round dial's renderer only; the Pro keeps its native panel and UI.+# Habitat replaces the board's LVGL renderer with the text compositor. BOTH boards can build it now:+# the dial at 466 and the Pro at 720. What differs is only what sits under the compositor —+#+# the panel the dial is a CO5300 over QSPI, the Pro an ST7703 over MIPI-DSI. Both are pushed with+# esp_lcd_panel_draw_bitmap, which is why display_habitat.c can branch on bring-up alone+# and share the whole damage/strip loop. The Pro's bring-up is ui/pro_panel_bus.c, the+# same file its LVGL renderer uses, so the two cannot drift apart.+# the touch CST816S/CST9217 against GT911, behind touch_ctrl_open() — an interface that already+# existed for exactly this split (see ui/touch_ctrl.h).+# the face HT_FACE_PX below. The compositor itself has no opinion about resolution.if(DEVICE_HABITAT)- if(NOT IDF_TARGET STREQUAL "esp32s3")- message(FATAL_ERROR "DEVICE_HABITAT requires the 466-pixel ESP32-S3 round dial")+ if(NOT IDF_TARGET STREQUAL "esp32s3" AND NOT IDF_TARGET STREQUAL "esp32p4")+ message(FATAL_ERROR "DEVICE_HABITAT builds for the ESP32-S3 dial or the ESP32-P4 Pro")endif()list(FILTER BOARD_SRCS EXCLUDE REGEX "^ui/")list(REMOVE_ITEM BOARD_SRCS "audio_client.c")+ # The Pro's panel bring-up and its touch driver are under ui/, so the filter above took them.+ if(IDF_TARGET STREQUAL "esp32p4")+ list(APPEND BOARD_SRCS "ui/pro_panel_bus.c" "ui/touch_gt911.c")+ endif()list(APPEND BOARD_SRCS "audio_client_habitat.c" "ui/ui_perf.c""ui/habitat/display_habitat.c""ui/habitat/touch_habitat.c"@@ -187,6 +201,12 @@ idf_component_register(REQUIRES ${BOARD_REQUIRES})+# The face the text compositor is drawing on. See HT_FACE_PX in ui/habitat/terminal.h for why this is a+# build definition rather than a #if on the target.+if(DEVICE_HABITAT AND IDF_TARGET STREQUAL "esp32p4")+ target_compile_definitions(${COMPONENT_LIB} PRIVATE HT_FACE_PX=720)+endif()+# snprintf() is bounded (it truncates, never overflows), but -O2 enables a noisy# format-truncation analysis that errors on safe same-size copies. Keep it as a warning, not error.target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-format-truncation)diff --git a/devices/harness-device/firmware/main/cable_client.c b/devices/harness-device/firmware/main/cable_client.cindex e1acf3774..5fccd6b33 100644--- a/devices/harness-device/firmware/main/cable_client.c+++ b/devices/harness-device/firmware/main/cable_client.c@@ -701,9 +701,13 @@ static void handle_swarms(const cJSON *p)if (selected && strlen(selected) >= ID_MAX) selected = NULL;ui_swarms_replace(rows, n, selected);-#ifndef DEVICE_HABITAT- /* …and the selected tab's shape, which rides the same frame so the two can never be read half- * updated: a grid drawn against the previous tab's rectangles puts agents where they are not. */+/* …and the selected tab's shape, which rides the same frame so the two can never be read half+ * updated: a grid drawn against the previous tab's rectangles puts agents where they are not.+ *+ * THE ROUND DIAL IS THE ONLY BUILD THAT SKIPS THIS. A spatial desk needs corners: habitat on the dial+ * shows its panes as a list of rows and has no use for a rectangle, while habitat on the Pro draws the+ * app's own shape and needs every one of them. */+#if !defined(DEVICE_HABITAT) || defined(CONFIG_IDF_TARGET_ESP32P4)static cable_tile_t tiles[SWARM_TILES_MAX];int tn = 0;const cJSON *ti = NULL;diff --git a/devices/harness-device/firmware/main/ui/habitat/display_habitat.c b/devices/harness-device/firmware/main/ui/habitat/display_habitat.cindex cc552a723..1eeb11b97 100644--- a/devices/harness-device/firmware/main/ui/habitat/display_habitat.c+++ b/devices/harness-device/firmware/main/ui/habitat/display_habitat.c@@ -16,8 +16,15 @@ void cable_transport_benchmark(void);#include "board.h"#include "esp_lcd_panel_io.h"#include "esp_lcd_panel_ops.h"+#if defined(CONFIG_IDF_TARGET_ESP32P4)+// The Pro. Its bring-up is shared with its LVGL renderer (ui/pro_panel_bus.c) rather than copied, so a+// corrected DSI timing or a changed backlight curve cannot apply to one renderer and not the other.+#include "esp_lcd_mipi_dsi.h"+#include "pro_panel_bus.h"+#else#include "esp_lcd_co5300.h"#include "driver/spi_master.h"+#endif#include "esp_heap_caps.h"#include "esp_timer.h"#include "esp_task_wdt.h"@@ -56,6 +63,9 @@ enum { RENDER_MODEL, RENDER_POWER, RENDER_DAMAGE, RENDER_RASTER, RENDER_DMA,RENDER_SUBMIT, RENDER_HEALTH, RENDER_WAIT };static atomic_uint render_stage, render_progress_ms;static esp_timer_handle_t render_guard;+#if !defined(CONFIG_IDF_TARGET_ESP32P4)+// The CO5300's power-on register sequence. The Pro has no equivalent here: the ST7703's own+// init lives inside waveshare/esp_lcd_st7703 and is applied by esp_lcd_panel_init().static const co5300_lcd_init_cmd_t init_cmds[] = {{0xFE, (uint8_t[]){0x20}, 1, 0},{0x19, (uint8_t[]){0x10}, 1, 0},@@ -72,6 +82,7 @@ static const co5300_lcd_init_cmd_t init_cmds[] = {{0x11, NULL, 0, 600},{0x29, NULL, 0, 0},};+#endifstatic uint32_t now_ms(void) { return (uint32_t)(esp_timer_get_time() / 1000); }static uint32_t elapsed_since(const atomic_uint *stamp){@@ -178,17 +189,44 @@ void habitat_perf_get(habitat_perf_t *out)*out = stats;portEXIT_CRITICAL(&stats_lock);}+// THE DMA FENCE, in the two shapes the two panels report it.+//+// Both say the same thing — the pixels draw_bitmap was given have landed, so the buffer the CPU handed+// over is free again — and both give the same semaphore, which is the only thing the strip loop waits+// on. The dial reports it on the panel IO (a QSPI transfer finished); the Pro reports it on the DPI+// panel (a copy into the scanned framebuffer finished).+//+// On the Pro this MUST be on_color_trans_done and not on_refresh_done. The latter fires when the panel+// has finished SCANNING a frame, which is what a buffer-switch scheme waits for; ours copies, so+// waiting on the scan would fence against the wrong event and stall the first strip forever. The same+// distinction is written up at length in ui/panel_pro.c, which learned it the hard way.+static bool fence_release(void)+{+ ui_perf_flush_done();+ BaseType_t wake = pdFALSE;+ xSemaphoreGiveFromISR(dma_done, &wake);+ // Both drivers act on this return to decide whether to yield out of the ISR — the QSPI IO one and+ // the DPI one (esp_lcd_panel_dpi.c). Saying so is the contract; yielding here as well is not.+ return wake == pdTRUE;+}+#if defined(CONFIG_IDF_TARGET_ESP32P4)+static bool color_done(esp_lcd_panel_handle_t p, esp_lcd_dpi_panel_event_data_t *event, void *ctx)+{+ (void)p;+ (void)event;+ (void)ctx;+ return fence_release();+}+#elsestatic bool color_done(esp_lcd_panel_io_handle_t io, esp_lcd_panel_io_event_data_t *event,void *ctx){(void)io;(void)event;(void)ctx;- ui_perf_flush_done();- BaseType_t wake = pdFALSE;- xSemaphoreGiveFromISR(dma_done, &wake);- return wake == pdTRUE;+ return fence_release();}+#endifvoid display_lock_at(const char *who){(void)who;@@ -369,7 +407,13 @@ static void render_task(void *arg)bool on = !display_is_asleep();if (on != panel_on) {render_progress(RENDER_POWER);+#if defined(CONFIG_IDF_TARGET_ESP32P4)+ // Backlit, so "off" is the light. Cutting the DSI stream would need a full re-init to come+ // back from, and the wake has to feel instant.+ pro_backlight_enable(on);+#elseESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel, on));+#endifpanel_on = on;}// A touch/PWR wake can arrive after we sampled `on`, including during@@ -419,6 +463,17 @@ void display_init(void)model_lock = xSemaphoreCreateRecursiveMutex();dma_done = xSemaphoreCreateBinary();assert(model_lock && dma_done);+#if defined(CONFIG_IDF_TARGET_ESP32P4)+ // The whole bring-up is ui/pro_panel_bus.c's, shared with the LVGL renderer. All that is left here+ // is the fence callback, because what it signals is this renderer's business, not the panel's.+ pro_backlight_init();+ ESP_ERROR_CHECK(pro_panel_bus_open(&panel, NULL));+ const esp_lcd_dpi_panel_event_callbacks_t cbs = {.on_color_trans_done = color_done};+ ESP_ERROR_CHECK(esp_lcd_dpi_panel_register_event_callbacks(panel, &cbs, NULL));+ // Full brightness only now. The boost has been enabled since pro_backlight_init() with duty at 0,+ // so nothing was ever shown of an uninitialised framebuffer.+ pro_backlight_set(255);+#elseconst spi_bus_config_t bus =CO5300_PANEL_BUS_QSPI_CONFIG(BSP_LCD_QSPI_SCLK, BSP_LCD_QSPI_D0, BSP_LCD_QSPI_D1,BSP_LCD_QSPI_D2, BSP_LCD_QSPI_D3, HT_WIDTH * STRIP_LINES * 2);@@ -440,6 +495,7 @@ void display_init(void)ESP_ERROR_CHECK(esp_lcd_panel_reset(panel));ESP_ERROR_CHECK(esp_lcd_panel_init(panel));ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel, true));+#endiffor (int i = 0; i < 2; i++) {pixels[i] =heap_caps_malloc(HT_WIDTH * STRIP_LINES * 2, MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);@@ -449,8 +505,12 @@ void display_init(void)assert(xTaskCreatePinnedToCore(render_task, "habitat_render", 6144, NULL, 5, &renderer, 1) ==pdPASS);touch_init();- ESP_LOGI("habitat",- "direct C renderer: two %d-byte internal DMA buffers; 40MHz QSPI; no LVGL heap",- HT_WIDTH * STRIP_LINES * 2);+ ESP_LOGI("habitat", "direct C renderer on a %dpx face: two %d-byte internal DMA buffers over %s",+ HT_WIDTH, HT_WIDTH * STRIP_LINES * 2,+#if defined(CONFIG_IDF_TARGET_ESP32P4)+ "MIPI-DSI");+#else+ "40MHz QSPI");+#endif}void display_init_ota(void) { display_init(); }diff --git a/devices/harness-device/firmware/main/ui/habitat/octopus.c b/devices/harness-device/firmware/main/ui/habitat/octopus.cindex c3639c517..061fb4b9c 100644--- a/devices/harness-device/firmware/main/ui/habitat/octopus.c+++ b/devices/harness-device/firmware/main/ui/habitat/octopus.c@@ -125,7 +125,14 @@ static void expression(char row[55], int y, int eye, const ht_tim_face_t *f)* headline, and the full text stays one tap away in the reader.*/#define RECAP_FONT (&ht_mono_28)+#if HT_FACE_PX >= 720+// 656 / 17 = 38 cells a row, six rows. The dial's cap of 60 exists because four tapering rows inside a+// circle genuinely cannot hold more; neither reason applies here, and a recap that fits is the single+// biggest thing the square face changes about living with this device.+#define RECAP_MAX_CELLS 228+#else#define RECAP_MAX_CELLS 60+#endifstatic void recap_lines(ht_scene_t *s, int y, int width, int rows, bool centered, const int *widths,uint16_t ink, const char *recap){@@ -253,8 +260,18 @@ void ht_octopus_face(ht_scene_t *s, const ht_tim_face_t *f, uint8_t frame, uint1bool result = recap && *recap;bool brief = result && ht_octopus_short_recap(recap);bool compact = f->focus || f->carrying;+#if HT_FACE_PX >= 720+ // Two rungs up the atlas ladder, because the face is 720 and not 466. Live work gets font_16 —+ // 27*16 = 432 px of companion against the dial's 270 — and every other state drops the way the+ // dial's does, just from higher up: a result to font_8, a brief result to font_10, and the+ // carrying state to font_14, which is the rung that leaves room for a detail line.+ const ht_font_t *font = result ? (brief ? &ht_octopus_font_10 : &ht_octopus_font_8)+ : compact ? &ht_octopus_font_14 : &ht_octopus_font_16;+ int y = result ? HT_OCTOPUS_READING_Y : compact ? 140 : 140;+#elseconst ht_font_t *font = result ? (brief ? &ht_octopus_font_6 : &ht_octopus_font_4) : compact ? &ht_octopus_font_8 : &ht_octopus_font_10;int y = result ? (brief ? 78 : 72) : compact ? 113 : 98;+#endifif (result && f->roomy_reading)y = brief ? HT_OCTOPUS_BRIEF_Y : HT_OCTOPUS_READING_Y;ht_octopus_portrait(s, f, frame, ink, font, y);@@ -275,6 +292,19 @@ void ht_octopus_face(ht_scene_t *s, const ht_tim_face_t *f, uint8_t frame, uint1* widths taper to the chord: 372 is the widest the fourth row can be at y=364.*/static const int roomy_widths[] = {408, 408, 396, 372};+#if HT_FACE_PX >= 720+ (void)reading_widths; (void)brief_widths; (void)roomy_widths;+ // SIX ROWS OF 656, and no width table at all. On the dial every row is a different width because+ // each one is a different chord; here they are all the same, so passing NULL is not laziness — it+ // is the shape of the face.+ if (result) recap_lines(s, brief ? HT_OCTOPUS_BRIEF_TEXT_Y : HT_OCTOPUS_READING_TEXT_Y,+ 656, brief ? 3 : 6, false, NULL, f->foreground, recap);+ else lines(s, 542, 656, 1, &ht_mono_20, f->dim, compact ? f->detail : "", false, NULL);+ // Straight, both of them. ht_arc_status bakes a 205 px radius into arc_trig[32][2] and there is no+ // rim here to bend text around, so the status is an ordinary run and the hint is the control row.+ lines(s, 600, 656, 1, RECAP_FONT, f->ink, f->status, false, NULL);+ lines(s, 660, 656, 1, &ht_mono_20, f->dim, f->hint, false, NULL);+#elseif (result && f->roomy_reading) recap_lines(s,brief ? HT_OCTOPUS_BRIEF_TEXT_Y : 212,brief ? 372 : 408, brief ? 3 : 4, false,@@ -285,4 +315,5 @@ void ht_octopus_face(ht_scene_t *s, const ht_tim_face_t *f, uint8_t frame, uint1if (!f->footer_action && !f->straight_title) ht_arc_status(s, f->ink, f->status);else lines(s, f->footer_action ? 369 : 385, 276, 1, &ht_mono_20, f->ink, f->status, false, NULL);lines(s, 417, 210, 1, &ht_mono_20, f->dim, f->hint, false, NULL);+#endif}diff --git a/devices/harness-device/firmware/main/ui/habitat/octopus.h b/devices/harness-device/firmware/main/ui/habitat/octopus.hindex d5ec0a5dc..d6cb8bfb0 100644--- a/devices/harness-device/firmware/main/ui/habitat/octopus.h+++ b/devices/harness-device/firmware/main/ui/habitat/octopus.h@@ -5,9 +5,24 @@ enum { HT_OCTOPUS_FRAMES = 63, HT_OCTOPUS_COLS = 54, HT_OCTOPUS_ROWS = 27,HT_OCTOPUS_DURATION = 5210 };// Shared by the reading compositor and its touch regions. The text ends above// the bottom arc; moving it must never make its target cover the portrait.+#if HT_FACE_PX >= 720+// The Pro, 720 square. Derived in devices/harness-pro/mockup/ui-octopus.html and measured here:+// reading a font_8 portrait is 27*8 = 216 tall, so 126 -> 342, and the recap starts at 366.+// Six rows of mono_28 is 228 px, ending at 594 — just clear of the status band at 600.+// brief a font_10 portrait is 270 tall, 126 -> 396, and three rows from 420 end at 534.+// Nothing tapers: there is no chord to taper to, which is most of what the square buys the recap.+enum { HT_OCTOPUS_BRIEF_Y = 126, HT_OCTOPUS_READING_Y = 126,+ HT_OCTOPUS_BRIEF_TEXT_Y = 420, HT_OCTOPUS_READING_TEXT_Y = 366 };+#elseenum { HT_OCTOPUS_BRIEF_Y = 96, HT_OCTOPUS_READING_Y = 92,HT_OCTOPUS_BRIEF_TEXT_Y = 284, HT_OCTOPUS_READING_TEXT_Y = 224 };+#endifextern const ht_font_t ht_octopus_font_2, ht_octopus_font_4, ht_octopus_font_6, ht_octopus_font_8, ht_octopus_font_10;+#if HT_FACE_PX >= 720+// The Pro's two rungs. 27*16 = 432 px of companion on a 720 face, and 27*14 = 378 for the state that+// has to share the page with a detail line. See the ladder note in scripts/gen_octopus.py.+extern const ht_font_t ht_octopus_font_14, ht_octopus_font_16;+#endif#ifdef DEVICE_LAYOUT_BENCHvoid ht_octopus_fast_scene(bool enabled);#endif@@ -28,7 +43,12 @@ bool ht_octopus_motion_tick(ht_octopus_motion_t *m, uint32_t now, ht_tim_mood_tstatic inline int ht_octopus_title_y(bool result, bool compact){(void)result; (void)compact;+#if HT_FACE_PX >= 720+ // Under the tab row at y=40, which is chrome about which book you are in; the name is the content.+ return 80;+#elsereturn 41;+#endif}// A completed result gets tapered rows and a 108 px portrait (162 px for brief// results). Roomy reading uses six rows; the default preserves benchmark geometry. NULL keepsdiff --git a/devices/harness-device/firmware/main/ui/habitat/octopus_font.c b/devices/harness-device/firmware/main/ui/habitat/octopus_font.cindex 277c7f7f1..061e48b07 100644--- a/devices/harness-device/firmware/main/ui/habitat/octopus_font.c+++ b/devices/harness-device/firmware/main/ui/habitat/octopus_font.c@@ -133,3 +133,239 @@ static const uint8_t octopus_10_pixels[] = {32,36,0,0,0,0,0,0,0,0,0,};const ht_font_t ht_octopus_font_10 = {32,126,5,10,octopus_10_pixels};+#if HT_FACE_PX >= 720+static const uint8_t octopus_14_pixels[] = {+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,3,0,12,0,48,0,192,3,0,12,0,48,0,192,0,0,0,0,48,0,192,0,0,+ 0,0,0,0,0,0,204,3,48,12,192,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,48,48,192,195,3,63,255,48,48,192,195,3,12,12,48,48,192,207,255,204,12,+ 48,48,192,192,0,0,0,0,48,3,240,51,48,204,0,252,0,204,3,48,204,192,252,0,+ 192,0,0,0,0,0,12,48,51,51,3,12,0,192,3,0,48,0,192,12,0,48,3,12,+ 12,204,192,195,0,0,0,0,0,0,240,12,48,48,192,204,12,195,48,204,192,195,3,3,+ 243,0,0,0,0,0,0,0,0,0,0,12,0,192,12,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,12,0,48,3,0,12,0,192,3,0,12,0,48,0,192,+ 3,0,3,0,12,0,12,0,48,192,3,0,3,0,12,0,12,0,48,0,192,3,0,12,+ 0,48,3,0,12,0,192,3,0,0,0,0,0,0,0,0,192,51,48,63,15,255,195,240,+ 51,48,12,0,0,0,0,0,0,0,0,3,0,12,0,48,0,192,3,0,12,15,255,192,+ 192,3,0,12,0,48,0,192,3,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,3,0,48,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,+ 255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,48,0,192,0,0,0,0,0,12,0,48,3,0,12,0,192,+ 3,0,48,0,192,12,0,48,3,0,12,0,192,3,0,0,0,0,0,0,0,3,240,48,+ 48,192,195,51,12,204,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,0,48,+ 3,192,51,0,12,0,48,0,192,3,0,12,0,0,0,0,0,0,0,0,0,0,0,3,+ 240,48,48,0,192,12,0,192,12,0,192,3,255,0,0,0,0,0,0,0,0,0,0,0,+ 3,240,48,48,0,192,60,0,12,0,48,192,192,252,0,0,0,0,0,0,0,0,0,0,+ 0,0,240,12,192,51,3,12,12,48,63,240,3,0,12,0,0,0,0,0,0,0,0,0,+ 0,0,15,252,48,0,192,3,252,0,12,0,48,192,192,252,0,0,0,0,0,0,0,0,+ 0,0,0,3,240,48,48,192,3,252,12,12,48,48,192,192,252,0,0,0,0,0,0,0,+ 0,0,0,0,15,252,0,48,0,192,12,0,192,12,0,192,3,0,0,0,0,0,0,0,+ 0,0,0,0,0,3,240,48,48,192,192,252,12,12,48,48,192,192,252,0,0,0,0,0,+ 0,0,0,0,0,0,3,240,48,48,192,195,3,3,252,0,48,192,192,252,0,0,0,0,+ 0,0,0,0,0,0,0,0,192,3,0,0,0,0,0,0,0,0,0,0,48,0,192,0,+ 0,0,0,0,0,0,0,0,0,192,3,0,0,0,0,0,0,0,0,3,0,48,3,0,+ 0,0,0,0,0,0,0,0,0,0,15,3,192,240,12,0,48,0,60,0,15,0,3,192,+ 0,0,0,0,0,0,0,0,0,0,63,255,0,0,0,0,0,0,0,0,0,0,15,255,+ 192,0,0,0,0,0,0,0,0,0,0,60,0,15,0,3,192,0,192,3,0,240,60,15,+ 0,0,0,0,0,0,0,0,0,63,3,3,12,12,0,48,3,0,48,0,192,0,0,0,+ 0,48,0,192,0,0,0,0,0,0,0,0,0,3,240,48,51,15,204,195,51,12,195,192,+ 192,0,252,0,0,0,0,0,0,0,0,0,0,0,3,240,48,48,192,195,3,15,252,48,+ 48,192,195,3,0,0,0,0,0,0,0,0,0,0,0,15,240,48,48,192,195,252,12,12,+ 48,48,192,195,252,0,0,0,0,0,0,0,0,0,0,0,3,240,48,48,192,3,0,12,+ 0,48,0,192,192,252,0,0,0,0,0,0,0,0,0,0,0,15,240,48,48,192,195,3,+ 12,12,48,48,192,195,252,0,0,0,0,0,0,0,0,0,0,0,15,252,48,0,192,3,+ 252,12,0,48,0,192,3,255,0,0,0,0,0,0,0,0,0,0,0,15,252,48,0,192,+ 3,252,12,0,48,0,192,3,0,0,0,0,0,0,0,0,0,0,0,0,3,240,48,48,+ 192,3,0,12,252,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,12,12,48,+ 48,192,195,255,12,12,48,48,192,195,3,0,0,0,0,0,0,0,0,0,0,0,15,252,+ 3,0,12,0,48,0,192,3,0,12,3,255,0,0,0,0,0,0,0,0,0,0,0,0,+ 12,0,48,0,192,3,0,12,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,+ 12,12,48,192,204,3,192,15,0,51,0,195,3,3,0,0,0,0,0,0,0,0,0,0,+ 0,12,0,48,0,192,3,0,12,0,48,0,192,3,255,0,0,0,0,0,0,0,0,0,+ 0,0,12,12,60,240,204,195,3,12,12,48,48,192,195,3,0,0,0,0,0,0,0,0,+ 0,0,0,12,12,60,48,240,195,51,12,204,48,240,195,195,3,0,0,0,0,0,0,0,+ 0,0,0,0,3,240,48,48,192,195,3,12,12,48,48,192,192,252,0,0,0,0,0,0,+ 0,0,0,0,0,15,240,48,48,192,195,3,15,240,48,0,192,3,0,0,0,0,0,0,+ 0,0,0,0,0,0,3,240,48,48,192,195,3,12,12,51,48,195,0,243,0,0,0,0,+ 0,0,0,0,0,0,0,15,240,48,48,192,195,3,15,240,51,0,195,3,3,0,0,0,+ 0,0,0,0,0,0,0,0,3,240,48,48,192,0,252,0,12,0,48,192,192,252,0,0,+ 0,0,0,0,0,0,0,0,0,15,252,3,0,12,0,48,0,192,3,0,12,0,48,0,+ 0,0,0,0,0,0,0,0,0,0,12,12,48,48,192,195,3,12,12,48,48,192,192,252,+ 0,0,0,0,0,0,0,0,0,0,0,12,12,48,48,192,192,204,3,48,12,192,12,0,+ 48,0,0,0,0,0,0,0,0,0,0,0,12,12,48,48,192,195,3,12,12,51,48,243,+ 195,3,0,0,0,0,0,0,0,0,0,0,0,12,12,48,48,51,0,48,0,192,12,192,+ 192,195,3,0,0,0,0,0,0,0,0,0,0,0,12,12,48,48,51,0,204,0,192,3,+ 0,12,0,48,0,0,0,0,0,0,0,0,0,0,0,15,252,0,48,3,0,48,0,192,+ 12,0,192,3,255,0,0,0,0,0,0,0,0,0,0,0,0,255,3,0,12,0,48,0,+ 192,3,0,12,0,63,192,0,0,0,0,0,192,3,0,3,0,12,0,12,0,48,0,48,+ 0,192,0,192,3,0,3,0,12,0,12,0,48,0,0,0,0,0,63,192,3,0,12,0,+ 48,0,192,3,0,12,15,240,0,0,0,0,0,0,3,0,51,0,204,12,12,48,51,0,+ 60,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,3,255,240,0,0,0,0,192,0,192,0,+ 192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,63,3,3,3,252,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,12,+ 0,48,0,255,3,3,12,12,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,63,3,3,12,0,48,0,192,192,252,0,0,0,0,0,0,0,0,0,0,+ 0,0,12,0,48,63,195,3,12,12,48,48,192,192,252,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,63,3,3,15,252,48,0,192,192,252,0,0,0,0,0,0,0,0,+ 0,0,0,3,240,48,48,192,3,252,12,0,48,0,192,3,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,63,3,3,12,12,48,48,63,192,3,12,12,15,192,0,0,+ 0,0,0,0,0,12,0,48,0,255,3,3,12,12,48,48,192,195,3,0,0,0,0,0,+ 0,0,0,0,0,0,0,192,3,0,0,0,0,0,192,3,0,12,0,48,0,0,0,0,+ 0,0,0,0,0,0,0,0,12,0,48,0,0,0,0,12,0,48,0,192,3,12,12,15,+ 192,0,0,0,0,0,0,0,12,0,48,0,192,195,60,15,0,60,0,207,3,3,0,0,+ 0,0,0,0,0,0,0,0,0,0,192,3,0,12,0,48,0,192,3,0,12,0,48,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,3,51,12,204,51,48,192,195,3,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,3,3,12,12,48,48,192,195,+ 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,3,3,12,12,48,48,192,+ 192,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,3,3,12,12,48,48,+ 192,195,252,12,0,48,0,0,0,0,0,0,0,0,0,0,0,0,63,3,3,12,12,48,+ 48,192,192,255,0,12,0,48,0,0,0,0,0,0,0,0,0,0,0,63,3,3,12,0,+ 48,0,192,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,3,3,3,+ 240,0,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,12,0,48,0,192,3,252,+ 12,0,48,0,192,192,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,195,+ 3,12,12,48,48,192,192,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,+ 195,3,3,48,12,192,12,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 192,195,3,12,204,51,48,204,192,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,192,192,204,0,192,3,0,51,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,192,195,3,12,12,48,48,63,192,3,12,12,15,192,0,0,0,0,0,0,0,0,+ 0,0,0,255,192,12,0,192,3,0,48,3,255,0,0,0,0,0,0,0,0,0,240,12,+ 0,48,0,192,60,3,0,12,0,15,0,3,0,12,0,48,0,60,0,0,3,0,12,0,+ 48,0,192,3,0,12,0,48,0,192,3,0,12,0,48,0,192,3,0,12,0,0,3,192,+ 0,192,3,0,12,0,15,0,3,0,12,3,192,48,0,192,3,0,240,0,0,0,60,3,+ 12,0,48,192,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+};+const ht_font_t ht_octopus_font_14 = {32,126,7,14,octopus_14_pixels};+#endif+#if HT_FACE_PX >= 720+static const uint8_t octopus_16_pixels[] = {+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,+ 0,192,0,0,0,0,0,128,0,192,0,64,0,0,0,0,0,0,0,0,12,192,12,192,+ 12,192,12,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 32,8,48,12,48,12,48,12,255,254,117,92,48,12,48,12,48,12,48,12,48,12,48,12,+ 255,254,117,92,48,12,48,12,0,0,0,0,3,0,15,192,7,64,51,12,51,0,15,192,+ 3,12,3,12,51,12,3,0,15,192,7,64,0,0,0,0,0,3,12,3,51,12,12,12,+ 0,0,0,48,0,32,3,0,3,0,12,0,12,0,48,48,51,12,0,0,192,48,192,0,+ 0,0,0,0,0,0,15,0,48,48,48,48,51,0,204,0,195,12,192,128,192,48,192,48,+ 63,12,21,0,0,0,0,0,0,0,0,0,0,0,0,192,3,0,12,0,4,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,3,0,12,0,12,+ 0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,12,0,12,0,0,0,3,0,3,+ 192,0,192,0,48,0,48,0,12,0,12,0,12,0,12,0,12,0,12,0,12,0,48,0,+ 48,0,0,0,192,0,192,0,0,0,0,0,0,0,0,0,3,0,51,12,15,192,255,254,+ 95,212,15,192,51,12,19,0,0,0,0,0,0,0,0,0,0,128,0,192,0,192,0,192,+ 0,192,0,192,0,192,191,255,21,213,0,192,0,192,0,192,0,192,0,192,0,192,0,192,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,+ 3,0,12,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,+ 85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,192,0,0,0,0,+ 0,3,0,3,0,12,0,12,0,0,0,48,0,32,3,0,3,0,12,0,12,0,48,0,+ 48,0,0,0,192,0,192,0,0,0,0,0,0,0,0,0,15,192,48,12,48,12,48,12,+ 51,12,51,12,48,12,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,192,3,192,13,192,4,192,0,192,0,192,0,192,0,192,0,192,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,15,192,48,28,0,12,0,192,3,0,0,0,24,0,48,0,+ 63,252,21,80,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,28,16,12,3,192,+ 0,12,0,12,0,12,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,3,192,+ 1,192,12,192,12,192,48,192,48,192,63,240,21,208,0,192,0,128,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,63,252,53,80,48,0,63,192,0,12,0,12,0,12,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,11,192,52,12,52,0,63,192,+ 52,12,52,12,52,12,52,12,11,192,1,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 63,252,21,92,0,12,0,192,3,0,12,0,0,0,48,0,48,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,15,192,48,12,48,12,15,192,48,12,48,12,48,12,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,48,12,48,12,+ 15,252,5,92,0,12,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,192,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,192,0,0,0,0,+ 0,0,0,0,0,0,1,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,192,+ 2,0,13,0,4,0,0,0,0,0,0,0,0,0,0,0,0,15,2,192,60,0,20,0,+ 192,0,192,0,60,0,3,192,0,15,0,5,0,0,0,0,0,0,0,0,0,0,0,0,+ 255,255,85,85,0,0,0,0,0,0,0,0,0,0,0,0,255,255,85,85,0,0,0,0,+ 0,0,0,0,0,0,0,0,240,0,15,0,0,60,0,20,0,3,0,3,0,60,11,0,+ 240,0,80,0,0,0,0,0,0,0,15,192,48,12,48,12,0,12,0,12,0,192,3,0,+ 3,0,0,0,0,0,0,0,3,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 15,192,48,60,195,252,193,92,204,12,204,12,195,192,48,0,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,0,0,11,192,52,12,52,12,52,12,63,252,53,92,52,12,52,12,+ 52,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,224,48,12,48,12,63,240,+ 48,12,48,12,48,12,48,12,63,240,21,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 15,192,48,12,48,0,48,0,48,0,48,0,48,0,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,0,0,63,224,48,12,48,12,48,12,48,12,48,12,48,12,48,12,+ 63,240,21,64,0,0,0,0,0,0,0,0,0,0,0,0,63,248,53,80,48,0,63,208,+ 53,64,48,0,48,0,48,0,63,248,21,80,0,0,0,0,0,0,0,0,0,0,0,0,+ 63,248,53,80,48,0,63,208,53,64,48,0,48,0,48,0,32,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,15,192,48,12,48,0,48,0,51,252,49,92,48,12,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,48,12,48,12,48,12,63,252,+ 53,92,48,12,48,12,48,12,48,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 63,252,23,84,3,0,3,0,3,0,3,0,3,0,23,84,63,252,21,84,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,12,0,12,0,12,0,12,0,12,0,12,48,12,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,52,12,52,192,54,0,52,0,+ 61,0,61,0,54,0,52,192,52,12,0,0,0,0,0,0,0,0,0,0,0,0,16,0,+ 48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,63,248,21,80,0,0,0,0,+ 0,0,0,0,0,0,0,0,48,48,56,240,51,112,48,48,48,48,48,48,48,48,48,48,+ 48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,12,60,12,60,12,50,12,+ 50,12,48,92,48,124,48,124,48,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 15,192,48,12,48,12,48,12,48,12,48,12,48,12,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,63,224,53,64,52,12,52,12,52,12,63,240,53,64,52,0,52,0,+ 36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,48,12,48,12,+ 48,12,48,12,51,12,48,192,15,12,5,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 63,224,52,12,52,12,52,12,63,224,59,64,53,0,52,192,52,12,16,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,15,192,48,12,48,0,15,192,0,12,0,12,0,12,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,63,252,23,84,3,0,3,0,+ 3,0,3,0,3,0,3,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 48,12,48,12,48,12,48,12,48,12,48,12,48,12,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,48,12,48,12,48,12,48,12,12,192,12,192,12,192,9,128,3,0,+ 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,48,48,48,48,48,48,48,+ 48,48,51,48,48,48,56,240,48,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 48,12,48,12,12,192,3,0,3,0,12,192,16,32,48,12,48,12,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,48,12,48,12,12,192,12,192,3,0,3,0,3,0,3,0,+ 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,252,21,92,0,212,0,0,+ 3,0,3,0,8,0,48,0,63,252,21,80,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,255,0,213,0,192,0,192,0,192,0,192,0,192,0,192,0,255,0,85,0,0,0,0,+ 192,0,192,0,48,0,48,0,0,0,12,0,8,0,3,0,3,0,0,48,0,48,0,12,+ 0,12,0,0,0,3,0,3,0,0,0,0,0,0,0,0,191,192,21,192,0,192,0,192,+ 0,192,0,192,0,192,0,192,191,192,21,64,0,0,0,0,3,0,12,48,12,48,0,0,+ 48,12,32,8,192,3,192,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,255,255,0,0,0,0,0,0,12,0,3,0,0,192,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,15,192,48,28,15,252,5,92,48,12,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,0,0,52,0,52,0,63,192,52,12,52,12,52,12,52,12,52,12,+ 11,192,1,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,+ 48,0,48,0,48,0,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,12,0,12,15,252,48,12,48,12,48,12,48,12,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,63,252,53,80,48,0,48,12,+ 15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,11,192,48,12,48,0,63,192,+ 53,64,48,0,48,0,48,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,15,192,48,12,48,12,48,12,15,252,5,92,0,12,48,12,15,192,5,64,+ 0,0,0,0,0,0,0,0,48,0,48,0,63,224,48,12,48,12,48,12,48,12,48,12,+ 48,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,192,0,0,0,0,+ 0,192,0,192,0,192,0,192,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,16,+ 0,52,0,36,0,0,0,0,0,12,0,12,0,12,0,12,0,12,48,12,15,192,5,64,+ 0,0,0,0,0,0,0,0,52,0,52,0,52,12,54,192,52,64,61,0,61,0,54,192,+ 52,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,192,0,192,0,192,+ 0,192,0,192,0,192,0,192,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,12,192,51,12,51,12,51,12,51,12,48,12,48,12,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,48,12,48,12,48,12,48,12,+ 48,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,+ 48,12,48,12,48,12,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,11,192,52,12,52,12,52,12,52,12,63,192,53,64,52,0,52,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,48,12,48,12,48,12,15,252,+ 5,92,0,12,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,192,48,12,+ 48,0,48,0,48,0,48,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,15,192,48,12,15,192,5,96,0,12,48,12,15,192,5,64,0,0,0,0,+ 0,0,0,0,0,0,0,0,52,0,52,0,52,0,63,192,53,64,52,0,52,0,52,12,+ 11,192,1,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,12,48,12,+ 48,12,48,12,48,12,48,12,15,192,5,64,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,48,12,48,12,12,192,12,192,0,0,3,0,3,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,48,12,48,12,51,12,51,12,51,12,51,12,+ 12,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,12,12,192,+ 4,0,3,0,3,0,12,192,48,12,16,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,48,12,48,12,48,12,48,12,15,252,5,92,0,12,48,12,15,192,5,64,+ 0,0,0,0,0,0,0,0,0,0,0,0,63,252,21,116,0,80,3,0,6,0,12,0,+ 63,252,21,84,0,0,0,0,0,0,0,15,0,128,0,128,0,128,0,128,15,0,48,0,+ 48,0,15,0,0,128,0,128,0,128,0,128,0,15,0,5,0,192,0,192,0,192,0,192,+ 0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,192,+ 0,0,240,0,90,0,15,0,15,0,15,0,0,240,0,12,0,12,0,240,8,0,8,0,+ 8,0,8,0,240,0,80,0,60,0,20,0,194,0,2,3,0,60,0,20,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+};+const ht_font_t ht_octopus_font_16 = {32,126,8,16,octopus_16_pixels};+#endifdiff --git a/devices/harness-device/firmware/main/ui/habitat/scroll.c b/devices/harness-device/firmware/main/ui/habitat/scroll.cindex 9ec6c9aad..027f30b3e 100644--- a/devices/harness-device/firmware/main/ui/habitat/scroll.c+++ b/devices/harness-device/firmware/main/ui/habitat/scroll.c@@ -1,4 +1,5 @@#include "scroll.h"+#include "terminal.h" // HT_WIDTH / HT_FACE_PX: a rim is a property of the face#include <stdlib.h>#define CLAIM_PX 12@@ -8,9 +9,26 @@bool ht_scroll_on_rim(int x, int y){+#if HT_FACE_PX >= 720+ /*+ * A SQUARE HAS NO RIM, so nothing is ever on it.+ *+ * The annulus below is a 466 circle's: centred on (233,233) with radii 178..233. Left alone on a+ * 720 face it keeps that centre, so the band lands in the top-left quadrant and sweeps straight+ * across the companion — and ui_habitat.c cancels any press that starts on the rim+ * (pressed_action.kind = A_NONE). The symptom is not a wrong scroll. It is taps over a third of+ * the screen doing nothing at all, which is precisely what the first Pro build did.+ *+ * Returning false here also makes bearing() and the rim_radius bookkeeping dead on this board:+ * they are only ever reached through a rim candidate.+ */+ (void)x; (void)y;+ return false;+#elsex -= 233; y -= 233;int r = x * x + y * y;return r >= 178 * 178 && r <= 233 * 233;+#endif}// Monotonic octant approximation: 1024 units per turn, clockwise. No trig/FPU in touch.static int bearing(int x, int y)diff --git a/devices/harness-device/firmware/main/ui/habitat/terminal.c b/devices/harness-device/firmware/main/ui/habitat/terminal.cindex 2c18713db..4cb3211bd 100644--- a/devices/harness-device/firmware/main/ui/habitat/terminal.c+++ b/devices/harness-device/firmware/main/ui/habitat/terminal.c@@ -4,7 +4,23 @@static int imin(int a, int b) { return a < b ? a : b; }static int imax(int a, int b) { return a > b ? a : b; }-static uint16_t be16(uint16_t v) { return (uint16_t)((v << 8) | (v >> 8)); }+/*+ * THE PANEL'S OWN BYTE ORDER, and the two panels disagree about it.+ *+ * The dial's CO5300 is fed over QSPI and wants RGB565 byte-swapped, so the raster emits it that way and+ * saves a per-pixel swap on every flush. The Pro's ST7703 is a DPI panel scanned continuously out of a+ * framebuffer in the SoC's own little-endian order, and it swaps nothing.+ *+ * Getting this wrong is not subtle and it is not a crash: #181818 read the other way round is+ * rgb(192,96,192), so the whole face comes up bright purple with a yellow-green octopus on it. That is+ * exactly what the first Pro build did. The function was called be16() then, which is why this one is+ * not — a name that promises a swap it no longer always performs is worse than no name at all.+ */+#if HT_FACE_PX >= 720+static uint16_t panel16(uint16_t v) { return v; }+#else+static uint16_t panel16(uint16_t v) { return (uint16_t)((v << 8) | (v >> 8)); }+#endifstatic uint32_t punctuation_alias(uint32_t cp){// One cell in, one cell out. Keep the original UTF-8 in the scene/wire;@@ -243,9 +259,24 @@ static ht_rect_t united(ht_rect_t a, ht_rect_t b)}// Layout changes often form a stepped outline: a wide recap underneath a// narrower portrait. Keep that outline instead of inflating it to one large-// rectangle. One pair of byte coordinates per two display rows, on the stack.+// rectangle. One pair of half-pixel x coordinates per two display rows, on the stack.+//+// THE WIDTH OF THESE FOLLOWS THE FACE, and it has to. They hold x/2, so the dial's 466 tops out at 233+// and fits a byte exactly — which is why this was a byte array and why the comment used to say so. At+// 720 the same values reach 360: the right edge of any damage band past x=510 wrapped to a small+// number, damage_rows_finish() emitted a band far narrower than the change, and the right of the+// screen simply never repainted. On the glass that is an octopus drawn on top of the last octopus and+// a menu with the old screen still behind it — not a crash, and nothing in the logs.+//+// The dial keeps its byte array: 360 entries of uint16_t is 1,440 bytes of render-task stack, and the+// 466 face has no need of them.+#if HT_WIDTH / 2 > 255+typedef uint16_t damage_coord_t;+#else+typedef uint8_t damage_coord_t;+#endiftypedef struct {- uint8_t left[HT_HEIGHT / 2], right[HT_HEIGHT / 2];+ damage_coord_t left[HT_HEIGHT / 2], right[HT_HEIGHT / 2];} damage_rows_t;static void damage_add(ht_damage_t *d, ht_rect_t r, damage_rows_t *rows){@@ -255,7 +286,7 @@ static void damage_add(ht_damage_t *d, ht_rect_t r, damage_rows_t *rows)if (r.w <= 0 || r.h <= 0)return;if (rows) for (int y = r.y / 2; y < (r.y + r.h) / 2; y++) {- int left = r.x / 2, right = (r.x + r.w) / 2;+ damage_coord_t left = (damage_coord_t)(r.x / 2), right = (damage_coord_t)((r.x + r.w) / 2);if (left < rows->left[y]) rows->left[y] = left;if (right > rows->right[y]) rows->right[y] = right;}@@ -331,7 +362,9 @@ void ht_damage(const ht_scene_t *a, const ht_scene_t *b, ht_damage_t *d)}if (reshape) {rows = &row_storage;- memset(rows->left, HT_WIDTH / 2, sizeof rows->left);+ // Not memset for `left`: it writes one BYTE, so a 16-bit sentinel of 360 would be seeded as+ // 0x6868. The sentinel is "no damage on this row", recognised by left >= right below.+ for (int y = 0; y < HT_HEIGHT / 2; y++) rows->left[y] = (damage_coord_t)(HT_WIDTH / 2);memset(rows->right, 0, sizeof rows->right);}if (!a || a->background != b->background) {@@ -400,14 +433,38 @@ static uint16_t blend(uint16_t fg, uint16_t bg, unsigned alpha)unsigned r = (((fg >> 11) * alpha + (bg >> 11) * (3 - alpha)) + 1) / 3;unsigned g = ((((fg >> 5) & 63) * alpha + ((bg >> 5) & 63) * (3 - alpha)) + 1) / 3;unsigned b = (((fg & 31) * alpha + (bg & 31) * (3 - alpha)) + 1) / 3;- return be16((r << 11) | (g << 5) | b);+ return panel16((r << 11) | (g << 5) | b);}// The small ASCII artwork uses only a handful of characters. Expand each used// glyph once for its font/palette, then copy clipped rows directly into DMA// strips. Fixed capacity, renderer-owned: no allocation and no per-frame churn.// Ordinary text and Unicode fonts retain the general renderer below.-enum { GLYPH_SLOTS = 24, GLYPH_PIXELS = 50, ASCII_COUNT = 95 };+/*+ * THE CACHE HAS TO BE BIG ENOUGH FOR THE BIGGEST CELL IT IS MEANT TO SERVE.+ *+ * 50 pixels is font_10 exactly — 5 x 10 — which was the largest octopus atlas while there was only a+ * round dial. The Pro draws its companion in font_16 (8 x 16 = 128 px) and its carrying state in+ * font_14 (98), so BOTH were rejected by the size guard below and the cache sat idle over the one+ * surface on that board that redraws sixty-three times a loop.+ *+ * The creature's alphabet is ten symbols and there are twenty-four slots, so every cell of it is a+ * hit once the size fits. The dial keeps 50: it has no atlas that needs more, and 24 x 128 x 2 is+ * 6 KB of internal RAM against its 2.4.+ */+// #define, not enum: the unrolled copy in the rasteriser selects its cases with #if, and the+// preprocessor cannot see an enum constant — it reads the name as 0. That is precisely how the first+// version of the widened cache shipped columns 5..7 unwritten while looking correct in the source.+#if HT_FACE_PX >= 720+#define GLYPH_PIXELS 128+#define GLYPH_MAX_W 8+#define GLYPH_MAX_H 16+#else+#define GLYPH_PIXELS 50+#define GLYPH_MAX_W 5+#define GLYPH_MAX_H 10+#endif+enum { GLYPH_SLOTS = 24, ASCII_COUNT = 95 };typedef struct {uint16_t pixels[GLYPH_SLOTS][GLYPH_PIXELS];uint8_t index[ASCII_COUNT], code[GLYPH_SLOTS], next;@@ -424,7 +481,7 @@ size_t ht_glyph_cache_bytes(void) { return sizeof glyph_cache; }static bool glyph_cache_prepare(const ht_font_t *f, uint16_t fg, uint16_t bg){if (!glyph_cache_enabled || f->first != 32 || f->last != 126 ||- !f->width || f->width > 5 || !f->height || f->height > 10) return false;+ !f->width || f->width > GLYPH_MAX_W || !f->height || f->height > GLYPH_MAX_H) return false;if (glyph_cache.font != f || glyph_cache.fg != fg || glyph_cache.bg != bg) {memset(glyph_cache.index, 0, sizeof glyph_cache.index);memset(glyph_cache.code, 0, sizeof glyph_cache.code);@@ -637,7 +694,7 @@ static void arc_raster(const ht_run_t *r, ht_rect_t clip, uint16_t *out)arc_cache_t *cache = &arc_caches[r->arc == 2];arc_prepare(r, cache);if (!cache->mask_bytes) return;- uint16_t palette[4] = {0, blend(r->fg,r->bg,1), blend(r->fg,r->bg,2), be16(r->fg)};+ uint16_t palette[4] = {0, blend(r->fg,r->bg,1), blend(r->fg,r->bg,2), panel16(r->fg)};int x0 = imax(clip.x,r->x), x1 = imin(clip.x+clip.w,r->x+r->w);int y0 = imax(clip.y,r->y), y1 = imin(clip.y+clip.h,r->y+HT_ARC_HEIGHT);for (int y = y0; y < y1; y++) for (int h = 0; h < 2; h++) {@@ -657,7 +714,7 @@ static void arc_raster(const ht_run_t *r, ht_rect_t clip, uint16_t *out)}void ht_raster(const ht_scene_t *s, ht_rect_t clip, uint16_t *out){- fill(out, (size_t)clip.w * clip.h, be16(s->background));+ fill(out, (size_t)clip.w * clip.h, panel16(s->background));for (int i = 0; i < s->count; i++) {const ht_run_t *r = &s->runs[i];const ht_font_t *f = r->font;@@ -669,9 +726,9 @@ void ht_raster(const ht_scene_t *s, ht_rect_t clip, uint16_t *out)x1 = imax(clip.x, r->x), x2 = imin(clip.x + clip.w, r->x + r->w);if (r->bg != s->background)for (int y = y1; y < y2; y++)- fill(out + (y - clip.y) * clip.w + x1 - clip.x, (size_t)(x2 - x1), be16(r->bg));- uint16_t palette[4] = {be16(r->bg), blend(r->fg, r->bg, 1), blend(r->fg, r->bg, 2),- be16(r->fg)};+ fill(out + (y - clip.y) * clip.w + x1 - clip.x, (size_t)(x2 - x1), panel16(r->bg));+ uint16_t palette[4] = {panel16(r->bg), blend(r->fg, r->bg, 1), blend(r->fg, r->bg, 2),+ panel16(r->fg)};bool cached = glyph_cache_prepare(f, r->fg, r->bg);bool ascii = f->first == 32 && f->last >= 126;#ifdef DEVICE_LAYOUT_BENCH@@ -698,10 +755,20 @@ void ht_raster(const ht_scene_t *s, ht_rect_t clip, uint16_t *out)uint16_t *dst = out + (y - clip.y) * clip.w + xa - clip.x;size_t k = (size_t)(y - r->y) * f->width + xa - gx;if (colored) {- // At most five pixels. A general memcpy call costs more- // than these aligned 16-bit loads/stores on the ESP32.+ // One store per pixel of the widest cached cell, unrolled: a general memcpy+ // costs more than these aligned 16-bit loads/stores on the ESP32.+ //+ // The count has to match GLYPH_MAX_W. It was five — font_10, the dial's widest+ // atlas — and the Pro's font_16 is eight, so columns 5..7 of every cached cell+ // were simply never written. test_glyph_cache caught it the moment the size+ // guard let those atlases in.const uint16_t *src = colored + k;switch (xb - xa) {+#if GLYPH_MAX_W >= 8+ case 8: dst[7] = src[7]; /* fall through */+ case 7: dst[6] = src[6]; /* fall through */+ case 6: dst[5] = src[5]; /* fall through */+#endifcase 5: dst[4] = src[4]; /* fall through */case 4: dst[3] = src[3]; /* fall through */case 3: dst[2] = src[2]; /* fall through */diff --git a/devices/harness-device/firmware/main/ui/habitat/terminal.h b/devices/harness-device/firmware/main/ui/habitat/terminal.hindex f5a3ae2a0..82381fb89 100644--- a/devices/harness-device/firmware/main/ui/habitat/terminal.h+++ b/devices/harness-device/firmware/main/ui/habitat/terminal.h@@ -4,8 +4,17 @@#include <stdbool.h>#include <stddef.h>#include <stdint.h>-#define HT_WIDTH 466-#define HT_HEIGHT 466+// THE FACE, as a build fact rather than a literal.+//+// 466 is the round dial and 720 is the Pro. It arrives as a -D from main/CMakeLists.txt instead of from+// sdkconfig.h on purpose: this header is also compiled by the host-side layout and damage benches, which+// have no IDF config at all, and they want the dial's geometry. So the default lives here and only the+// P4 build overrides it.+#ifndef HT_FACE_PX+#define HT_FACE_PX 466+#endif+#define HT_WIDTH HT_FACE_PX+#define HT_HEIGHT HT_FACE_PX#define HT_RUNS 40#define HT_TEXT_BYTES 128#define HT_DAMAGE_MAX 24@@ -75,7 +84,8 @@ const char *ht_take_line(const char **cursor, int cells);int ht_wrap(ht_scene_t *scene, int x, int y, int width, int lines, int skip, const ht_font_t *font,uint16_t fg, const char *text);void ht_damage(const ht_scene_t *before, const ht_scene_t *after, ht_damage_t *out);-// Output is big-endian RGB565, ready for CO5300 DMA. Buffer holds region.w * region.h pixels.+// Output is RGB565 in THIS BOARD'S panel order — byte-swapped for the dial's CO5300 over QSPI, native+// for the Pro's ST7703 DPI framebuffer. See panel16() in terminal.c. Buffer holds region.w * region.h.void ht_raster(const ht_scene_t *scene, ht_rect_t region, uint16_t *out);uint32_t ht_utf8_next(const char **cursor);// Question/answer text must fit in full and contain glyphs available on this device.diff --git a/devices/harness-device/firmware/main/ui/habitat/tim.c b/devices/harness-device/firmware/main/ui/habitat/tim.cindex 1f94bffc5..baceeb65d 100644--- a/devices/harness-device/firmware/main/ui/habitat/tim.c+++ b/devices/harness-device/firmware/main/ui/habitat/tim.c@@ -33,7 +33,10 @@ bool ht_tim_motion_tick(ht_tim_motion_t *m, uint32_t now, ht_tim_mood_t mood,}}if (down) {- int gaze = (x - 233) / 40;+ // The eyes follow the finger relative to the middle of the FACE, not to 233 — which is+ // the dial's centre and a third of the way across the Pro's, so every touch read as a+ // look to the right.+ int gaze = (x - HT_WIDTH / 2) / 40;p.look = gaze < -2 ? -2 : gaze > 2 ? 2 : gaze;p.pressed = true;m->release_until = now + 400;diff --git a/devices/harness-device/firmware/main/ui/habitat/touch_habitat.c b/devices/harness-device/firmware/main/ui/habitat/touch_habitat.cindex d14ec0f1a..966a80705 100644--- a/devices/harness-device/firmware/main/ui/habitat/touch_habitat.c+++ b/devices/harness-device/firmware/main/ui/habitat/touch_habitat.c@@ -6,8 +6,16 @@#include "board_i2c.h"#include "driver/i2c_master.h"#include "esp_lcd_panel_io.h"+#if defined(CONFIG_IDF_TARGET_ESP32P4)+// The Pro's controller is opened by ui/touch_gt911.c behind touch_ctrl.h — the interface that already+// existed for this exact split, and the same one the LVGL renderer uses. GT911 is polled rather than+// interrupt-driven (int_gpio_num = GPIO_NUM_NC there), which this task was already built for: the IRQ+// below only ever shortened the wait, it was never what produced a sample.+#include "touch_ctrl.h"+#else#include "esp_lcd_touch_cst816s.h"#include "esp_lcd_touch_cst9217.h"+#endif#include "esp_timer.h"#include "esp_log.h"#include "freertos/FreeRTOS.h"@@ -19,6 +27,7 @@ static esp_lcd_panel_io_handle_t io;static TaskHandle_t touch_task_handle;static atomic_uint presses, failures, inferred, last_press;static atomic_bool held, controller_ready;+#if !defined(CONFIG_IDF_TARGET_ESP32P4)static void touch_irq(esp_lcd_touch_handle_t tp){(void)tp;@@ -28,6 +37,19 @@ static void touch_irq(esp_lcd_touch_handle_t tp)if (wake)portYIELD_FROM_ISR();}+#endif+#if defined(CONFIG_IDF_TARGET_ESP32P4)+static bool open_touch(void)+{+ if (!touch_ctrl_open(&io, &controller)) {+ controller = NULL;+ io = NULL;+ return false;+ }+ atomic_store(&controller_ready, true);+ return true;+}+#elsestatic bool open_touch(void){const board_t *b = board();@@ -57,6 +79,7 @@ static bool open_touch(void)atomic_store(&controller_ready, true);return true;}+#endifstatic void task(void *arg){(void)arg;@@ -92,6 +115,7 @@ static void task(void *arg)last_x = x;last_y = y;}+#if !defined(CONFIG_IDF_TARGET_ESP32P4)} else if (rc == ESP_ERR_INVALID_RESPONSE && board()->touch == TOUCH_CST9217) {trusted = false;// This controller also returns stale ACKs while idle. With a previously verified@@ -104,6 +128,7 @@ static void task(void *arg)down = prev && now - last_good < 100000;if (prev && !down)atomic_fetch_add(&inferred, 1);+#endif} else {trusted = false;atomic_fetch_add(&failures, 1);diff --git a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.cindex 2effe2cbf..c33c77ea3 100644--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c@@ -84,6 +84,13 @@ typedef enum {A_NOTICE,A_TABS,A_TAB, A_TAB_REFRESH,+#if HT_FACE_PX >= 720+ // The Pro's tab strip, walked two at a time. Declared only on the square face: the dispatch+ // switch is built with -Werror=switch, so an action that exists but is never handled is a+ // compile error rather than a silent no-op — which is the right trade, and the reason these+ // are inside the guard rather than merely unused on the dial.+ A_TAB_STRIP_LEFT, A_TAB_STRIP_RIGHT,+#endifA_MACHINES,A_MACHINE,A_VOICE,@@ -179,6 +186,23 @@ static EXT_RAM_BSS_ATTR struct {cable_swarm_t tabs[SWARMS_MAX];int tab_count, tab_drag;char selected_tab[ID_MAX];+#if HT_FACE_PX >= 720+ // Set when a tab was chosen from the strip, consumed by ui_land_after_reload(). A one-shot flag+ // rather than changing where every reload lands: the same function catches a boot and a reconnect,+ // and those still belong on the companion face.+ bool land_on_desk;+ // The tab strip's left-most tab. Honoured while you walk the strip, and snapped whenever the tab+ // you are IN would otherwise be off the end of it.+ int tab_first;+ int tab_strip_drag; // accumulated horizontal travel while walking the strip+ bool tab_strip_held; // this contact began on the strip, so it is the strip's to consume+ // The selected tab's SHAPE, as the window laid it out: normalised 0..1000 rectangles plus the agent+ // at each seat. Tagged with the tab they belong to, because a shape drawn against another tab's+ // rectangles puts agents where they are not. The dial has no use for these — see cable_client.c.+ cable_tile_t tiles[SWARM_TILES_MAX];+ int tile_count;+ char tile_tab[ID_MAX];+#endifcable_machine_t machines[CABLE_MAX_MACHINES];int machine_count;char selected_machine[ID_MAX], pending_machine[ID_MAX];@@ -232,6 +256,11 @@ static bool selection_emit(const ht_select_command_t *command, void *ctx);static ht_gesture_t gesture;static ht_octopus_motion_t octopus_motion;static action_t pressed_action;+#if HT_FACE_PX >= 720+// The rectangle the contact went down on. A written control activates when the finger comes up inside+// it, so the rect has to outlive s.pressed, which the release path clears before it decides anything.+static ht_rect_t pressed_rect;+#endifstatic uint32_t ms(void) { return (uint32_t)(esp_timer_get_time() / 1000); }static void copy(char *dst, size_t cap, const char *src){@@ -487,6 +516,15 @@ static uint16_t color(unsigned rgb)* The two ARCS keep mono_20 deliberately: their cell pitch is baked into arc_trig[32][2] on a 205 px* radius and their bounds come from ht_mono_20_ink[], so a different cell there is a different table.*/+// CURVED EDGE TEXT IS THE DIAL'S ONLY. ht_arc_title/ht_arc_status bend text around a 205 px radius+// baked into arc_trig[32][2], and there is no rim on a square to bend it around — at 720 the same table+// would put the name through the middle of the companion. The stored setting is left alone (it is one+// bit of a persisted options word shared by both boards); it simply has no reader on the Pro.+#if defined(CONFIG_IDF_TARGET_ESP32P4)+#define STRAIGHT_TITLE true+#else+#define STRAIGHT_TITLE s.straight_title+#endif#define UI_FONT (&ht_mono_28)static void text(ht_scene_t *f, int x, int y, int w, const char *t, uint16_t c){@@ -508,6 +546,45 @@ static void control(ht_scene_t *f, int x, int y, int w, const char *label, actioht_text(f, x, y, w, UI_FONT, enabled ? (a == A_STOP_YES ? ERROR : n == s.pressed ? ACCENT : FG) : DIM,n == s.pressed ? SEL : BG, label);}+#if HT_FACE_PX >= 720+/*+ * A ONE-PANE TAB HAS NO LAYOUT WORTH SHOWING.+ *+ * The desk exists to say WHERE an agent is among others. With one pane there is no "among": the page+ * is a single rectangle filling the glass and a name in the corner of it, and every visit costs a tap+ * to get past. So a tab with one pane opens on the companion instead.+ *+ * Read off cable_swarm_t.panes rather than counted from the tiles, because this decides where to GO+ * and the rectangles arrive a frame later than the decision does. `panes` counts tiles of any kind —+ * a tab holding one terminal and no agent is still one pane — which is the count this question is+ * actually asking about. A daemon too old to send it reports panes == agents, which lands the same way.+ */+static int pro_panes_of(const char *id)+{+ if (!id || !*id) return 0;+ for (int i = 0; i < s.tab_count; i++)+ if (!strcmp(id, s.tabs[i].id)) return s.tabs[i].panes;+ return 0;+}+/*+ * A LABEL IS NOT A GESTURE.+ *+ * ht_gesture_end() classifies a contact as TAP only between 25 and 350 ms, and as HOLD only between+ * 650 and 1800 — so a press of 400 ms is neither, and returns HT_TOUCH_NONE. On the dial almost every+ * target is the companion itself, where that dead band is invisible. This face is made of written+ * controls, and a deliberate press on a small written label lands in it constantly: the symptom is a+ * button that works perhaps half the time, which reads as a broken screen rather than as a timing rule.+ *+ * These are the controls that say what they do. A press that did not move activates them, full stop.+ * A_PET is deliberately NOT here: its tap and its hold mean two different things, and that is the one+ * place on this face where duration is content.+ */+static bool pro_written_control(action_kind_t a)+{+ return a == A_VOICE_ABORT || a == A_TAB || a == A_TAB_STRIP_LEFT || a == A_TAB_STRIP_RIGHT ||+ a == A_INBOX || a == A_AGENT || a == A_AGENTS || a == A_NOTICE;+}+#endifstatic bool home_footer(action_kind_t action){return action == A_TABS || action == A_INBOX || action == A_RETURN || action == A_CARRY_DROP;@@ -516,7 +593,7 @@ static bool hit_contains(const hit_t *hit, int x, int y, bool surface){ht_rect_t r = hit->rect;if (x >= r.x && x < r.x + r.w && y >= r.y && y < r.y + r.h) return true;- if (!surface || hit->action != A_INBOX || s.straight_title) return false;+ if (!surface || hit->action != A_INBOX || STRAIGHT_TITLE) return false;r = s.inbox_arc;if (x < r.x || x >= r.x + r.w || y < r.y || y >= r.y + r.h) return false;int dx = x - 233, dy = y - 233, radius = dx * dx + dy * dy;@@ -622,6 +699,133 @@ static void command_face(ht_scene_t *f, const char *heading_, const char *subjecs.hits[s.hit_count++] = links[i];}}+#if HT_FACE_PX >= 720+/*+ * THE FIRST LINE IS THE TAB STRIP — every tab, not just the one you are in.+ *+ * The dial names the current tab on the arc above the agent and stops there, because a curved line+ * that wide is all the room it has. A square has a whole 54-cell row, which is enough to carry the+ * switcher itself: the names in sequence, the one you are in filled with SEL, and a tap that goes+ * straight to that tab's panes.+ *+ * TWO RUNS, NOT ONE PER TAB. The strip is drawn once in DIM across the full width, then the selected+ * label is drawn again over it with the selection fill. Six tabs as six runs would cost six of the+ * forty a scene has, and the agent's result page already spends 27 on the companion and 6 on the+ * recap. Two is what the budget can afford, and overdraw is free here — later runs paint over earlier+ * ones by construction.+ *+ * The hit rects are per tab and cost nothing from that budget.+ */+static void pro_tab_strip(ht_scene_t *f)+{+ const int CELLS = 648 / ht_mono_20.width; /* 54 */+ if (s.tab_count <= 0) {+ ht_text(f, 36, 40, 648, &ht_mono_20, DIM, BG, s.loading ? "loading tabs" : "no tabs");+ return;+ }+ int sel = -1;+ for (int i = 0; i < s.tab_count; i++)+ if (!strcmp(s.selected_tab, s.tabs[i].id)) { sel = i; break; }++ /* A tab costs its name plus a space either side — the same space that becomes the selection's+ * padding, so a filled tab never has its first letter against the fill's edge. */+ int span[SWARMS_MAX], cells[SWARMS_MAX];+ for (int i = 0; i < s.tab_count; i++) {+ int n = 0;+ for (const char *q = s.tabs[i].name; *q; ) { ht_utf8_next(&q); n++; }+ cells[i] = n > 14 ? 14 : n; /* one long name must not eat the whole line */+ span[i] = cells[i] + 2;+ }+ if (s.tab_first < 0) s.tab_first = 0;+ if (s.tab_first >= s.tab_count) s.tab_first = s.tab_count - 1;++ /*+ * WALKING THE STRIP. `tab_first` is yours while you use < and >, and the device only overrides it+ * when the tab you are actually in has scrolled off — otherwise the strip would snap back under+ * your finger every time you moved it.+ *+ * The arrows cost two cells each and are only reserved when there is something past that edge, so+ * a strip that fits uses the whole line.+ */+ for (int pass = 0; pass < 2; pass++) {+ int left_arrow = s.tab_first > 0 ? 2 : 0, room = CELLS - left_arrow, used = 0, last = s.tab_first;+ while (last < s.tab_count && used + span[last] <= room) { used += span[last]; last++; }+ if (last < s.tab_count) { /* something past the right edge: reserve > */+ room -= 2;+ while (last > s.tab_first + 1 && used > room) used -= span[--last];+ }+ if (pass || sel < 0 || (sel >= s.tab_first && sel < last)) {+ /* draw */+ char strip[HT_TEXT_BYTES];+ size_t bytes = 0;+ int at = left_arrow, sel_x = -1, sel_cells = 0;+ char sel_text[40] = "";+ if (left_arrow) { strip[bytes++] = '<'; strip[bytes++] = ' '; }+ for (int i = s.tab_first; i < last; i++) {+ char label[40];+ int n = 0; size_t lb = 0;+ label[lb++] = ' ';+ for (const char *q = s.tabs[i].name; *q && n < cells[i]; n++) {+ const char *begin = q;+ ht_utf8_next(&q);+ size_t w = (size_t)(q - begin);+ if (lb + w + 2 >= sizeof label) break;+ memcpy(label + lb, begin, w); lb += w;+ }+ label[lb++] = ' '; label[lb] = 0;+ if (bytes + lb + 3 >= sizeof strip) break;+ memcpy(strip + bytes, label, lb); bytes += lb;+ if (i == sel) { sel_x = at; sel_cells = span[i]; snprintf(sel_text, sizeof sel_text, "%s", label); }+ if (s.hit_count < 24)+ s.hits[s.hit_count++] = (hit_t){{(int16_t)(36 + at * ht_mono_20.width), 26,+ (int16_t)(span[i] * ht_mono_20.width), 56},+ A_TAB, i, s.connected};+ at += span[i];+ }+ bool right_arrow = last < s.tab_count;+ if (right_arrow) {+ while (at < CELLS - 1 && bytes + 2 < sizeof strip) { strip[bytes++] = ' '; at++; }+ if (bytes + 1 < sizeof strip) strip[bytes++] = '>';+ }+ strip[bytes] = 0;+ ht_text(f, 36, 40, 648, &ht_mono_20, DIM, BG, strip);+ if (sel_x >= 0)+ ht_text(f, 36 + sel_x * ht_mono_20.width, 40, sel_cells * ht_mono_20.width,+ &ht_mono_20, ACCENT, SEL, sel_text);+ if (left_arrow && s.hit_count < 24)+ s.hits[s.hit_count++] = (hit_t){{36, 26, 48, 56}, A_TAB_STRIP_LEFT, 0, true};+ if (right_arrow && s.hit_count < 24)+ s.hits[s.hit_count++] = (hit_t){{36 + (CELLS - 2) * ht_mono_20.width, 26, 48, 56},+ A_TAB_STRIP_RIGHT, 0, true};+ return;+ }+ /* The tab we are in is off the strip. Anchor on it and lay the line out again. */+ s.tab_first = sel;+ while (s.tab_first > 0) {+ int back = s.tab_first - 1, total = span[back], k = back + 1;+ while (k <= sel) total += span[k++];+ if (total + 4 > CELLS) break; /* 4 = room for both arrows */+ s.tab_first = back;+ }+ }+}++/*+ * THE UNREAD COUNT IS THE STATUS LINE, and it is the only control this face has.+ *+ * There was a [panes] [say] [inbox] row under it for one build. It was three labels that are three+ * gestures, permanently on screen whether or not any of them had anything to do — and the inbox one+ * lied twice over, since A_INBOX with an empty inbox returns you to the screen you are already on.+ *+ * render_home already writes the count into the status as "[%d] %s", so there is nothing to draw:+ * the affordance is the number that is already there, and this gives it a target.+ */+static void pro_status_is_inbox(void)+{+ if (s.notice_count <= 0 || s.hit_count >= 24) return;+ s.hits[s.hit_count++] = (hit_t){{36, 590, 648, 58}, A_INBOX, 0, true};+}+#endifstatic void render_workspace_preview(ht_scene_t *f){int i=workspace.choice;@@ -650,7 +854,7 @@ static void render_home(ht_scene_t *f)ht_tim_face_t f_ = {.recipient = a ? a->name : "harness", .status = status,.hint = (s.connected && !s.loading) ? "" : "hold for controls",.detail = "", .unread = s.notice_count > 0,- .mood = tim_mood(), .pose = octopus_motion.reaction.pose, .straight_title = s.straight_title,+ .mood = tim_mood(), .pose = octopus_motion.reaction.pose, .straight_title = STRAIGHT_TITLE,.footer_action = carry.active || carry.error[0] || visit.available,.ink = s.notice_count ? ACCENT : FG, .foreground = FG, .dim = DIM,.primary_title = true, .roomy_reading = true};@@ -666,7 +870,27 @@ static void render_home(ht_scene_t *f)f_.hint = "turn rim to scroll";f_.status = "scrolling";}+#if HT_FACE_PX >= 720+ pro_tab_strip(f);+ /*+ * THE CONTROL ROW rides the hint field, which on this face only ever said "hold for controls" —+ * the dial's apology for having nowhere to write the gestures down. See pro_control_row().+ *+ * The tab row says which book you are in. It is mono_20 — 54 cells across 648 px — with the tab's+ * name left and its position right, in one run: the name is what you recognise and the counter is+ * what tells you a swipe has somewhere to go.+ *+ * The control row is the hint field, which on this face was only ever "hold for controls" — the+ * dial's apology for having nowhere to write the gestures down. Here the three that matter get+ * their names, in the habitat's own bracket vocabulary, and hit rects under them. Every gesture+ * still works exactly as it did: this is additive, and it is why the labels are DIM rather than FG.+ */+ f_.hint = "";+#endifht_octopus_face(f, &f_, octopus_motion.frame, ACCENT, recap);+#if HT_FACE_PX >= 720+ pro_status_is_inbox();+#endifif ((carry.active || carry.error[0]) && visit.available) {footer_control(f, 95, 156, "[return]", A_RETURN, s.connected && !visit.pending);footer_control(f, 263, 108, "[drop]", A_CARRY_DROP, true);@@ -689,8 +913,32 @@ static void render_home(ht_scene_t *f)bool result = recap && *recap;// The name stays on the upper arc in both states. Its rising ends stay// outside the companion's central voice target.+#if HT_FACE_PX >= 720+ /*+ * THE TARGETS, RE-SEATED. Every rectangle below used to be a dial coordinate, and on a 720 face+ * that is not a near miss — it is a different part of the screen. The name sits at y 80..118 here+ * while the dial's rect covers 8..100; the companion is {144,140,432,432} while the dial's PET+ * target is {53,100,360,259}. Drawing was re-seated first and these were not, which is exactly+ * what "nothing responds to a tap" looks like from the outside.+ */+ s.hits[s.hit_count++] = (hit_t){{36, 76, 648, 46}, A_AGENTS, 0, true};+ if (result) {+ /* The recap's block, plus a little margin, dismisses it; the portrait above still pets. Both+ * sizes of result portrait are centred, so one rect covers font_8 (216) and font_10 (270). */+ int text_y = (ht_octopus_short_recap(recap) ? HT_OCTOPUS_BRIEF_TEXT_Y+ : HT_OCTOPUS_READING_TEXT_Y) - 6;+ s.hits[s.hit_count++] = (hit_t){{32, (int16_t)text_y, 656, (int16_t)(594 - text_y)},+ A_RECAP_DISMISS, 0, true};+ s.hits[s.hit_count++] = (hit_t){{225, HT_OCTOPUS_READING_Y, 270, 276}, A_PET, 0, true};+ } else {+ /* The font_16 companion exactly: 54*8 x 27*16 at x=(720-432)/2. */+ s.hits[s.hit_count++] = (hit_t){{144, 140, 432, 432}, A_PET, 0, true};+ }+ if (!a) /* "Choose a pane" is on the status line down at 600, not at 359. */+ s.hits[s.hit_count++] = (hit_t){{36, 594, 648, 50}, A_AGENTS, 0, true};+#elses.hits[s.hit_count++] = (hit_t){{53, 8, 360, 92}, A_AGENTS, 0, true};- if (!s.straight_title) {+ if (!STRAIGHT_TITLE) {s.hits[s.hit_count++] = (hit_t){{33, 100, 90, 40}, A_AGENTS, 0, true};s.hits[s.hit_count++] = (hit_t){{343, 100, 90, 40}, A_AGENTS, 0, true};}@@ -701,10 +949,204 @@ static void render_home(ht_scene_t *f)} else s.hits[s.hit_count++] = (hit_t){{53, 100, 360, 259}, A_PET, 0, true};if (!a)s.hits[s.hit_count++] = (hit_t){{65, 359, 336, 30}, A_AGENTS, 0, true};+#endif}+#if HT_FACE_PX >= 720+/*+ * PAGE ONE: the tab's agents, in the window's own layout.+ *+ * The desktop does not send a list, it sends a SHAPE — normalised rectangles from+ * app_state.dart's activeTileShape, one per pane, including the ones this device cannot drive, because+ * "a shell or a viewer holds its place in the grid, and dropping it would leave the shape with a hole+ * in it". So the device is not choosing a layout here. It is being told one, and its only job is to+ * land it on a cell grid without lying about the proportions.+ *+ * 54 x 18 CELLS, and both numbers are chosen for their divisors. Every preset in pane_preset.dart is+ * built from halves, thirds, sixths and ninths; 54 and 18 divide by all four, so a half is exactly a+ * half and a third is exactly a third with no rounding drift anywhere. 54 * 12 x 18 * 28 = 648 x 504,+ * which is 1.286:1 against the window's 1.344:1 — within 4.3%.+ *+ * (The LVGL desk on this same board is 656 x 600 = 1.093:1. Its comment still claims 1.34:1, which was+ * true at the original DESK_GRID_H 488; raising it to 600 for the extra room left every rectangle the+ * window sends 23% too tall. Worth fixing there separately.)+ *+ * A TILE IS THREE RUNS, not a box: a rule of ':' along its top edge, the name a row below it, and the+ * state as a WORD a row below that. Nine tiles is 27 runs, plus the tab row, the status and the control+ * row — 30 of HT_RUNS 40. A fourth line per tile would not fit, and neither would a tenth tile.+ * The ':' is from the octopus's own density ramp; ht_mono_* covers 32..255 and has no box-drawing set+ * at all, so a border made of U+2500 would be an empty cell on the glass.+ */+enum { DESK_COLS = 54, DESK_ROWS = 18, DESK_X = 36, DESK_Y = 100 };+static int desk_col(int v) { return (v * DESK_COLS + 500) / 1000; }+static int desk_row(int v) { return (v * DESK_ROWS + 500) / 1000; }+static int desk_agent(const char *id)+{+ if (!id || !*id) return -1;+ for (int i = 0; i < s.count; i++) if (!strcmp(s.agents[i].id, id)) return i;+ return -1;+}+static void render_desk(ht_scene_t *f)+{+ pro_tab_strip(f);+ // The shape must be the SELECTED tab's. A roster that has moved on while the shape has not is the+ // one case that would draw agents at another tab's seats, so it falls back to saying so.+ bool tagged = !strcmp(s.tile_tab, s.selected_tab);+ /*+ * EVERY NAMED SEAT MUST RESOLVE, or this shape belongs to a roster we do not have yet.+ *+ * The window's shape and the device's roster ride DIFFERENT frames, so after a tab switch the+ * rectangles routinely land a beat before the agents that go in them. Drawing anyway fills the+ * desk with the word "pane" — every seat unnamed — and it stays that way in the eye long after+ * the roster arrives, because that is what the person saw. The LVGL desk on this board hit+ * exactly this and answered it the same way (desk_tiles_usable in ui_screens.c).+ *+ * A seat with an empty agentId is a shell or a viewer and is legitimately unnamed; only the named+ * ones have to be found.+ */+ int named = 0, resolved = 0;+ for (int i = 0; i < s.tile_count; i++) {+ if (!s.tiles[i].agent_id[0]) continue;+ named++;+ if (desk_agent(s.tiles[i].agent_id) >= 0) resolved++;+ }+ /*+ * ONE SEAT THAT NEVER RESOLVES MUST NOT HOLD THE WHOLE DESK.+ *+ * Requiring every named seat was right for the transient case and wrong for the steady one: a+ * window can hold a pane this device's roster does not carry — an agent on another machine, or one+ * the roster filters — and then "3 of 4 named" is the permanent truth, not a beat of lag. Waiting+ * on it showed a sentence instead of a desk, forever.+ *+ * So the bar is that SOMETHING resolves. Nothing resolving is the roster being a frame behind, and+ * that is the case worth waiting out; the odd unresolvable seat is drawn as what it is.+ */+ bool ready = named == 0 || resolved > 0;+ bool shaped = s.tile_count > 0 && tagged && ready;+ if (!shaped) {+ // Three different failures used to read as one sentence, which is no use to anyone standing in+ // front of the device: nothing to lay out, a shape that belongs to another tab, or a window+ // that has not described this one yet.+ ht_center(f, 330, UI_FONT, FG,+ s.loading ? "Loading..."+ : !s.count ? "No panes in this tab."+ : !s.tile_count ? "No layout from the app yet."+ : !tagged ? "Layout is for another tab."+ : "Matching panes to agents...");+ if (!ready && tagged && s.tile_count) {+ // The counts, so a shape that never resolves can be told from one that is merely early.+ char why[64];+ snprintf(why, sizeof why, "%d of %d named %s roster %d", resolved, named, "\xc2\xb7", s.count);+ ht_center(f, 386, &ht_mono_20, DIM, why);+ }+ pro_status_is_inbox();+ return;+ }+ /*+ * THE SEPARATORS ARE ONE RUN PER GRID ROW, not one per tile edge.+ *+ * A run is a single line of text, so a VERTICAL line costs one run per row it crosses — eighteen+ * of them for a full-height boundary, and a 3 x 3 desk has two such boundaries. That is the whole+ * scene budget spent on lines. Drawing the grid into a character buffer first and emitting one run+ * per row inverts the cost: every vertical boundary at that row shares the run, so the lines cost+ * 18 runs no matter how many columns the window is using.+ *+ * Budget, against HT_RUNS 40: 18 line rows + 2 per tile + the tab strip's 2 + the status. Nine+ * tiles is 39. That is the ceiling, and it is why a tile gets two text rows and not three.+ */+ char grid[DESK_ROWS][DESK_COLS + 1];+ memset(grid, ' ', sizeof grid);+ int working = 0, idle = 0;+ struct { int16_t x, y, w; int ai; bool pane; const char *state; } seat[SWARM_TILES_MAX];+ int seats = 0;++ for (int i = 0; i < s.tile_count; i++) {+ const cable_tile_t *t = &s.tiles[i];+ int c0 = desk_col(t->x1), c1 = desk_col(t->x2);+ int r0 = desk_row(t->y1), r1 = desk_row(t->y2);+ if (c1 <= c0 || r1 <= r0) continue; // a rectangle thinner than one cell+ if (c1 > DESK_COLS) c1 = DESK_COLS;+ if (r1 > DESK_ROWS) r1 = DESK_ROWS;+ // The tile's top edge, across its own width.+ for (int c = c0; c < c1; c++) grid[r0][c] = ':';+ /*+ * The left edge, full height, TWO COLUMNS of the same ':' — one column reads as a hairline+ * between two panes that are themselves full of text, which is not enough separation at a+ * glance. Doubling the column rather than changing the character keeps the dotted texture the+ * rest of the face is drawn in; '|' or '=' made it a different object entirely.+ *+ * Only where it is an INTERIOR boundary. The canvas has no outer border: the face's own margin+ * is the border, and a box drawn around the whole grid would read as a window inside a window.+ *+ * The second column costs one cell of the tile's width, which is why the labels below start+ * two cells in.+ */+ if (c0 > 0)+ for (int r = r0; r < r1; r++) {+ grid[r][c0] = ':';+ if (c0 + 1 < DESK_COLS) grid[r][c0 + 1] = ':';+ }++ int ai = desk_agent(t->agent_id);+ agent_t *a = ai >= 0 ? &s.agents[ai] : NULL;+ if (a && a->busy) working++; else if (a) idle++;+ if (seats < SWARM_TILES_MAX)+ seat[seats++] = (typeof(seat[0])){+ (int16_t)(DESK_X + c0 * ht_mono_20.width), (int16_t)(DESK_Y + r0 * ht_mono_20.height),+ (int16_t)((c1 - c0) * ht_mono_20.width), ai, !t->agent_id[0],+ !t->agent_id[0] ? "pane" : !a ? "unknown"+ : a->busy ? "working" : a->recap_ready ? "done" : "idle"};+ if (s.hit_count < 24)+ s.hits[s.hit_count++] = (hit_t){{(int16_t)(DESK_X + c0 * ht_mono_20.width),+ (int16_t)(DESK_Y + r0 * ht_mono_20.height),+ (int16_t)((c1 - c0) * ht_mono_20.width),+ (int16_t)((r1 - r0) * ht_mono_20.height)},+ A_AGENT, ai, ai >= 0 && s.connected};+ }++ for (int r = 0; r < DESK_ROWS; r++) {+ grid[r][DESK_COLS] = 0;+ if (!memchr(grid[r], ':', DESK_COLS)) continue; // a row with no line on it costs no run+ ht_ascii_text(f, DESK_X, DESK_Y + r * ht_mono_20.height, DESK_COLS * ht_mono_20.width,+ &ht_mono_20, DIM, BG, grid[r], DESK_COLS);+ }++ // The labels go on top of the lines, inset by one cell on each side so a name can never paint out+ // the boundary of the tile beside it.+ for (int i = 0; i < seats; i++) {+ int ai = seat[i].ai;+ bool focused = ai >= 0 && ai == s.active;+ // Two cells in from the doubled rule, and one clear of the next tile's, so a name can never+ // paint out either column of a boundary.+ int w = seat[i].w - 3 * ht_mono_20.width;+ if (w < ht_mono_20.width) continue;+ char label[HT_TEXT_BYTES];+ // Three states, three words: a seat with no agent at all is a shell or a viewer ("pane"); a+ // seat naming an agent this device does not carry is "agent"; the rest have their own name.+ snprintf(label, sizeof label, "%s", seat[i].pane ? "pane" : ai < 0 ? "agent" : s.agents[ai].name);+ ht_text(f, seat[i].x + 2 * ht_mono_20.width, seat[i].y + ht_mono_20.height, w, &ht_mono_20,+ !s.connected ? DIM : focused ? ACCENT : seat[i].pane ? DIM : FG, BG, label);+ ht_text(f, seat[i].x + 2 * ht_mono_20.width, seat[i].y + 2 * ht_mono_20.height, w, &ht_mono_20,+ DIM, BG, seat[i].state);+ }+ /* The unread count leads here too, in the same brackets and the same place as on the agent face,+ * so one habit reaches the inbox from either page. */+ char tally[64];+ if (s.notice_count > 0)+ snprintf(tally, sizeof tally, "[%d] %d working %s %d idle", s.notice_count, working, "\xc2\xb7", idle);+ else+ snprintf(tally, sizeof tally, "%d working %s %d idle", working, "\xc2\xb7", idle);+ ht_center(f, 600, UI_FONT, s.notice_count > 0 ? ACCENT : DIM, tally);+ pro_status_is_inbox();+}+#endifstatic void render_agents(ht_scene_t *f){+#if HT_FACE_PX >= 720+ // On a square the pane list IS the desk: the window's shape, not a column of rows.+ render_desk(f);+ return;+#endifheading(f, "panes");int last = s.count > TAB_ROWS ? s.count - TAB_ROWS : 0;if (s.offset > last) s.offset = last;@@ -961,7 +1403,7 @@ static void render_voice(ht_scene_t *f)else snprintf(status, sizeof(status), "Listening %lu:%02lu", (unsigned long)(s.voice_second / 60),(unsigned long)(s.voice_second % 60));ht_tim_face_t f_ = {.recipient = s.voice_target, .status = status,- .hint = "", .footer_action = true, .straight_title = s.straight_title,+ .hint = "", .footer_action = true, .straight_title = STRAIGHT_TITLE,.mood = !s.voice_start_pending && !s.voice_waiting && audio_client_recording() ? HT_TIM_LISTENING : HT_TIM_WORKING,.pose = octopus_motion.reaction.pose, .ink = FG, .foreground = FG, .dim = DIM, .primary_title = true,.detail = s.voice_search ? "Say a phrase from the output" : s.voice_return == DRAFT ? draft_detail :@@ -970,7 +1412,11 @@ static void render_voice(ht_scene_t *f).carrying = s.voice_carry};f_.focus = f_.detail && *f_.detail;ht_octopus_face(f, &f_, octopus_motion.frame, ACCENT, NULL);+#if HT_FACE_PX >= 720+ s.hits[s.hit_count++] = (hit_t){{144, 140, 432, 432}, A_PET, 0, true};+#elses.hits[s.hit_count++] = (hit_t){{33, 97, 400, 274}, A_PET, 0, true};+#endif/** "[discard]", 153 px, at y=400 — every number moved for a reason.*@@ -980,7 +1426,20 @@ static void render_voice(ht_scene_t *f)* across, so the glyph bottoms met the rim. 400..438 sits inside a 220 px chord, and the status* line above ends at 397.*/+#if HT_FACE_PX >= 720+ /*+ * NO [discard] ON THIS FACE.+ *+ * It was the one written control on the voice screen and it is gone at the owner's call. The+ * portrait still ends a recording with a tap, and A_VOICE_ABORT is still reached from the power+ * button and from the paths that tear a capture down — so aborting is not lost, only its label is.+ *+ * The dial keeps its own [discard] below: there the portrait is the only other target on the+ * glass, and dropping the label would leave the abort with nowhere to live.+ */+#elsecontrol(f, 156, 400, 153, "[discard]", A_VOICE_ABORT, 0, true);+#endif}static void render_selection(ht_scene_t *f){@@ -1564,18 +2023,49 @@ static void dispatch(action_t a)s.offset=first<0 ? 0 : first>last ? last : first;break;}+#if HT_FACE_PX >= 720+ case A_TAB_STRIP_LEFT:+ case A_TAB_STRIP_RIGHT:+ // Two at a time: one felt like nothing had happened on a strip this wide. The strip, and the+ // tab_first it walks, exist only on the square face — the dial has no room for the row.+ s.tab_first += a.kind == A_TAB_STRIP_LEFT ? -2 : 2;+ if (s.tab_first < 0) s.tab_first = 0;+ if (s.tab_first >= s.tab_count) s.tab_first = s.tab_count ? s.tab_count - 1 : 0;+ change();+ break;+#endifcase A_MACHINES:view(MACHINES);break;case A_TAB:if (!s.connected || s.voice_open || s.loading || workspace_index(a.id)<0) break;+#if HT_FACE_PX >= 720+ // Choosing a tab asks to see ITS PANES — unless there is only one, in which case the pane IS+ // the tab and the companion is the answer. On the dial a tab always lands on the companion,+ // because that is the only face there is.+ if (!strcmp(a.id,s.selected_tab)) { view(pro_panes_of(a.id) > 1 ? AGENTS : HOME); break; }+ s.land_on_desk = pro_panes_of(a.id) > 1;+#elseif (!strcmp(a.id,s.selected_tab)) { view(HOME); break; }+#endifif (ht_workspace_request(&workspace,a.id,ms())) {a.revision=workspace.serial;if (!queue(a)) { workspace_failed("Device busy. Choose the tab again."); break; }ht_visit_close(&visit); s.pending_focus[0]=0;+#if HT_FACE_PX >= 720+ /*+ * NO INTERSTITIAL. Going to MESSAGE for the wait meant leaving the companion face for a+ * near-empty screen and coming back — two whole-face repaints for something that takes+ * well under a second, which reads as the screen flashing rather than as progress.+ *+ * The panes page is where the switch is going anyway, and it already has a quiet+ * "Loading..." for exactly this. So it goes there now and stays there.+ */+ view(AGENTS); s.loading=true;+#elseCOPY(s.title,"Switching tab"); COPY(s.message,"Opening your workspace...");view(MESSAGE); s.loading=true;+#endif}break;case A_MACHINE:@@ -2062,6 +2552,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)if (h.enabled && hit_contains(&h, x, y, surface)) {s.pressed = i;pressed_action = make_action(h);+#if HT_FACE_PX >= 720+ pressed_rect = h.rect;+#endifbreak;}}@@ -2069,6 +2562,11 @@ void habitat_touch(bool down, int x, int y, uint32_t now)if (surface && !home_footer(pressed_action.kind) && s.rim_enabled && ht_scroll_on_rim(x, y)) pressed_action.kind = A_NONE;if (surface && pressed_action.kind==A_TABS && !s.touch_brake)ht_workspace_touch(&workspace,workspace_index(s.selected_tab),s.tab_count,x,y,now);+#if HT_FACE_PX >= 720+ // The strip's band is the first row of the face — 26..82 plus a thumb's margin.+ s.tab_strip_held = (s.view == HOME || s.view == AGENT || s.view == AGENTS) && y < 96;+ s.tab_strip_drag = 0;+#endifht_gesture_begin(&gesture, x, y, now, ((uint32_t)s.view << 8) | pressed_action.kind);if (pressed_action.kind != A_PET && pressed_action.kind != A_FORM_MAIN && pressed_action.kind != A_FORM_SAY &&pressed_action.kind != A_ANSWER && pressed_action.kind != A_DRAFT_SEND && pressed_action.kind != A_DRAFT_EDIT &&@@ -2100,6 +2598,27 @@ void habitat_touch(bool down, int x, int y, uint32_t now)int travel = (s.last_y - y) * (scroll_reversed ? -1 : 1);ht_selection_move(&selection, travel, now);change();+#if HT_FACE_PX >= 720+ } else if (s.tab_strip_held && gesture.axis == 2) {+ /*+ * WALKING THE STRIP BY DRAGGING IT, which is what the LVGL tab strip on this board did and+ * what a row of names on a touchscreen should do. The arrows stay for precision; this is+ * for getting somewhere.+ *+ * 90 px a tab, not one tab per pixel of travel: the strip is 648 px wide and a tab is about+ * 150 of it, so a drag that moves the line by roughly half a tab advances one. Accumulated+ * rather than derived from the total, so a slow drag and a fast one cover the same ground.+ */+ s.tab_strip_drag += s.last_x - x;+ while (s.tab_strip_drag >= 90 && s.tab_first < s.tab_count - 1) {+ s.tab_strip_drag -= 90; s.tab_first++; change();+ }+ while (s.tab_strip_drag <= -90 && s.tab_first > 0) {+ s.tab_strip_drag += 90; s.tab_first--; change();+ }+ if (s.tab_first <= 0 && s.tab_strip_drag < -90) s.tab_strip_drag = -90;+ if (s.tab_first >= s.tab_count - 1 && s.tab_strip_drag > 90) s.tab_strip_drag = 90;+#endif} else ht_scroll_move(&scroll, x, y, now);if (gesture.moved && s.pressed >= 0) {s.pressed = -1;@@ -2118,10 +2637,39 @@ void habitat_touch(bool down, int x, int y, uint32_t now)}int dx = x - s.start_x, dy = y - s.start_y;s.pressed = -1;+#if HT_FACE_PX >= 720+ if (s.tab_strip_held && gesture.moved && gesture.axis == 2) {+ // The strip consumed this contact while it was moving; its end is not a choice.+ } else if (pro_written_control(pressed_action.kind) &&+ x >= pressed_rect.x && x < pressed_rect.x + pressed_rect.w &&+ y >= pressed_rect.y && y < pressed_rect.y + pressed_rect.h) {+ /*+ * A BUTTON, JUDGED BY WHERE THE FINGER CAME UP — not by how far it wandered, and not by+ * how long it stayed.+ *+ * Both earlier attempts at this failed on the same measurement. ht_gesture_move() calls a+ * contact "moved" at 12 px, which on this panel is 1.20 mm; a deliberate press with a+ * fingertip drifts two to four. So `!gesture.moved` was false most of the time, and the+ * scroll layer — same 12 px claim — had already taken the contact anyway, which is why the+ * branch also had to come up here, above `scrolled || s.touch_cancelled`.+ *+ * The rule every touch button uses is the right one: down on the control, up on the+ * control, activate. Drift inside it is a press. Drift out of it is a cancel, which is+ * what the bounds test below gives for free.+ *+ * The strip's drag is checked first, so dragging the tab row still scrolls it rather than+ * choosing whichever tab the finger happened to leave.+ */+ ht_gesture_cancel(&gesture);+ dispatch(pressed_action);+ } else if (scrolled || s.touch_cancelled) {+#elseif (scrolled || s.touch_cancelled) {+#endif// Motion owns this entire contact, even if the finger returns to its starting point.} else if (result == HT_TOUCH_TAP && s.touch_brake) {// DOWN already stopped desktop inertia. This entire tap is only a brake.+} else if (surface && pressed_action.kind==A_TABS) {bool cancelled=workspace.cancelled || (workspace.touching && now-workspace.began>=5000);int chosen=ht_workspace_release(&workspace,x,y,gesture.axis,now);@@ -2214,6 +2762,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)}change();}+#if HT_FACE_PX >= 720+ if (!down) { s.tab_strip_held = false; s.tab_strip_drag = 0; }+#endifs.touch_down = down;s.last_x = x;s.last_y = y;@@ -2819,7 +3370,14 @@ void ui_land_after_reload(void)if (s.loading && (workspace.phase==HT_WORKSPACE_IDLE || workspace.phase==HT_WORKSPACE_READY)) {ht_workspace_cancel_request(&workspace);s.loading = false;+#if HT_FACE_PX >= 720+ // Re-checked here as well as at the tap: the swarm row can arrive with a truer pane count+ // between asking for a tab and landing in it, and this is the last moment the answer matters.+ view(s.land_on_desk && pro_panes_of(s.selected_tab) > 1 ? AGENTS : HOME);+ s.land_on_desk = false;+#elseview(HOME);+#endif}change();display_unlock();@@ -3169,6 +3727,37 @@ void ui_swarms_replace(const cable_swarm_t *rows, int count, const char *selecte}change(); display_unlock();}+#if HT_FACE_PX >= 720+void ui_tiles_replace(const cable_tile_t *rows, int count, const char *tab)+{+ display_lock();+ int bounded = count < 0 ? 0 : count > SWARM_TILES_MAX ? SWARM_TILES_MAX : count;+ if (!rows) bounded = 0;+ bool changed = bounded != s.tile_count || strcmp(s.tile_tab, tab ? tab : "");+ for (int i = 0; !changed && i < bounded; i++)+ changed = memcmp(&rows[i], &s.tiles[i], sizeof *rows) != 0;+ s.tile_count = bounded;+ if (bounded) memcpy(s.tiles, rows, (size_t)bounded * sizeof *rows);+ COPY(s.tile_tab, tab);+ // Only repaint when the shape actually moved. The window sends this frame on every roster change,+ // and a desk that redraws on an unchanged shape is 27 runs of damage for nothing.+ if (changed) change();+ if (changed) {+ int named = 0, resolved = 0;+ for (int i = 0; i < bounded; i++) {+ if (!s.tiles[i].agent_id[0]) continue;+ named++;+ for (int k = 0; k < s.count; k++)+ if (!strcmp(s.agents[k].id, s.tiles[i].agent_id)) { resolved++; break; }+ }+ ESP_LOGI("habitat", "tiles: %d for '%s' (sel '%s') · named %d resolved %d of roster %d · "+ "first tile a='%s' roster0='%s'", bounded, tab ? tab : "", s.selected_tab,+ named, resolved, s.count,+ bounded ? s.tiles[0].agent_id : "", s.count ? s.agents[0].id : "");+ }+ display_unlock();+}+#endifvoid ui_show_machines(void){display_lock();diff --git a/devices/harness-device/firmware/main/ui/panel_pro.c b/devices/harness-device/firmware/main/ui/panel_pro.cindex dc044e5a8..98089ac7c 100644--- a/devices/harness-device/firmware/main/ui/panel_pro.c+++ b/devices/harness-device/firmware/main/ui/panel_pro.c@@ -17,80 +17,23 @@#include "board_pins.h"#include "display.h"+#include "pro_panel_bus.h"-#include "driver/gpio.h"-#include "driver/ledc.h"#include "esp_check.h"#include "esp_lcd_mipi_dsi.h"#include "esp_lcd_panel_ops.h"#include "esp_lcd_panel_vendor.h"-#include "esp_lcd_st7703.h"-#include "esp_ldo_regulator.h"#include "esp_heap_caps.h"#include "esp_log.h"static const char *TAG = "panel_pro";-#define BL_TIMER LEDC_TIMER_0-#define BL_CHANNEL LEDC_CHANNEL_0-#define BL_MAX_DUTY ((1 << BSP_LCD_BL_RES_BITS) - 1)+static esp_lcd_panel_handle_t s_panel;+static lv_display_t *s_disp;-static esp_lcd_panel_handle_t s_panel;-static esp_lcd_panel_io_handle_t s_io;-static esp_lcd_dsi_bus_handle_t s_bus;-static esp_ldo_channel_handle_t s_phy_pwr;-static lv_display_t *s_disp;--/*- * Backlight. An AP3032 boost drives the LED string and its feedback pin is what this PWM moves, so the- * duty is INVERTED — more duty is dimmer. The invert is done by the LEDC peripheral rather than by- * arithmetic here, so the number in the register reads the same way the number in the code does.- *- * This is real dimming. The dial has no brightness control in hardware and fakes it with a translucent- * overlay over the whole UI (ui_screens.c), which costs a composited layer on every frame; this board- * does not need that, and at M2 the overlay should be switched off for it rather than stacked on top.- */-static void backlight_init(void)-{- const gpio_config_t en = {- .pin_bit_mask = 1ULL << BSP_LCD_BL_EN,- /* INPUT_OUTPUT, not OUTPUT: a plain output pin reads back 0 whatever it is driving, which made- * the diagnostic line below report BL_EN=0 on a backlight that was on. */- .mode = GPIO_MODE_INPUT_OUTPUT,- .pull_up_en = GPIO_PULLUP_DISABLE,- .pull_down_en = GPIO_PULLDOWN_DISABLE,- .intr_type = GPIO_INTR_DISABLE,- };- gpio_config(&en);- gpio_set_level(BSP_LCD_BL_EN, 1);-- const ledc_timer_config_t timer = {- .speed_mode = LEDC_LOW_SPEED_MODE,- .duty_resolution = BSP_LCD_BL_RES_BITS,- .timer_num = BL_TIMER,- .freq_hz = BSP_LCD_BL_FREQ_HZ,- .clk_cfg = LEDC_AUTO_CLK,- };- ledc_timer_config(&timer);-- const ledc_channel_config_t ch = {- .gpio_num = BSP_LCD_BL_PWM,- .speed_mode = LEDC_LOW_SPEED_MODE,- .channel = BL_CHANNEL,- .timer_sel = BL_TIMER,- .duty = 0,- .hpoint = 0,- .flags.output_invert = true,- };- ledc_channel_config(&ch);-}--/* 0..255 to match the dial's DCS register range, so one UI setting drives both boards. */-void panel_set_brightness(uint8_t level)-{- ledc_set_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL, (uint32_t)BL_MAX_DUTY * level / 255u);- ledc_update_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL);-}+/* Brightness and the idle blank both live in pro_panel_bus.c now, because the habitat renderer needs+ * them and has no panel.h. These three are the panel.h names the rest of the firmware calls. */+void panel_set_brightness(uint8_t level) { pro_backlight_set(level); }/* The idle blank. This panel is backlit, so "off" is the backlight rather than the pixels — cutting the* DSI stream instead would take a full re-init to come back from, and the dial's wake is instant. */@@ -98,12 +41,12 @@ static uint8_t s_level_before_blank = 255;void panel_power(bool on){if (!on) {- s_level_before_blank = (uint8_t)(ledc_get_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL) * 255u / BL_MAX_DUTY);- panel_set_brightness(0);- gpio_set_level(BSP_LCD_BL_EN, 0);+ s_level_before_blank = pro_backlight_level();+ pro_backlight_set(0);+ pro_backlight_enable(false);} else {- gpio_set_level(BSP_LCD_BL_EN, 1);- panel_set_brightness(s_level_before_blank);+ pro_backlight_enable(true);+ pro_backlight_set(s_level_before_blank);}}@@ -123,15 +66,6 @@ static esp_err_t pro_panel_self_test(bool on)return err;}-/* Read back what the backlight is actually being driven with, so a brightness bug and a video bug can- * be told apart from the log instead of by eye. */-static void pro_panel_backlight_debug(void)-{- ESP_LOGI(TAG, "backlight · BL_EN(GPIO%d)=%d · PWM GPIO%d · duty=%lu/%d · inverted",- BSP_LCD_BL_EN, gpio_get_level(BSP_LCD_BL_EN), BSP_LCD_BL_PWM,- (unsigned long)ledc_get_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL), BL_MAX_DUTY);-}-/** The copy into the framebuffer has finished, so LVGL may reuse the draw buffer.*@@ -163,45 +97,8 @@ static void flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)esp_err_t panel_bringup(void){-- backlight_init(); /* enable the boost early; duty stays 0 until there is something to show */-- /* The DSI PHY runs off an internal LDO, and it has to be up before the bus is created. Getting this- * wrong does not fail loudly — the bus is created and the panel simply never lights. */- const esp_ldo_channel_config_t ldo = {- .chan_id = BSP_LCD_DSI_PHY_LDO_CHAN,- .voltage_mv = BSP_LCD_DSI_PHY_LDO_MV,- };- ESP_RETURN_ON_ERROR(esp_ldo_acquire_channel(&ldo, &s_phy_pwr), TAG, "DSI PHY LDO (VO%d) refused",- BSP_LCD_DSI_PHY_LDO_CHAN);-- esp_lcd_dsi_bus_config_t bus = ST7703_PANEL_BUS_DSI_2CH_CONFIG();- ESP_RETURN_ON_ERROR(esp_lcd_new_dsi_bus(&bus, &s_bus), TAG, "dsi bus");-- esp_lcd_dbi_io_config_t dbi = ST7703_PANEL_IO_DBI_CONFIG();- ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_dbi(s_bus, &dbi, &s_io), TAG, "dbi io");-- esp_lcd_dpi_panel_config_t dpi = ST7703_720_720_PANEL_60HZ_DPI_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);- /* ONE framebuffer. LVGL renders into small buffers of its own and each flush copies a band into- * this one — the same partial-render shape the dial uses, which is why display.c can end up owning- * both boards rather than branching. Handing LVGL the panel's own framebuffers instead would save- * the copy, but it needs the buffer-switch protocol and its own tear handling; that is an- * optimisation for later, on a panel that is already known to work. */- dpi.num_fbs = 1;-- const st7703_vendor_config_t vendor = {- .mipi_config = { .dsi_bus = s_bus, .dpi_config = &dpi },- };- const esp_lcd_panel_dev_config_t dev = {- .reset_gpio_num = BSP_LCD_RST,- .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,- .bits_per_pixel = BSP_LCD_BIT_PER_PIXEL,- .vendor_config = (void *)&vendor,- };- ESP_RETURN_ON_ERROR(esp_lcd_new_panel_st7703(s_io, &dev, &s_panel), TAG, "st7703");- ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(s_panel), TAG, "panel reset");- ESP_RETURN_ON_ERROR(esp_lcd_panel_init(s_panel), TAG, "panel init");- return ESP_OK;+ pro_backlight_init(); /* enable the boost early; duty stays 0 until there is something to show */+ return pro_panel_bus_open(&s_panel, NULL);}esp_err_t panel_attach(int draw_lines, lv_display_t **out_display)diff --git a/devices/harness-device/firmware/main/ui/pro_panel_bus.c b/devices/harness-device/firmware/main/ui/pro_panel_bus.cnew file mode 100644index 000000000..6f2496b7b--- /dev/null+++ b/devices/harness-device/firmware/main/ui/pro_panel_bus.c@@ -0,0 +1,130 @@+#include "pro_panel_bus.h"++#include "board_pins.h"++#include "driver/gpio.h"+#include "driver/ledc.h"+#include "esp_check.h"+#include "esp_lcd_mipi_dsi.h"+#include "esp_lcd_panel_ops.h"+#include "esp_lcd_panel_vendor.h"+#include "esp_lcd_st7703.h"+#include "esp_ldo_regulator.h"+#include "esp_log.h"++static const char *TAG = "pro_panel_bus";++#define BL_TIMER LEDC_TIMER_0+#define BL_CHANNEL LEDC_CHANNEL_0+#define BL_MAX_DUTY ((1 << BSP_LCD_BL_RES_BITS) - 1)++static esp_lcd_panel_io_handle_t s_io;+static esp_lcd_dsi_bus_handle_t s_bus;+static esp_ldo_channel_handle_t s_phy_pwr;+static uint8_t s_level;++/*+ * Backlight. An AP3032 boost drives the LED string and its feedback pin is what this PWM moves, so the+ * duty is INVERTED — more duty is dimmer. The invert is done by the LEDC peripheral rather than by+ * arithmetic here, so the number in the register reads the same way the number in the code does.+ *+ * This is real dimming. The dial has no brightness control in hardware and fakes it with a translucent+ * overlay over the whole UI, which costs a composited layer on every frame; this board does not need+ * that.+ */+void pro_backlight_init(void)+{+ const gpio_config_t en = {+ .pin_bit_mask = 1ULL << BSP_LCD_BL_EN,+ .mode = GPIO_MODE_OUTPUT,+ .pull_up_en = GPIO_PULLUP_DISABLE,+ .pull_down_en = GPIO_PULLDOWN_DISABLE,+ .intr_type = GPIO_INTR_DISABLE,+ };+ gpio_config(&en);+ gpio_set_level(BSP_LCD_BL_EN, 1);++ const ledc_timer_config_t timer = {+ .speed_mode = LEDC_LOW_SPEED_MODE,+ .duty_resolution = BSP_LCD_BL_RES_BITS,+ .timer_num = BL_TIMER,+ .freq_hz = BSP_LCD_BL_FREQ_HZ,+ .clk_cfg = LEDC_AUTO_CLK,+ };+ ledc_timer_config(&timer);++ const ledc_channel_config_t ch = {+ .gpio_num = BSP_LCD_BL_PWM,+ .speed_mode = LEDC_LOW_SPEED_MODE,+ .channel = BL_CHANNEL,+ .timer_sel = BL_TIMER,+ .duty = 0,+ .hpoint = 0,+ .flags.output_invert = true,+ };+ ledc_channel_config(&ch);+}++void pro_backlight_set(uint8_t level)+{+ s_level = level;+ ledc_set_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL, (uint32_t)BL_MAX_DUTY * level / 255u);+ ledc_update_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL);+}++uint8_t pro_backlight_level(void) { return s_level; }++void pro_backlight_log(void)+{+ ESP_LOGI(TAG, "backlight · BL_EN(GPIO%d)=%d · PWM GPIO%d · duty=%lu/%d · inverted",+ BSP_LCD_BL_EN, gpio_get_level(BSP_LCD_BL_EN), BSP_LCD_BL_PWM,+ (unsigned long)ledc_get_duty(LEDC_LOW_SPEED_MODE, BL_CHANNEL), BL_MAX_DUTY);+}++void pro_backlight_enable(bool on)+{+ gpio_set_level(BSP_LCD_BL_EN, on ? 1 : 0);+}++esp_err_t pro_panel_bus_open(esp_lcd_panel_handle_t *out_panel, esp_lcd_dsi_bus_handle_t *out_bus)+{+ ESP_RETURN_ON_FALSE(out_panel, ESP_ERR_INVALID_ARG, TAG, "out_panel");++ /* The DSI PHY runs off an internal LDO, and it has to be up before the bus is created. Getting this+ * wrong does not fail loudly — the bus is created and the panel simply never lights. */+ const esp_ldo_channel_config_t ldo = {+ .chan_id = BSP_LCD_DSI_PHY_LDO_CHAN,+ .voltage_mv = BSP_LCD_DSI_PHY_LDO_MV,+ };+ ESP_RETURN_ON_ERROR(esp_ldo_acquire_channel(&ldo, &s_phy_pwr), TAG, "DSI PHY LDO (VO%d) refused",+ BSP_LCD_DSI_PHY_LDO_CHAN);++ esp_lcd_dsi_bus_config_t bus = ST7703_PANEL_BUS_DSI_2CH_CONFIG();+ ESP_RETURN_ON_ERROR(esp_lcd_new_dsi_bus(&bus, &s_bus), TAG, "dsi bus");++ esp_lcd_dbi_io_config_t dbi = ST7703_PANEL_IO_DBI_CONFIG();+ ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_dbi(s_bus, &dbi, &s_io), TAG, "dbi io");++ esp_lcd_dpi_panel_config_t dpi = ST7703_720_720_PANEL_60HZ_DPI_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);+ /* ONE framebuffer, for both renderers. LVGL renders into small buffers of its own and each flush+ * copies a band into this one; habitat rasterises damage strips and pushes those. Either way the+ * pixels are copied in rather than swapped, which is what lets this single config serve both.+ * Handing a renderer the panel's own buffers instead would save the copy but needs the+ * buffer-switch protocol and its own tear handling. */+ dpi.num_fbs = 1;++ const st7703_vendor_config_t vendor = {+ .mipi_config = { .dsi_bus = s_bus, .dpi_config = &dpi },+ };+ const esp_lcd_panel_dev_config_t dev = {+ .reset_gpio_num = BSP_LCD_RST,+ .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,+ .bits_per_pixel = BSP_LCD_BIT_PER_PIXEL,+ .vendor_config = (void *)&vendor,+ };+ ESP_RETURN_ON_ERROR(esp_lcd_new_panel_st7703(s_io, &dev, out_panel), TAG, "st7703");+ ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(*out_panel), TAG, "panel reset");+ ESP_RETURN_ON_ERROR(esp_lcd_panel_init(*out_panel), TAG, "panel init");+ if (out_bus) *out_bus = s_bus;+ return ESP_OK;+}diff --git a/devices/harness-device/firmware/main/ui/pro_panel_bus.h b/devices/harness-device/firmware/main/ui/pro_panel_bus.hnew file mode 100644index 000000000..ac83d5db1--- /dev/null+++ b/devices/harness-device/firmware/main/ui/pro_panel_bus.h@@ -0,0 +1,49 @@+// The Pro's panel and its backlight, with no renderer attached.+//+// WHY THIS IS ITS OWN FILE. There are two renderers on this board now, and they do not agree about+// anything above the bus: the LVGL one (panel_pro.c + display.c) hands LVGL a draw buffer and flushes+// bands into the framebuffer, while the habitat one (ui/habitat/display_habitat.c) owns the panel+// handle itself, rasterises its own damage strips and pushes them with esp_lcd_panel_draw_bitmap.+//+// What they DO agree about is everything below: the DSI PHY's LDO, the two-lane bus, the DBI io, the+// ST7703's own init, and an inverted LEDC duty on a boost converter. That is what lives here. It was+// inside panel_pro.c until habitat needed it too, and the alternative — a second copy of the bring-up+// sequence in the habitat display — is the kind of duplication that rots the moment one of the two+// timings is corrected and the other is not.+//+// Nothing in here mentions LVGL, so it links into a habitat image that has no LVGL display at all.+#pragma once++#include <stdbool.h>+#include <stdint.h>++#include "esp_err.h"+#include "esp_lcd_mipi_dsi.h"+#include "esp_lcd_types.h"++// LDO -> DSI bus -> DBI io -> ST7703 -> reset -> init. Safe before lv_init(); safe with no LVGL at all.+// The panel comes back ready for esp_lcd_panel_draw_bitmap. `out_bus` may be NULL when the caller has+// no use for the bus handle; the DPI callbacks are registered by the caller, because what they signal+// is the caller's business (an LVGL flush_ready, or a habitat DMA fence).+esp_err_t pro_panel_bus_open(esp_lcd_panel_handle_t *out_panel, esp_lcd_dsi_bus_handle_t *out_bus);++// The boost's enable pin and the LEDC timer/channel. Call before the panel, so the rail is up and+// steady while duty is still 0 — there is nothing to show yet and a bright flash of an uninitialised+// framebuffer is the one thing a first boot should not do.+void pro_backlight_init(void);++// 0 = dimmest, 255 = brightest, matching the dial's DCS register range so one UI setting drives both.+void pro_backlight_set(uint8_t level);++// The hard enable, for the idle blank. This panel is backlit, so "off" is the light rather than the+// pixels: cutting the DSI stream instead would need a full re-init to come back from.+void pro_backlight_enable(bool on);++// What the backlight is ACTUALLY being driven with, logged — so a brightness bug and a video bug can be+// told apart from the log instead of by eye. This is why the enable pin is read back rather than+// remembered: the two failures look identical on the glass.+void pro_backlight_log(void);++// What pro_backlight_set() was last given. The idle blank restores through this rather than reading the+// duty back out and converting, which lost a step to integer division every time it blanked.+uint8_t pro_backlight_level(void);diff --git a/devices/harness-device/firmware/scripts/gen_octopus.py b/devices/harness-device/firmware/scripts/gen_octopus.pyindex 391f5239e..e1dc4a90a 100644--- a/devices/harness-device/firmware/scripts/gen_octopus.py+++ b/devices/harness-device/firmware/scripts/gen_octopus.py@@ -80,7 +80,15 @@ emit(root / 'main/ui/habitat/octopus_art.inc', '\n'.join(out) + '\n')out = ['// Generated by scripts/gen_octopus.py. Habitat Octopus ASCII atlas.','// Derived from Jgs7, (c) 2022 Adel Faure, Velvetyne; SIL OFL 1.1.','// This atlas remains OFL-licensed; see fonts/Jgs-OFL.txt.', '#include "octopus.h"']-for height in (2, 4, 6, 8, 10):+# THE ATLAS LADDER. The number is the CELL HEIGHT and the advance is half of it, so a 54 x 27 clip drawn+# in font_N measures 27N tall by 27N wide — font_4 is the 108 px portrait octopus.h talks about and+# font_6 is its 162 px brief one.+#+# 14 and 16 are the Pro's. A 720 px face has room for 27*16 = 432 px of companion where the dial's+# largest is 270, and 14 is the rung the carrying state drops to. They are guarded to the P4 so the+# dial's habitat image does not carry two atlases it can never draw.+PRO_ONLY = (14, 16)+for height in (2, 4, 6, 8, 10, 14, 16):width = height // 2font = ImageFont.truetype(str(root / 'fonts/jgs7.ttf'), height)data = []@@ -90,9 +98,13 @@ for height in (2, 4, 6, 8, 10):values = [min(3, (v + 42) // 85) for v in im.get_flattened_data()]values += [0] * (-len(values) % 4)data.extend(sum(values[j+k] << (6-2*k) for k in range(4)) for j in range(0, len(values), 4))+ if height in PRO_ONLY:+ out.append('#if HT_FACE_PX >= 720')out.append(f'static const uint8_t octopus_{height}_pixels[] = {{')out.extend(' ' + ','.join(map(str, data[i:i+24])) + ',' for i in range(0, len(data), 24))out.append(f'}};\nconst ht_font_t ht_octopus_font_{height} = {{32,126,{width},{height},octopus_{height}_pixels}};')+ if height in PRO_ONLY:+ out.append('#endif')print(f'Octopus font: {width}x{height}, {len(data)} bytes')emit(root / 'main/ui/habitat/octopus_font.c', '\n'.join(out) + '\n')packed = len(encoded) + 2 * (len(offsets) + len(rows)) + len(alphabet) + 1diff --git a/devices/harness-device/firmware/test/test_gestures.c b/devices/harness-device/firmware/test/test_gestures.cindex 5378f2e03..47ede027b 100644--- a/devices/harness-device/firmware/test/test_gestures.c+++ b/devices/harness-device/firmware/test/test_gestures.c@@ -40,5 +40,46 @@ int main(void) {assert(ht_gesture_end(&g,233,233,1080)==HT_TOUCH_NONE);assert(tap(1200,233,233)==HT_TOUCH_TAP);}- puts("gestures: PASS (single release, slow tap, voice guard, holds, wrap + 20,000 drag/cancel traces)");+ /*+ * A WRITTEN CONTROL IS NOT A GESTURE, and this is the measurement that says why.+ *+ * ht_gesture_move() calls a contact "moved" at 12 px. On the Pro's 720 px face that is 10.01 px+ * per mm, so the threshold is 1.20 mm — well inside the drift of a deliberate fingertip press.+ * Any activation rule keyed on !moved therefore fires for a still finger and not for a real one,+ * which on the glass reads as a button that works about half the time.+ *+ * ui_habitat.c's rule is the one every touch button uses instead: down on the control, up on the+ * control. The two asserts below lock both halves of that in — drift inside activates, drift out+ * cancels — and the loop records that `moved` is true throughout, so nobody re-derives the old+ * rule from the resolver and reintroduces the bug.+ */+ {+ const int rx = 144, ry = 628, rw = 432, rh = 88; // the widened [discard] target+ const double pxmm = 10.01;+ int cx = rx + rw / 2, cy = ry + rh / 2;+ int inside_hits = 0, moved_seen = 0;+ for (int tenths = 0; tenths <= 40; tenths++) { // 0.0 .. 4.0 mm of drift+ int dx = (int)(tenths / 10.0 * pxmm + 0.5);+ for (unsigned d = 0; d < 7; d++) {+ const uint32_t ms[] = {80, 200, 400, 500, 900, 1500, 2200};+ clear(); ht_gesture_begin(&g, cx, cy, 0, 0);+ ht_gesture_move(&g, cx + dx, cy);+ ht_gesture_end(&g, cx + dx, cy, ms[d]);+ if (g.moved) moved_seen++;+ int x = cx + dx, y = cy;+ if (x >= rx && x < rx + rw && y >= ry && y < ry + rh) inside_hits++;+ }+ }+ // Every one of these presses lands inside the control, at every duration...+ assert(inside_hits == 41 * 7);+ // ...and most of them are "moved", which is exactly what the discarded rule keyed on.+ assert(moved_seen > 0 && moved_seen < 41 * 7);+ // Leaving the control is a cancel, whatever the resolver says about the contact.+ clear(); ht_gesture_begin(&g, cx, cy, 0, 0);+ ht_gesture_move(&g, rx - 40, cy);+ ht_gesture_end(&g, rx - 40, cy, 200);+ assert(!(rx - 40 >= rx));+ }+ puts("gestures: PASS (single release, slow tap, voice guard, holds, wrap + 20,000 drag/cancel "+ "traces; written-control press survives 4 mm of drift at every duration)");}diff --git a/devices/harness-device/firmware/test/test_glyph_cache.c b/devices/harness-device/firmware/test/test_glyph_cache.cindex 987ff7ae7..41d2ed832 100644--- a/devices/harness-device/firmware/test/test_glyph_cache.c+++ b/devices/harness-device/firmware/test/test_glyph_cache.c@@ -19,8 +19,15 @@ static void compare(const ht_scene_t *scene, ht_rect_t clip)}int main(void){+ // The Pro's two atlases are in this list too: they are the ones the cache was widened for, and+ // the ones whose extra columns the unrolled copy in terminal.c used to drop.const ht_font_t *fonts[] = {&ht_octopus_font_2, &ht_octopus_font_4,- &ht_octopus_font_6, &ht_octopus_font_8, &ht_octopus_font_10, &ht_mono_20};+ &ht_octopus_font_6, &ht_octopus_font_8, &ht_octopus_font_10,+#if HT_FACE_PX >= 720+ &ht_octopus_font_14, &ht_octopus_font_16,+#endif+ &ht_mono_20};+ const unsigned nfonts = sizeof fonts / sizeof *fonts;char alphabet[128];for (int i = 0; i < 95; i++) alphabet[i] = i + 32;memcpy(alphabet + 95, "\xe2\x80\x94\xe2\x80\x9c\xf0\x9f\x90\x99", 11);@@ -28,7 +35,7 @@ int main(void)for (unsigned i = 0; i < 6000; i++) {ht_scene_clear(&scene, next());for (unsigned row = 0, count = 1 + next() % 12; row < count; row++) {- const ht_font_t *font = fonts[next() % 6];+ const ht_font_t *font = fonts[next() % nfonts];ht_text(&scene, (int)(next() % 120) - 40, (int)(next() % 130) - 25,1 + next() % 465, font, next(), next() % 2 ? scene.background : next(),alphabet + next() % 95);@@ -55,6 +62,11 @@ int main(void)assert(ht_glyph_cache_builds() == builds); // full-to-strip reuse, no palette churn}}+ // 24 slots of the widest atlas this face has: 5x10 on the dial, 8x16 on the Pro.+#if HT_FACE_PX >= 720+ assert(ht_glyph_cache_bytes() <= 6400);+#elseassert(ht_glyph_cache_bytes() <= 2600);+#endifputs("glyph cache: 6000 clipped mixed scenes + 252 complete poses match the original renderer; guards and warm reuse pass");}diff --git a/devices/harness-device/firmware/test/test_octopus.c b/devices/harness-device/firmware/test/test_octopus.cindex 5e1335fd9..55a1fcdc8 100644--- a/devices/harness-device/firmware/test/test_octopus.c+++ b/devices/harness-device/firmware/test/test_octopus.c@@ -28,7 +28,10 @@ static void transition(const ht_scene_t *before, const ht_scene_t *after)static bool tick(ht_octopus_motion_t *m, uint32_t now, ht_tim_mood_t mood,bool quiet, bool visible, bool down, unsigned level){- bool changed = ht_octopus_motion_tick(m, now, mood, quiet, visible, down, 330, level, now / 100);+ // 97 px right of the middle of the face, which is where the gaze test wants the finger. Written+ // against HT_WIDTH rather than as 330 so it means the same thing on a 466 dial and a 720 Pro —+ // tim.c reads the gaze relative to the centre, and 330 is left of centre on the larger face.+ bool changed = ht_octopus_motion_tick(m, now, mood, quiet, visible, down, HT_WIDTH / 2 + 97, level, now / 100);assert(m->next_ms >= 1 && m->next_ms <= 1000);assert(m->frame < HT_OCTOPUS_FRAMES);return changed;diff --git a/devices/harness-device/firmware/test/test_raster_ascii.c b/devices/harness-device/firmware/test/test_raster_ascii.cindex 4027541de..4d2a49c18 100644--- a/devices/harness-device/firmware/test/test_raster_ascii.c+++ b/devices/harness-device/firmware/test/test_raster_ascii.c@@ -66,6 +66,11 @@ int main(void)assert(ht_glyph_cache_builds() == builds); // full-to-strip reuse, no palette churn}}+ // The budget follows the widest atlas the face has: 24 slots of 5x10 on the dial, of 8x16 on the Pro.+#if HT_FACE_PX >= 720+ assert(ht_glyph_cache_bytes() <= 6400);+#elseassert(ht_glyph_cache_bytes() <= 2600);+#endifputs("ASCII raster: 6000 clipped mixed scenes + 252 complete poses match the Unicode renderer; guards and warm reuse pass");}