Compass has higher sample rate, and distinguishes map north from true north

This commit is contained in:
James Babcock committed 2026-09-01 14:37:09 -07:00
1 parent eb8a863222
commit a72e29a04f
13 files changed
+429 -55

No files matched your search

+16 -4
View File
@@ -79,7 +79,7 @@ brief:
| `getConfiguredApiKeys(): Promise<ApiKeyService[]>` | Which keys the user configured (names only). |
| `requestApiKeyAccess(services): Promise<Partial<Record<ApiKeyService, string>>>` | Prompt for and return key values. |
| `playBuzzer(steps): Promise<void>` | Play a piezo tone sequence. |
| `addCompassListener(fn): () => void` | Activate the magnetometer; receive heading samples. Uncalibrated (see note). |
| `addCompassListener(fn): () => void` | Activate the magnetometer; receive heading samples (see note). |
| `createLayout(layout): Promise<boolean>` | Build the initial page (extended layout: full 576×452, no count limit, `preserve`). |
| `replaceLayout(layout): Promise<boolean>` | Replace the page; `preserve` containers inherit content by name. |
| `setAssistantTools(tools): void` | Contribute voice-assistant tools (namespaced by package name). |
@@ -88,9 +88,21 @@ brief:
### Compass
`addCompassListener` is **not pre-calibrated**: the magnetometer is inside the
right arm, which rests on the head with a slight curl that differs between
wearers and wears. Treat the heading as relative — let the user zero it.
Each `CompassReading` carries several headings, all degrees clockwise in
[0, 360):
- `headingDegrees` — the raw glasses reading. **Not pre-calibrated**: the
magnetometer is inside the right arm, which rests on the head with a slight
curl that differs between wearers and wears, so this is relative.
- `magneticHeadingDegrees` — raw reading corrected by the wearer's calibration
offset from the host's Compass app. `wearerCalibrated` says whether they have
calibrated; until then it equals `headingDegrees`.
- `declinationDegrees` / `trueHeadingDegrees` — local declination from the
phone's location, and the magnetic heading with it applied. Absent when the
host has no location (no permission, or no fix yet).
Prefer `trueHeadingDegrees` when present, then `magneticHeadingDegrees`. If
`wearerCalibrated` is false, treat them as relative or let the user zero them.
### Extended layout
+32 -6
View File
@@ -62,10 +62,34 @@ export type WindowLifecycleEventType = "visible" | "hidden" | "focused" | "blurr
export interface WindowLifecycleEvent {
type: WindowLifecycleEventType;
}
/** A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}. */
/**
* A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}.
* All headings are degrees clockwise in [0, 360).
*/
export interface CompassReading {
/** Magnetic heading in degrees [0, 360). */
/**
* Raw magnetic heading as reported by the glasses, with no correction for
* how they sit on the wearer's head. Kept for apps that zero it themselves.
*/
headingDegrees: number;
/**
* Magnetic heading corrected by the wearer's calibration offset from the
* host's Compass app. Equal to `headingDegrees` until they calibrate.
*/
magneticHeadingDegrees: number;
/**
* Whether the wearer has been through the host's compass calibration, i.e.
* whether `magneticHeadingDegrees` and `trueHeadingDegrees` can be trusted
* as absolute rather than relative.
*/
wearerCalibrated: boolean;
/**
* Local magnetic declination (east positive), from the phone's location and
* the World Magnetic Model. Absent when the host has no location.
*/
declinationDegrees?: number;
/** `magneticHeadingDegrees` plus declination. Absent when declination is. */
trueHeadingDegrees?: number;
}
export interface FaceclawContainerCommon {
containerID: number;
@@ -172,10 +196,12 @@ export interface FaceclawExtensions {
* Returns an unsubscribe function; the sensor stays on while at least one
* listener is registered and the app is the foreground window.
*
* NOT pre-calibrated: the magnetometer sits inside the right arm, which rests
* against the wearer's head with a slight curl that differs between wearers
* (and between wears). Treat `headingDegrees` as relative — let the user zero
* it against a known direction rather than trusting it as true/magnetic north.
* The magnetometer sits inside the right arm, which rests against the
* wearer's head with a slight curl that differs between wearers (and between
* wears), so `headingDegrees` is relative. The host's Compass app lets the
* wearer calibrate that away and adds local declination: prefer
* `trueHeadingDegrees` when present, then `magneticHeadingDegrees`, and check
* `wearerCalibrated` before trusting either as absolute.
*/
addCompassListener(listener: (reading: CompassReading) => void): () => void;
/**
+32 -6
View File
@@ -67,10 +67,34 @@ export interface WindowLifecycleEvent {
type: WindowLifecycleEventType;
}
/** A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}. */
/**
* A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}.
* All headings are degrees clockwise in [0, 360).
*/
export interface CompassReading {
/** Magnetic heading in degrees [0, 360). */
/**
* Raw magnetic heading as reported by the glasses, with no correction for
* how they sit on the wearer's head. Kept for apps that zero it themselves.
*/
headingDegrees: number;
/**
* Magnetic heading corrected by the wearer's calibration offset from the
* host's Compass app. Equal to `headingDegrees` until they calibrate.
*/
magneticHeadingDegrees: number;
/**
* Whether the wearer has been through the host's compass calibration, i.e.
* whether `magneticHeadingDegrees` and `trueHeadingDegrees` can be trusted
* as absolute rather than relative.
*/
wearerCalibrated: boolean;
/**
* Local magnetic declination (east positive), from the phone's location and
* the World Magnetic Model. Absent when the host has no location.
*/
declinationDegrees?: number;
/** `magneticHeadingDegrees` plus declination. Absent when declination is. */
trueHeadingDegrees?: number;
}
// ---- Extended layout (a superset of the stock EvenHub page containers) ----
@@ -207,10 +231,12 @@ export interface FaceclawExtensions {
* Returns an unsubscribe function; the sensor stays on while at least one
* listener is registered and the app is the foreground window.
*
* NOT pre-calibrated: the magnetometer sits inside the right arm, which rests
* against the wearer's head with a slight curl that differs between wearers
* (and between wears). Treat `headingDegrees` as relative — let the user zero
* it against a known direction rather than trusting it as true/magnetic north.
* The magnetometer sits inside the right arm, which rests against the
* wearer's head with a slight curl that differs between wearers (and between
* wears), so `headingDegrees` is relative. The host's Compass app lets the
* wearer calibrate that away and adds local declination: prefer
* `trueHeadingDegrees` when present, then `magneticHeadingDegrees`, and check
* `wearerCalibrated` before trusting either as absolute.
*/
addCompassListener(listener: (reading: CompassReading) => void): () => void;