forked from Blendman974/faceclaw
- Head tilt angle setting (Glanceboard): sets the glasses' own head-up trigger through the stock settings message (g2_setting.proto DeviceReceiveInfoFromAPP.deviceReceiveHeadUpSetting), so detection stays on the glasses and nothing streams while the screen is off. The stored calibration is read back and compensated for, and the value is re-applied on every connect. "glasses" (the default) leaves the glasses' setting untouched. - "Set to current head angle" measures the tilt from a ~1.2 s IMU burst and rounds it to the nearest 5 degrees. - Glance down to hide: a head-tilt showing now stays up until the head comes back down (HEAD_DOWN, forwarded by Faceclaw/38) instead of a fixed timeout, with a 60 s safety cap. HEAD_DOWN goes only to the Glanceboard on Android and iOS, so it never counts as shell activity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
declare const com: any;
|
|
|
|
/**
|
|
* Head-up (look-up wake) trigger on the active glasses session
|
|
* (GlassesSessionCore.setHeadUpTrigger / getHeadUpStatus). Android only for
|
|
* now: on iOS, or with no session, the setter does nothing and the getter
|
|
* returns null.
|
|
*/
|
|
|
|
/** GlassesSessionCore.getHeadUpStatus. switch -1 = not read on this connection. */
|
|
export type HeadUpStatus = {
|
|
switch: number;
|
|
angle: number;
|
|
calibration: number;
|
|
/** The trigger Faceclaw is maintaining, or -1 when it leaves the glasses' own setting. */
|
|
desired: number;
|
|
readAgeMs: number;
|
|
};
|
|
|
|
function activeCommunicator(): any {
|
|
if (!global.isAndroid) return null;
|
|
try {
|
|
return com.faceclaw.app.FaceclawBleCommunicator.getActive();
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/** Ask the session to keep the head-up trigger at `degrees` (1..90); 0 stops managing it. */
|
|
export function setHeadUpTrigger(degrees: number): boolean {
|
|
const active = activeCommunicator();
|
|
if (!active) return false;
|
|
try {
|
|
active.setHeadUpTrigger(Math.round(degrees));
|
|
return true;
|
|
} catch (error) {
|
|
console.warn(`setHeadUpTrigger failed: ${error}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getHeadUpStatus(): HeadUpStatus | null {
|
|
const active = activeCommunicator();
|
|
if (!active) return null;
|
|
try {
|
|
return JSON.parse(String(active.getHeadUpStatus())) as HeadUpStatus;
|
|
} catch (error) {
|
|
console.warn(`getHeadUpStatus failed: ${error}`);
|
|
return null;
|
|
}
|
|
}
|