Add calibration indicator to glanceboard compass

This commit is contained in:
James Babcock committed 2026-10-13 17:21:46 -07:00
1 parent df95cc4064
commit 22c31f4240
4 files changed
+45 -13

No files matched your search

+10 -10
View File
@@ -23,7 +23,14 @@ import {
import { shell } from "../../ui/shell/shell";
import { ensureLocationPermission, hasLocationPermission } from "../../native/location-permissions";
import { isCompassCalibrated, normalizeHeading } from "./calibration";
import { cardinalDirection, createCompassBackground, drawCompassRose, layoutCompassRose, TICK_HEIGHT } from "./compass-rose";
import {
cardinalDirection,
createCompassBackground,
drawCompassRose,
layoutCompassRose,
magneticAccuracyDots,
TICK_HEIGHT,
} from "./compass-rose";
import { CompassCalibrationLayer } from "./calibration-layer";
import { getDeclinationAvailability, onDeclinationChanged, refreshDeclination } from "./declination";
import { getNorthReference, resolveHeading, setNorthReference, type NorthReference } from "./heading";
@@ -277,14 +284,7 @@ function frameStatusText(): string {
}
}
/**
* The firmware's magnetometer calibration readiness (0-3) as filled/empty
* dots, e.g. "Calibration: ●●○" for 2/3. This is the glasses' own sensor
* calibration, not the wearer-fit offset set on the calibration screen.
*/
/** The firmware's magnetometer calibration readiness, e.g. "Calibration: ●●○" for 2/3. */
function magneticAccuracyText(diagnostics: CompassDiagnostics | null): string {
const accuracy = diagnostics && (diagnostics.flags & 0x80) ? diagnostics.magneticAccuracy : -1;
if (accuracy < 0) return "Calibration: --";
const filled = Math.min(3, accuracy);
return `Calibration: ${"●".repeat(filled)}${"○".repeat(3 - filled)}`;
return `Calibration: ${magneticAccuracyDots(diagnostics) ?? "--"}`;
}
+14
View File
@@ -5,6 +5,7 @@
* own the magnetometer lifecycle and the readout text around it.
*/
import { GrayImage } from "../../graphics/image";
import { type CompassDiagnostics } from "../../native/compass-types";
import { normalizeHeading } from "./calibration";
/**
@@ -102,6 +103,19 @@ export function cardinalDirection(heading: number): string {
return names[Math.round(normalizeHeading(heading) / 45) % names.length]!;
}
/**
* The firmware's magnetometer calibration readiness (0-3) as filled/empty
* dots, e.g. "●●○" for 2/3, or null when the firmware doesn't report it. This
* is the glasses' own sensor calibration, not the wearer-fit offset set on the
* calibration screen.
*/
export function magneticAccuracyDots(diagnostics: CompassDiagnostics | null): string | null {
const accuracy = diagnostics && (diagnostics.flags & 0x80) ? diagnostics.magneticAccuracy : -1;
if (accuracy < 0) return null;
const filled = Math.min(3, accuracy);
return "●".repeat(filled) + "○".repeat(3 - filled);
}
interface Point {
x: number;
y: number;