forked from Blendman974/faceclaw
App UI improvements
This commit is contained in:
1 parent
e3be5dd629
commit
89f63db8ab
4 files changed
+32
-19
No files matched your search
@@ -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<DashboardListener>();
|
||||
|
||||
private communicator: FaceclawCommunicatorBridge | null = null;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+18
-13
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user