Glanceboard: Head tilt timeout setting

How long a head-tilt showing may last when no head-down arrives: 60 s
(the default, as before), 30, 15, 10 s, or never (it then stays until the
head comes down or a double-tap). Where the head-down is unlikely, the tap
duration still applies when it is shorter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
BrendenandClaude Opus 5.5 committed 2026-11-06 12:47:46 -08:00
1 parent b1ca8b8ca1
commit 58626ce146
8 files changed
+86 -25

No files matched your search

+2
View File
@@ -50,6 +50,8 @@ export type GlanceboardProvider = {
showOnTap: () => boolean;
/** How long a tap keeps the board up (and a head-tilt, when its head-down is unlikely to come). */
tapTimeoutMs: () => number;
/** How long a head-tilt showing may last without a head-down (null = no limit). */
tiltTimeoutMs: () => number | null;
/** Whether a long-press holds the board up until released. */
showOnLongPress: () => boolean;
/** Whether the head-tilt wake goes to the board rather than the regular UI. */
+2
View File
@@ -30,6 +30,7 @@ import {
glanceShowLinesSetting,
glanceAngleSetting,
glanceShowOnHeadTiltSetting,
glanceTiltTimeoutSetting,
glanceShowOnLongPressSetting,
glanceSlotChoiceLabel,
glanceSlotSettings,
@@ -322,6 +323,7 @@ function openGlanceSettings(ctx: LayerContext): void {
enumSettingMenuItem(glanceTapDurationSetting),
toggleSettingMenuItem(glanceShowOnLongPressSetting),
toggleSettingMenuItem(glanceShowOnHeadTiltSetting),
enumSettingMenuItem(glanceTiltTimeoutSetting),
// 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()] : []),
@@ -107,6 +107,31 @@ export const glanceShowOnHeadTiltSetting = new ConfigSettingBoolean({
description: "Tilting your head up while asleep shows the Glanceboard instead of waking the regular UI. It stays up until you look back down.",
});
export type GlanceTiltTimeout = "60s" | "30s" | "15s" | "10s" | "never";
/**
* How long a head-tilt showing may last if the head-down never comes (the
* board normally hides when the head comes back down). "never" removes the
* limit; a double-tap still dismisses the board.
*/
export const glanceTiltTimeoutSetting = new ConfigSettingEnum<GlanceTiltTimeout>({
id: "glanceboard-head-tilt-timeout",
label: "Head tilt timeout",
storageKey: "glanceboard.headTiltTimeout",
defaultValue: "60s",
values: ["60s", "30s", "15s", "10s", "never"],
formatValue: (value) => (value === "never" ? "Never" : value.replace("s", " s")),
description:
"The longest a head-tilt keeps the Glanceboard up when looking back down is not detected. Never: it stays until you look down or double-tap. " +
"When looking down is unlikely to register (a low Head tilt angle, or the display was suspended), the tap duration applies if shorter.",
});
/** The Head tilt timeout in ms, or null for none. */
export function glanceTiltTimeoutMs(): number | null {
const value = glanceTiltTimeoutSetting.get();
return value === "never" ? null : Number.parseInt(value, 10) * 1000;
}
const GLANCE_ANGLE_VALUES = ["glasses", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60"] as const;
export type GlanceAngle = (typeof GLANCE_ANGLE_VALUES)[number];
+2
View File
@@ -9,6 +9,7 @@ import {
glanceShowOnLongPressSetting,
glanceShowOnTap,
glanceTapTimeoutMs,
glanceTiltTimeoutMs,
} from "./glanceboard-settings";
const glanceboardApp: AppDefinition = {
@@ -24,6 +25,7 @@ const glanceboardApp: AppDefinition = {
isEnabled: () => glanceboardEnabledSetting.get(),
showOnTap: glanceShowOnTap,
tapTimeoutMs: glanceTapTimeoutMs,
tiltTimeoutMs: glanceTiltTimeoutMs,
showOnLongPress: () => glanceShowOnLongPressSetting.get(),
showOnHeadTilt: () => glanceShowOnHeadTiltSetting.get(),
depth: glanceDepth,
+2 -1
View File
@@ -22,7 +22,7 @@ import { openEvenAppSettings, readEvenAppNotificationState } from "../native/eve
import { defaultRingName, setGlassesRingLink } from "../native/ring-status";
import { applyGlanceAngle, glassesHeadUpTrigger, syncGlanceAngleOriginal } from "./head-angle";
import { glanceAngleTriggerDegrees, glanceTapTimeoutMs } from "../apps/glanceboard/glanceboard-settings";
import { glanceTiltMaxMs } from "./glance-state";
import { GLANCE_TILT_MAX_MS, glanceTiltMaxMs } from "./glance-state";
import { getBooleanSetting, setBooleanSetting } from "../native/settings-store";
import { grayImageToPreviewSource } from "../native/gray-image-preview";
import { firmwareIncompatibilityMessage, hasCompatibleFirmware } from "./firmware-compat";
@@ -2542,6 +2542,7 @@ class DashboardController {
const glanceEvent = this.glance.eventForGesture("head-tilt");
if (glanceEvent?.type !== "tilt") return glanceEvent;
const maxMs = glanceTiltMaxMs({
capMs: glanceEvent.maxMs === undefined ? GLANCE_TILT_MAX_MS : glanceEvent.maxMs,
resumedSession: this.evenHubSessionSuspended || this.evenHubResumePromise !== null,
triggerDegrees: glassesHeadUpTrigger() ?? (glanceAngleTriggerDegrees() || null),
tapTimeoutMs: glanceTapTimeoutMs(),
+2 -1
View File
@@ -92,7 +92,8 @@ export class GlanceHost {
if (gesture === "click" && !provider.showOnTap()) return null;
if ((gesture === "long-press" || gesture === "short-then-long-press") && !provider.showOnLongPress()) return null;
if (gesture === "head-tilt" && !provider.showOnHeadTilt()) return null;
return glanceEventForGesture(gesture, this.isVisible());
const event = glanceEventForGesture(gesture, this.isVisible());
return event?.type === "tilt" ? { type: "tilt", maxMs: provider.tiltTimeoutMs() } : event;
}
/**
+32 -17
View File
@@ -15,9 +15,10 @@
export const GLANCE_TIMEOUT_MS = 3000;
/**
* Safety cap for a head-tilt showing: the board normally stays up until the
* Default cap for a head-tilt showing: the board normally stays up until the
* head comes back down (as the stock dashboard does), but a lost head-down
* event must not leave it on forever.
* event should not leave it on indefinitely. The user's Head tilt timeout
* setting replaces it (and may remove it).
*/
export const GLANCE_TILT_MAX_MS = 60_000;
@@ -29,17 +30,24 @@ export const GLANCE_TILT_MAX_MS = 60_000;
export const GLANCE_LOW_TILT_TRIGGER_DEGREES = 25;
/**
* How long a head-tilt showing may last without a head-down. The full cap,
* except when the head-down is unlikely to arrive, where the tap duration is
* used instead: a tilt that woke a suspended EvenHub session (the head-down
* is only forwarded once the page is back, so a quick glance can end before
* that), or a trigger too low for a level gaze to count as looking down.
* triggerDegrees is the glasses' trigger, or null when not known.
* How long a head-tilt showing may last without a head-down: capMs (the Head
* tilt timeout; null = no limit), except when the head-down is unlikely to
* arrive, where the tap duration is used if shorter: a tilt that woke a
* suspended EvenHub session (the head-down is only forwarded once the page is
* back, so a quick glance can end before that), or a trigger too low for a
* level gaze to count as looking down. triggerDegrees is the glasses'
* trigger, or null when not known.
*/
export function glanceTiltMaxMs(options: { resumedSession: boolean; triggerDegrees: number | null; tapTimeoutMs: number }): number {
export function glanceTiltMaxMs(options: {
capMs: number | null;
resumedSession: boolean;
triggerDegrees: number | null;
tapTimeoutMs: number;
}): number | null {
const lowTrigger =
options.triggerDegrees !== null && options.triggerDegrees > 0 && options.triggerDegrees < GLANCE_LOW_TILT_TRIGGER_DEGREES;
return options.resumedSession || lowTrigger ? options.tapTimeoutMs : GLANCE_TILT_MAX_MS;
if (!options.resumedSession && !lowTrigger) return options.capMs;
return options.capMs === null ? options.tapTimeoutMs : Math.min(options.capMs, options.tapTimeoutMs);
}
export type GlanceState = {
@@ -51,8 +59,8 @@ export type GlanceState = {
* the head back down (or tiltMaxMs passes).
*/
tilted: boolean;
/** The current head-tilt's cap (0 when not tilted); a hold ending mid-tilt re-arms it. */
tiltMaxMs: number;
/** The current head-tilt's cap (0 when not tilted, null for none); a hold ending mid-tilt re-arms it. */
tiltMaxMs: number | null;
/** When the board hides on its own (epoch ms), or null while held / hidden. */
hideAtMs: number | null;
};
@@ -60,8 +68,11 @@ export type GlanceState = {
export type GlanceEvent =
/** Single tap: show, and (re)start the auto-hide timer. */
| { type: "press" }
/** Head-tilt (IMU head-up): show until the head comes back down, or maxMs (default GLANCE_TILT_MAX_MS). */
| { type: "tilt"; maxMs?: number }
/**
* Head-tilt (IMU head-up): show until the head comes back down, or until
* maxMs passes (default GLANCE_TILT_MAX_MS; null = no limit).
*/
| { type: "tilt"; maxMs?: number | null }
/** The IMU reported the head back down: ends a head-tilt showing. */
| { type: "head-down" }
/** Long-press: show and keep showing until the release. */
@@ -87,8 +98,8 @@ export function reduceGlance(
if (state.holding || state.tilted) return state;
return { visible: true, holding: false, tilted: false, tiltMaxMs: 0, hideAtMs: nowMs + timeoutMs };
case "tilt": {
const maxMs = event.maxMs ?? GLANCE_TILT_MAX_MS;
return { visible: true, holding: state.holding, tilted: true, tiltMaxMs: maxMs, hideAtMs: state.holding ? null : nowMs + maxMs };
const maxMs = event.maxMs === undefined ? GLANCE_TILT_MAX_MS : event.maxMs;
return { visible: true, holding: state.holding, tilted: true, tiltMaxMs: maxMs, hideAtMs: state.holding ? null : tiltHideAt(nowMs, maxMs) };
}
case "head-down":
// Only a head-tilt showing ends with the head; a tap's timer or a hold keeps running.
@@ -101,7 +112,7 @@ export function reduceGlance(
if (!state.holding) return state;
// Head still up: the board stays, as if the tilt had just shown it.
return state.tilted
? { visible: true, holding: false, tilted: true, tiltMaxMs: state.tiltMaxMs, hideAtMs: nowMs + state.tiltMaxMs }
? { visible: true, holding: false, tilted: true, tiltMaxMs: state.tiltMaxMs, hideAtMs: tiltHideAt(nowMs, state.tiltMaxMs) }
: GLANCE_HIDDEN;
case "timeout":
if (!state.visible || state.holding || state.hideAtMs === null || nowMs < state.hideAtMs) return state;
@@ -111,6 +122,10 @@ export function reduceGlance(
}
}
function tiltHideAt(nowMs: number, maxMs: number | null): number | null {
return maxMs === null ? null : nowMs + maxMs;
}
/**
* Which glance event, if any, a shell input gesture means while the screen is
* off. A double-tap only concerns the board while it is showing (it then
+19 -6
View File
@@ -106,11 +106,24 @@ test("a tilt with a shorter cap keeps it, also across a hold", () => {
assert.equal(reduceGlance(held, { type: "release" }, T0 + 1000).hideAtMs, T0 + 1000 + 5000);
});
test("the tilt cap falls back to the tap duration where the head-down is unlikely", () => {
test("the tilt cap is the Head tilt timeout, or the tap duration if shorter where the head-down is unlikely", () => {
const tapTimeoutMs = 5000;
assert.equal(glanceTiltMaxMs({ resumedSession: false, triggerDegrees: 30, tapTimeoutMs }), GLANCE_TILT_MAX_MS);
assert.equal(glanceTiltMaxMs({ resumedSession: false, triggerDegrees: null, tapTimeoutMs }), GLANCE_TILT_MAX_MS);
assert.equal(glanceTiltMaxMs({ resumedSession: true, triggerDegrees: 30, tapTimeoutMs }), tapTimeoutMs);
assert.equal(glanceTiltMaxMs({ resumedSession: false, triggerDegrees: 20, tapTimeoutMs }), tapTimeoutMs);
assert.equal(glanceTiltMaxMs({ resumedSession: false, triggerDegrees: 25, tapTimeoutMs }), GLANCE_TILT_MAX_MS);
const cap = (capMs, resumedSession, triggerDegrees) => glanceTiltMaxMs({ capMs, resumedSession, triggerDegrees, tapTimeoutMs });
assert.equal(cap(60_000, false, 30), 60_000);
assert.equal(cap(15_000, false, null), 15_000);
assert.equal(cap(null, false, 30), null);
assert.equal(cap(60_000, true, 30), tapTimeoutMs);
assert.equal(cap(60_000, false, 20), tapTimeoutMs);
assert.equal(cap(null, false, 20), tapTimeoutMs);
assert.equal(cap(3000, true, 30), 3000);
assert.equal(cap(60_000, false, 25), 60_000);
});
test("a tilt with no timeout stays until the head-down, also across a hold", () => {
const up = reduceGlance(GLANCE_HIDDEN, { type: "tilt", maxMs: null }, T0);
assert.equal(up.hideAtMs, null);
assert.equal(reduceGlance(up, { type: "timeout" }, T0 + 3_600_000), up);
const held = reduceGlance(up, { type: "hold" }, T0 + 100);
assert.equal(reduceGlance(held, { type: "release" }, T0 + 1000).hideAtMs, null);
assert.deepEqual(reduceGlance(up, { type: "head-down" }, T0 + 9000), GLANCE_HIDDEN);
});