From 89f63db8ab9bcfca1918b78e83477a3d01fe7224 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Mon, 11 May 2026 21:04:45 -0700 Subject: [PATCH] App UI improvements --- app/g2/dashboard-controller.ts | 8 ++++++-- app/graphics/battery.ts | 8 ++++---- app/graphics/bdffont.ts | 4 ++++ app/ui/dashboard.ts | 31 ++++++++++++++++++------------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index f9f3a1b6..1ac5ec14 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -9,7 +9,7 @@ import { nightscoutBridge } from "../native/nightscout"; import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict"; import { grayImageToPreviewSource, grayImageToPreviewSourceWithBitmapFactory } from "../native/gray-image-preview"; import { voiceControlBridge } from "../native/voice-control"; -import { type GrayImage } from "../graphics/image"; +import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image"; import { applyDashboardScreenTimeout, consumeDashboardTiledWakePaint, @@ -59,6 +59,10 @@ const CONNECTED_PREVIEW_MIN_UPDATE_MS = 1_000; const EVEN_APP_DETECTED_MESSAGE = "The Even Realities app appears to be running. If Faceclaw has trouble connecting, open its app settings and force stop it."; +function createInitialDisplayPreview(): ImageSource | null { + return grayImageToPreviewSource(new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0)); +} + function formatTimestamp(date: Date): string { return date.toISOString().slice(11, 23); } @@ -114,7 +118,7 @@ class DashboardController { private activeTextSettingEditorKind: TextSettingEditorKind | null = null; private evenNotificationActive = false; private evenAppConflictMessage = ""; - private displayPreview: ImageSource | null = null; + private displayPreview: ImageSource | null = createInitialDisplayPreview(); private readonly listeners = new Set(); private communicator: FaceclawCommunicatorBridge | null = null; diff --git a/app/graphics/battery.ts b/app/graphics/battery.ts index 330d6b34..2cba1b32 100644 --- a/app/graphics/battery.ts +++ b/app/graphics/battery.ts @@ -43,16 +43,16 @@ export function drawBattery(percentCharge: number, isCharging: boolean): GrayIma const fillWidth = Math.round((BATTERY_FILL_WIDTH * clamped) / 100); icon.fillRect(BATTERY_FILL_X, BATTERY_FILL_Y, fillWidth, BATTERY_FILL_HEIGHT, 190); if (isCharging) { - overlayImage(icon, BATTERY_BOLT_ICON, 7, 1); + overlayImage(icon, BATTERY_BOLT_ICON, 7, 1, clamped > 50 ? 0 : 255); } return icon; } -function overlayImage(target: GrayImage, source: GrayImage, dx: number, dy: number): void { +function overlayImage(target: GrayImage, source: GrayImage, dx: number, dy: number, value: number): void { for (let y = 0; y < source.height; y++) { for (let x = 0; x < source.width; x++) { - const value = source.pixels[y * source.width + x] ?? 0; - if (value > 0) { + const sourceValue = source.pixels[y * source.width + x] ?? 0; + if (sourceValue > 0) { target.setPixel(dx + x, dy + y, value); } } diff --git a/app/graphics/bdffont.ts b/app/graphics/bdffont.ts index ad84b6b0..28c0b56b 100644 --- a/app/graphics/bdffont.ts +++ b/app/graphics/bdffont.ts @@ -142,6 +142,10 @@ export function loadEmbeddedTerminus24(): BdfFont { return loadEmbeddedFont("fonts/terminus/ter-u24n.bdf"); } +export function loadEmbeddedTerminus32(): BdfFont { + return loadEmbeddedFont("fonts/terminus/ter-u32n.bdf"); +} + function loadEmbeddedFont(path: string): BdfFont { const cached = cachedEmbeddedFonts.get(path); if (cached) { diff --git a/app/ui/dashboard.ts b/app/ui/dashboard.ts index 2f764a7e..f932f0d3 100644 --- a/app/ui/dashboard.ts +++ b/app/ui/dashboard.ts @@ -1,5 +1,5 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image"; -import { loadEmbeddedTerminus12, loadEmbeddedTerminus16 } from "../graphics/bdffont"; +import { loadEmbeddedTerminus12, loadEmbeddedTerminus16, loadEmbeddedTerminus32 } from "../graphics/bdffont"; import { BATTERY_ICON_WIDTH, drawBattery } from "../graphics/battery"; import { loadPngAsGrayImage } from "../graphics/imagefile"; import { type RawInputEvent } from "../native/faceclaw-communicator"; @@ -92,6 +92,7 @@ const dashboardActions: LayerActions = { }; const dashboardFont = loadEmbeddedTerminus12(); const dashboardSystemFont = loadEmbeddedTerminus16(); +const stopwatchFont = loadEmbeddedTerminus32(); const NOTIFICATION_ICON_SIZE = 24; const SYSTEM_CARD_ITEM_HEIGHT = 38; const SYSTEM_CARD_ITEM_GAP = 2; @@ -460,15 +461,17 @@ function createRootMenuLayer(): MenuLayer { ctx.stack.push(createSettingsMenuLayer()); }, }, - ...getDashboardSlotIds().map((slot) => ({ - label: pluginLabelForSlot(slot), - onSelect: (ctx: LayerContext) => { - openDashboardSlot(slot, ctx); - }, - render: ({ image, x, y }: { image: GrayImage; x: number; y: number }) => { - image.drawText(dashboardFont, x, y + 3, pluginLabelForSlot(slot), 200); - }, - })), + ...getDashboardSlotIds() + .filter((slot) => !isBlankDashboardPlugin(dashboardState.slotConfig[slot])) + .map((slot) => ({ + label: pluginLabelForSlot(slot), + onSelect: (ctx: LayerContext) => { + openDashboardSlot(slot, ctx); + }, + render: ({ image, x, y }: { image: GrayImage; x: number; y: number }) => { + image.drawText(dashboardFont, x, y + 3, pluginLabelForSlot(slot), 200); + }, + })), { label: "System", onSelect: (ctx) => { @@ -515,12 +518,14 @@ class StopwatchLayer implements Layer { const timeLabel = formatStopwatchElapsed(elapsedMs); const stateLabel = this.pausedAtMs === null ? "Running" : "Paused"; - image.drawRect(12, 12, G2_LENS_WIDTH - 24, G2_LENS_HEIGHT - 24, 52); image.drawText(ctx.font, 24, 24, "Stopwatch", 180); image.drawText(ctx.font, G2_LENS_WIDTH - 114, 24, stateLabel, this.pausedAtMs === null ? 200 : 120); - const timeX = Math.max(0, ((G2_LENS_WIDTH - dashboardSystemFont.measureText(timeLabel)) / 2) | 0); - image.drawText(dashboardSystemFont, timeX, 106, timeLabel, 245); + const quadrantWidth = G2_LENS_WIDTH / 2; + const quadrantHeight = G2_LENS_HEIGHT / 2; + const timeX = Math.max(0, Math.round((quadrantWidth - stopwatchFont.measureText(timeLabel)) / 2)); + const timeY = Math.max(0, Math.round((quadrantHeight - stopwatchFont.lineHeight) / 2)); + image.drawText(stopwatchFont, timeX, timeY, timeLabel, 245); image.drawText(ctx.font, 126, 160, "Click: pause / resume", 150); image.drawText(ctx.font, 126, 178, "Double-click: back", 120); image.drawText(ctx.font, 126, 214, "Renders requested every 100ms", 110);