forked from Blendman974/faceclaw
Adapt layouts for Rayneo screen resolution
This commit is contained in:
1 parent
4d101eefe1
commit
dee60bbcd2
34 files changed
+721
-202
No files matched your search
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* The paired glasses' screen (per eye), which the shell and UI lay out in:
|
||||
* the G2's 640x480, or the RayNeo iO's 540x220 with the Faceclaw firmware.
|
||||
*
|
||||
* Read straight from the settings store (the key dashboard-settings.ts's
|
||||
* glassesTypeSetting writes), so this stays a leaf that UI primitives can
|
||||
* import without pulling in the settings module, and every isolate (the
|
||||
* main one, app workers, the phone preview) agrees with the session.
|
||||
*/
|
||||
import { getStringSetting } from "../native/settings-store";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, RAYNEO_IO_HEIGHT, RAYNEO_IO_WIDTH } from "./image";
|
||||
|
||||
/** Settings key of the paired glasses' type: "g2" (default) or "rayneo-io". */
|
||||
export const GLASSES_TYPE_KEY = "deviceType";
|
||||
|
||||
/** Whether the paired glasses are a RayNeo iO. */
|
||||
export function isRayNeoIoConfigured(): boolean {
|
||||
return getStringSetting(GLASSES_TYPE_KEY, "g2") === "rayneo-io";
|
||||
}
|
||||
|
||||
export function screenWidth(): number {
|
||||
return isRayNeoIoConfigured() ? RAYNEO_IO_WIDTH : G2_LENS_WIDTH;
|
||||
}
|
||||
|
||||
export function screenHeight(): number {
|
||||
return isRayNeoIoConfigured() ? RAYNEO_IO_HEIGHT : G2_LENS_HEIGHT;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import type { UiFont } from "./image";
|
||||
import { TtfFont } from "./ttf-font";
|
||||
import { ensurePreinstalledFonts, getInstalledFont, installedFontPath } from "./installed-fonts";
|
||||
import { getStringSetting, onSettingsStoreChanged, setStringSetting } from "../native/settings-store";
|
||||
import { GLASSES_TYPE_KEY, isRayNeoIoConfigured } from "./screen-size";
|
||||
|
||||
export type BitmapFace = "terminus" | "terminusv";
|
||||
|
||||
@@ -72,8 +73,18 @@ export function parseFontSelection(raw: string): UiFontSelection | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Default UI font when the user has never picked one. */
|
||||
const DEFAULT_UI_FONT: UiFontSelection = { kind: "ttf", file: "Roboto-Light.ttf", size: 16 };
|
||||
/**
|
||||
* The default UI font's size, which onboarding recommends: 16, or 14 on the
|
||||
* RayNeo iO, whose 540x220 screen fits fewer rows.
|
||||
*/
|
||||
export function defaultUiFontSize(): number {
|
||||
return isRayNeoIoConfigured() ? 14 : 16;
|
||||
}
|
||||
|
||||
/** Default UI font when the user has never picked one: Roboto Light at the default size. */
|
||||
function defaultUiFont(): UiFontSelection {
|
||||
return { kind: "ttf", file: "Roboto-Light.ttf", size: defaultUiFontSize() };
|
||||
}
|
||||
|
||||
export function getUiFontSelection(): UiFontSelection {
|
||||
const parsed = parseFontSelection(getStringSetting(UI_FONT_SELECTION_KEY, ""));
|
||||
@@ -84,7 +95,7 @@ export function getUiFontSelection(): UiFontSelection {
|
||||
if (legacy === "terminus" || legacy === "terminusv") {
|
||||
return { kind: "bitmap", face: legacy };
|
||||
}
|
||||
return DEFAULT_UI_FONT;
|
||||
return defaultUiFont();
|
||||
}
|
||||
|
||||
export function setUiFontSelection(selection: UiFontSelection): void {
|
||||
@@ -113,7 +124,8 @@ export function fontSelectionLabel(selection: UiFontSelection): string {
|
||||
|
||||
type UiFontRole = "small" | "medium" | "large";
|
||||
|
||||
const UI_FONT_KEYS: readonly string[] = [UI_FONT_SELECTION_KEY, LEGACY_UI_FONT_KEY];
|
||||
/** Keys whose change re-resolves the UI fonts (the glasses type picks the default size). */
|
||||
const UI_FONT_KEYS: readonly string[] = [UI_FONT_SELECTION_KEY, LEGACY_UI_FONT_KEY, GLASSES_TYPE_KEY];
|
||||
|
||||
/**
|
||||
* The three role fonts for one selection source, resolved lazily and cached
|
||||
|
||||
Reference in new issue
Block a user