forked from Blendman974/faceclaw
Add calibration indicator to glanceboard compass
This commit is contained in:
1 parent
df95cc4064
commit
22c31f4240
4 files changed
+45
-13
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user