forked from Blendman974/faceclaw
Glanceboard: address review of head-tilt angle and glance down
- A verification read that still disagrees no longer requeues the writes at once (which looped while the firmware refused the value); the next regular poll retries. - "Glasses default" now writes back the glasses' own switch and angle, saved before Faceclaw first changed them (persisted across app restarts), and drops writes still queued. Disabling the Glanceboard does the same. - "Set to current head angle" takes two readings, head level then tilted up, and uses the angle between them, so it no longer depends on the sensor's axes or folds past 45°. A head that did not move is reported, not stored as 5°. The math is in head-tilt-math.ts, with tests. - A head-tilt that woke a suspended session, or a trigger under 25° (where a level gaze stays above the head-down threshold), hides after the tap duration instead of the 60 s cap. The setting's description explains it. - The angle rows are hidden on iOS, which cannot change the setting. - The capture row repaints while measuring, ignores repeat selects, and its status clears when the menu reopens or the angle changes; the angle is sent once, by the controller's settings listener. - Comments describing a head-tilt as a timed press are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cf74f34767
commit
b1ca8b8ca1
15 files changed
+476
-128
No files matched your search
@@ -48,7 +48,7 @@ export type GlanceboardProvider = {
|
||||
isEnabled: () => boolean;
|
||||
/** Whether a single tap shows the board (for tapTimeoutMs). */
|
||||
showOnTap: () => boolean;
|
||||
/** How long a tap or head-tilt keeps the board up. */
|
||||
/** How long a tap keeps the board up (and a head-tilt, when its head-down is unlikely to come). */
|
||||
tapTimeoutMs: () => number;
|
||||
/** Whether a long-press holds the board up until released. */
|
||||
showOnLongPress: () => boolean;
|
||||
|
||||
@@ -6,7 +6,15 @@ import { uiFontOverridePickerMenuItem } from "../../ui/font-picker";
|
||||
import { type InputEvent } from "../../ui/gestures";
|
||||
import { type Layer, type LayerContext } from "../../ui/layers";
|
||||
import { drawRightValueMenuItem, drawSelectionHighlight, isMenuItemDisabled, MenuLayer, openModalMenu, submenuItem, type MenuItem } from "../../ui/menu";
|
||||
import { applyGlanceAngle, glassesHeadUpTrigger, setGlanceAngleFromHead } from "../../g2/head-angle";
|
||||
import {
|
||||
captureHeadAngleStep,
|
||||
glassesHeadUpTrigger,
|
||||
headAngleCaptureRunning,
|
||||
headAngleCaptureStep,
|
||||
resetHeadAngleCapture,
|
||||
syncGlanceAngleOriginal,
|
||||
} from "../../g2/head-angle";
|
||||
import { getHeadUpStatus, headUpControlsAvailable } from "../../native/glasses-controls";
|
||||
import { Menu } from "../../ui/menu-core";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../../ui/metrics";
|
||||
import { createInProcessWindow, type InProcessAppOptions, type InProcessWindow } from "../../ui/shell/in-process-window";
|
||||
@@ -314,8 +322,9 @@ function openGlanceSettings(ctx: LayerContext): void {
|
||||
enumSettingMenuItem(glanceTapDurationSetting),
|
||||
toggleSettingMenuItem(glanceShowOnLongPressSetting),
|
||||
toggleSettingMenuItem(glanceShowOnHeadTiltSetting),
|
||||
enumSettingMenuItem(glanceAngleSetting, { onChange: () => { applyGlanceAngle(); } }),
|
||||
headAngleCaptureMenuItem(),
|
||||
// Only Android can change the glasses' head-up setting (glasses-controls.ts).
|
||||
// The controller's settings listener sends a new angle to the glasses.
|
||||
...(headUpControlsAvailable() ? [enumSettingMenuItem(glanceAngleSetting), headAngleCaptureMenuItem()] : []),
|
||||
toggleSettingMenuItem(glanceShowLinesSetting),
|
||||
uiFontOverridePickerMenuItem(glanceFont, {
|
||||
title: "Glanceboard font",
|
||||
@@ -325,32 +334,51 @@ function openGlanceSettings(ctx: LayerContext): void {
|
||||
enumSettingMenuItem(glanceDepthSetting),
|
||||
...widgetSettingsMenuItems(),
|
||||
];
|
||||
resetHeadAngleCapture();
|
||||
headAngleCapture = null;
|
||||
const layer = new MenuLayer("Glanceboard settings", items(), pageMenuLayout(ctx.stack.getBaseSize().width));
|
||||
ctx.stack.push(layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Set to current head angle": measure the head's tilt from the glasses'
|
||||
* accelerometer, round it to the nearest 5°, store it as the Head tilt angle
|
||||
* and send it to the glasses. The row's value shows the result, or the
|
||||
* glasses' current trigger before the first use.
|
||||
* "Set to current head angle", in two selects: one with the head level, one
|
||||
* tilted up to where the display should wake (head-angle.ts). The row shows
|
||||
* the step or the last result; otherwise the glasses' current trigger. A
|
||||
* result is shown only while the Head tilt angle still has the value it was
|
||||
* shown with, and only until the menu is reopened.
|
||||
*/
|
||||
let headAngleCaptureStatus = "";
|
||||
let headAngleCapture: { status: string; angleSetting: string } | null = null;
|
||||
|
||||
function headAngleCaptureMenuItem(): MenuItem {
|
||||
const label = "Set to current head angle";
|
||||
const setStatus = (status: string) => {
|
||||
headAngleCapture = { status, angleSetting: glanceAngleSetting.get() };
|
||||
};
|
||||
return {
|
||||
label,
|
||||
description:
|
||||
"Tilt your head to where the display should wake, keep still, and select. " +
|
||||
"Faceclaw reads the glasses' angle for about a second, rounds it to the nearest 5°, and saves it as the Head tilt angle.",
|
||||
onSelect: async () => {
|
||||
headAngleCaptureStatus = "Measuring...";
|
||||
headAngleCaptureStatus = await setGlanceAngleFromHead();
|
||||
"Two steps. Look straight ahead, keep still and select; then tilt your head up to where the display should wake, keep still and select again. " +
|
||||
"Faceclaw reads the glasses' angle for about a second each time and saves the difference, rounded to 5°, as the Head tilt angle. Keep your head level side to side.",
|
||||
onSelect: async (ctx) => {
|
||||
// Selects during a measurement are ignored; it would share the IMU stream.
|
||||
if (headAngleCaptureRunning()) return;
|
||||
setStatus("Measuring...");
|
||||
ctx.actions.requestRender();
|
||||
const status = await captureHeadAngleStep();
|
||||
if (status !== null) setStatus(status);
|
||||
ctx.actions.requestRender();
|
||||
},
|
||||
render: ({ image, x, y, width }) => {
|
||||
const current = glassesHeadUpTrigger();
|
||||
const value = headAngleCaptureStatus || (current === null ? "" : current === 0 ? "glasses: off" : `glasses: ${current}°`);
|
||||
const status = getHeadUpStatus();
|
||||
syncGlanceAngleOriginal(status);
|
||||
let value: string;
|
||||
if (headAngleCapture && headAngleCapture.angleSetting === glanceAngleSetting.get() &&
|
||||
(headAngleCaptureRunning() || headAngleCaptureStep() === "tilt" || !headAngleCapture.status.startsWith("Now"))) {
|
||||
value = headAngleCapture.status;
|
||||
} else {
|
||||
const current = glassesHeadUpTrigger(status);
|
||||
value = current === null ? "" : current === 0 ? "glasses: off" : `glasses: ${current}°`;
|
||||
}
|
||||
drawRightValueMenuItem(image, getDefaultSmallFont(), x, y, width, label, value);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -44,8 +44,9 @@ export function glanceLayout(): GlanceLayout {
|
||||
|
||||
/**
|
||||
* Whether sleep-time gestures show the board at all. Off restores the plain
|
||||
* behaviour: a tap, hold or head-tilt while asleep does nothing (a head-tilt
|
||||
* wakes the regular UI), double-tap wakes.
|
||||
* behaviour: a tap or hold while asleep does nothing, a head-tilt wakes the
|
||||
* regular UI, double-tap wakes; and the head-up angle goes back to the glasses'
|
||||
* own.
|
||||
*/
|
||||
export const glanceboardEnabledSetting = new ConfigSettingBoolean({
|
||||
id: "glanceboard-enabled",
|
||||
@@ -61,9 +62,10 @@ export type GlanceTapDuration = "off" | "3s" | "5s" | "7s" | "10s";
|
||||
const DEFAULT_TAP_DURATION: GlanceTapDuration = "5s";
|
||||
|
||||
/**
|
||||
* How long a tap (or head-tilt) keeps the board up; each further tap restarts
|
||||
* it. "off" means a single tap does not show the board at all; a head-tilt
|
||||
* then uses the default duration.
|
||||
* How long a tap keeps the board up; each further tap restarts it. "off"
|
||||
* means a single tap does not show the board at all. A head-tilt showing
|
||||
* lasts until the head comes back down, falling back to this duration (the
|
||||
* default one when "off") where the head-down is unlikely to arrive.
|
||||
*/
|
||||
export const glanceTapDurationSetting = new ConfigSettingEnum<GlanceTapDuration>({
|
||||
id: "glanceboard-tap-duration",
|
||||
@@ -96,7 +98,7 @@ export const glanceShowOnLongPressSetting = new ConfigSettingBoolean({
|
||||
description: "A long-press or short-then-long-press while asleep shows the Glanceboard until the press is released.",
|
||||
});
|
||||
|
||||
/** The head-tilt wake shows the board (for the tap duration) instead of the regular UI. */
|
||||
/** The head-tilt wake shows the board (until the head comes back down) instead of the regular UI. */
|
||||
export const glanceShowOnHeadTiltSetting = new ConfigSettingBoolean({
|
||||
id: "glanceboard-show-on-head-tilt",
|
||||
label: "Show on head tilt",
|
||||
@@ -110,9 +112,10 @@ export type GlanceAngle = (typeof GLANCE_ANGLE_VALUES)[number];
|
||||
|
||||
/**
|
||||
* How far the head must tilt up for a head-tilt wake, as the glasses' own
|
||||
* pitch reading (degrees). "glasses" leaves whatever the glasses already have
|
||||
* (set by the Even app or its calibration). A number is written to the
|
||||
* glasses' head-up setting on every connection (glasses-controls.ts).
|
||||
* pitch reading (degrees). "glasses" keeps the glasses' own setting (from the
|
||||
* Even app), writing back their original values if Faceclaw changed them. A
|
||||
* number is written to the glasses' head-up setting on every connection while
|
||||
* the Glanceboard is enabled (head-angle.ts). Android only.
|
||||
*/
|
||||
export const glanceAngleSetting = new ConfigSettingEnum<GlanceAngle>({
|
||||
id: "glanceboard-head-tilt-angle",
|
||||
@@ -122,13 +125,17 @@ export const glanceAngleSetting = new ConfigSettingEnum<GlanceAngle>({
|
||||
values: GLANCE_ANGLE_VALUES,
|
||||
formatValue: (value) => (value === "glasses" ? "Glasses default" : `${value}°`),
|
||||
description:
|
||||
"How far you tilt your head up to wake the display. Glasses default keeps the angle already stored on the glasses.",
|
||||
"How far you tilt your head up to wake the display. Glasses default uses the glasses' own setting from the Even app. " +
|
||||
"The board hides when your head drops 20° below this angle; under 25°, looking straight ahead may not count, so it hides after the tap duration instead.",
|
||||
});
|
||||
|
||||
/** The trigger in degrees, or 0 when the glasses keep their own. */
|
||||
export function glanceAngleDegrees(): number {
|
||||
/**
|
||||
* The trigger Faceclaw should maintain, in degrees: the Head tilt angle while
|
||||
* the Glanceboard is enabled, else 0 (the glasses' own setting).
|
||||
*/
|
||||
export function glanceAngleTriggerDegrees(): number {
|
||||
const value = glanceAngleSetting.get();
|
||||
return value === "glasses" ? 0 : Number(value);
|
||||
return value === "glasses" || !glanceboardEnabledSetting.get() ? 0 : Number(value);
|
||||
}
|
||||
|
||||
const DEPTH_VALUES = ["-64", "-48", "-32", "-16", "0", "16", "32", "48", "64"] as const;
|
||||
|
||||
Reference in new issue
Block a user