forked from Blendman974/faceclaw
Add support for using RayNeo iO together with an R1 ring
This commit is contained in:
1 parent
dee60bbcd2
commit
fde847a31a
10 files changed
+172
-47
No files matched your search
@@ -4,7 +4,7 @@ import { type InputEvent } from "../../ui/gestures";
|
||||
import { Layer, type LayerContext } from "../../ui/layers";
|
||||
import { shell } from "../../ui/shell/shell";
|
||||
import { MenuLayer, type MenuItem } from "../../ui/menu";
|
||||
import { ringConnectionModeSetting } from "../../ui/dashboard-settings";
|
||||
import { effectiveRingConnectionMode, ringConnectionModeSetting } from "../../ui/dashboard-settings";
|
||||
import { loadDeviceAddresses } from "../../g2/device-addresses";
|
||||
import {
|
||||
getRingSessionStatus,
|
||||
@@ -146,7 +146,7 @@ export class RingStatusLayer implements Layer {
|
||||
}
|
||||
|
||||
if (!s.directEnabled) {
|
||||
const pending = ringConnectionModeSetting.get() !== "glasses";
|
||||
const pending = effectiveRingConnectionMode() !== "glasses";
|
||||
rows.push({ label: "Direct link", value: pending ? "on after glasses reconnect" : "off (only via glasses)", dim: true });
|
||||
} else {
|
||||
const state = s.directNotificationsReady ? "subscribed"
|
||||
|
||||
@@ -78,7 +78,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
|
||||
import { appViewportRect, isOnSwitcherEdge, screenHeight, screenWidth, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -1047,9 +1047,11 @@ class DashboardController {
|
||||
|
||||
/**
|
||||
* A Direct-mode session may have unpaired the R1 from the glasses (see
|
||||
* GlassesSessionRing.releaseRingFromGlassesLocked). The first session in
|
||||
* another mode asks the glasses to connect to it again; the ring's own
|
||||
* glasses targets were cleared, so it accepts them. Called on connect.
|
||||
* GlassesSessionRing.releaseRingFromGlassesLocked), and a RayNeo iO
|
||||
* session (always Direct) may have cleared the ring's glasses targets.
|
||||
* The first G2 session in another mode asks the glasses to connect to it
|
||||
* again; the ring's own glasses targets were cleared, so it accepts them.
|
||||
* Called on connect.
|
||||
*/
|
||||
private handRingBackToGlassesIfNeeded(): void {
|
||||
if (this.ringModeAtConnect === "direct" || !getBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, false)) return;
|
||||
@@ -1488,20 +1490,21 @@ class DashboardController {
|
||||
this.refreshEvenAppStatus();
|
||||
this.setPhase("connecting");
|
||||
this.setStatus("Connecting to the glasses...");
|
||||
// "Only via glasses" (the default) means the phone never opens its own
|
||||
// link to the ring: the glasses relay its gestures to us anyway. An empty
|
||||
// address disables every direct-ring code path in the communicator.
|
||||
const ringMode = ringConnectionModeSetting.get();
|
||||
// "Only via glasses" (the G2's default) means the phone never opens its
|
||||
// own link to the ring: the glasses relay its gestures to us anyway. An
|
||||
// empty address disables every direct-ring code path in the communicator.
|
||||
// A RayNeo iO (one link, its address in both arm slots) can't relay a
|
||||
// ring, so with one the phone always takes the ring directly.
|
||||
const ringMode = effectiveRingConnectionMode();
|
||||
this.ringModeAtConnect = ringMode;
|
||||
// A RayNeo iO is one link (its address in both arm slots) and has no ring.
|
||||
const glassesType = glassesTypeSetting.get();
|
||||
const ringAddress = ringMode !== "glasses" && glassesType === "g2" ? addresses.ring : "";
|
||||
const ringAddress = ringMode !== "glasses" ? addresses.ring : "";
|
||||
// Direct mode may unpair the ring from the glasses; remember to hand it
|
||||
// back once a later session runs in another mode.
|
||||
if (ringMode === "direct" && ringAddress) setBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, true);
|
||||
this.appendLog(glassesType === "rayneo-io"
|
||||
this.appendLog((glassesType === "rayneo-io"
|
||||
? `Using configured RayNeo iO: ${addresses.right}`
|
||||
: `Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
: `Using configured arms: R=${addresses.right} L=${addresses.left}`) + (ringAddress ? ` ring=${ringAddress}` : ""),
|
||||
);
|
||||
|
||||
let communicator: FaceclawCommunicatorBridge | null = null;
|
||||
|
||||
@@ -68,7 +68,7 @@ export class PairingViewModel extends Observable {
|
||||
private _ringRows: PairingRowItem[] = [];
|
||||
private selectedPair: GlassesPairCandidate | null = null;
|
||||
private selectedRing: RingCandidate | null = null;
|
||||
/** A RayNeo iO instead of a G2 pair (the two are exclusive). */
|
||||
/** A RayNeo iO instead of a G2 pair (the two are exclusive; either takes a ring). */
|
||||
private selectedIo: RayNeoCandidate | null = null;
|
||||
private readonly previouslyPairedSerial: string | null;
|
||||
private readonly previouslyPairedRing: string;
|
||||
@@ -186,7 +186,7 @@ export class PairingViewModel extends Observable {
|
||||
|
||||
get instructions(): string {
|
||||
return (
|
||||
"Select your G2 glasses and R1 ring, or your RayNeo iO, below. Wear the glasses or take them out of the case, " +
|
||||
"Select your G2 glasses or RayNeo iO, and your R1 ring if you have one, below. Wear the glasses or take them out of the case, " +
|
||||
"and keep the glasses and phone nearby. If your glasses are not detected, make sure no other " +
|
||||
"apps are connected."
|
||||
);
|
||||
@@ -298,10 +298,7 @@ export class PairingViewModel extends Observable {
|
||||
if (row.kind === "rayneo-io") {
|
||||
const io = this.aggregator.rayneos().find((candidate) => candidate.id === row.id) ?? null;
|
||||
this.selectedIo = this.selectedIo?.id === io?.id ? null : io;
|
||||
if (this.selectedIo) {
|
||||
this.selectedPair = null;
|
||||
this.selectedRing = null;
|
||||
}
|
||||
if (this.selectedIo) this.selectedPair = null;
|
||||
} else if (row.kind === "glasses") {
|
||||
const pair = this.aggregator.pairs().find((candidate) => candidate.id === row.id) ?? null;
|
||||
if (!pair) return;
|
||||
@@ -314,17 +311,24 @@ export class PairingViewModel extends Observable {
|
||||
} else {
|
||||
const ring = this.aggregator.rings().find((candidate) => candidate.id === row.id) ?? null;
|
||||
this.selectedRing = this.selectedRing?.id === ring?.id ? null : ring;
|
||||
if (this.selectedRing) this.selectedIo = null;
|
||||
}
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
onPrimaryTap(): void {
|
||||
const io = this.selectedIo;
|
||||
const pair = this.selectedPair;
|
||||
const ring = this.selectedRing;
|
||||
const existing = loadDeviceAddresses();
|
||||
// Glasses saved without a ring selected keep the ring paired before.
|
||||
const ringAddress = ring?.advertisement.address ?? existing.ring;
|
||||
const ringName = ring?.advertisement.name ??
|
||||
(ringAddress === existing.ring ? (loadPairedGlassesIdentity()?.ringName ?? "") : "");
|
||||
if (io) {
|
||||
// One link: the same address stands for both arms; no ring.
|
||||
// One link: the same address stands for both arms. The iO can't relay a
|
||||
// ring, so the session connects to it directly (Direct ring mode).
|
||||
const address = io.advertisement.address;
|
||||
saveDeviceAddresses({ right: address, left: address, ring: "" });
|
||||
saveDeviceAddresses({ right: address, left: address, ring: ringAddress });
|
||||
glassesTypeSetting.set("rayneo-io");
|
||||
savePairedGlassesIdentity({
|
||||
serial: io.advertisement.embeddedMac ?? address,
|
||||
@@ -332,8 +336,8 @@ export class PairingViewModel extends Observable {
|
||||
rightName: io.advertisement.name,
|
||||
leftAddress: address,
|
||||
rightAddress: address,
|
||||
ringName: "",
|
||||
ringAddress: "",
|
||||
ringName,
|
||||
ringAddress,
|
||||
pairedAtMs: Date.now(),
|
||||
});
|
||||
this.dispose();
|
||||
@@ -343,18 +347,15 @@ export class PairingViewModel extends Observable {
|
||||
finishOnboardingNavigation();
|
||||
return;
|
||||
}
|
||||
const pair = this.selectedPair;
|
||||
const ring = this.selectedRing;
|
||||
if (!pair && !ring) return;
|
||||
// refresh() drops a selection whose pair regressed below complete, but the
|
||||
// tap can race a prune: never fall back to previously stored addresses for
|
||||
// a missing arm — that silently welds together arms of two different pairs.
|
||||
if (pair && (!pair.left || !pair.right)) return;
|
||||
const existing = loadDeviceAddresses();
|
||||
const addresses = {
|
||||
right: pair ? pair.right!.address : existing.right,
|
||||
left: pair ? pair.left!.address : existing.left,
|
||||
ring: ring?.advertisement.address ?? existing.ring,
|
||||
ring: ringAddress,
|
||||
};
|
||||
saveDeviceAddresses(addresses);
|
||||
if (pair) glassesTypeSetting.set("g2");
|
||||
@@ -365,8 +366,8 @@ export class PairingViewModel extends Observable {
|
||||
rightName: pair.right!.name,
|
||||
leftAddress: pair.left!.address,
|
||||
rightAddress: pair.right!.address,
|
||||
ringName: ring?.advertisement.name ?? (addresses.ring === existing.ring ? (loadPairedGlassesIdentity()?.ringName ?? "") : ""),
|
||||
ringAddress: addresses.ring,
|
||||
ringName,
|
||||
ringAddress,
|
||||
pairedAtMs: Date.now(),
|
||||
});
|
||||
} else if (ring) {
|
||||
|
||||
@@ -874,9 +874,18 @@ export const ringConnectionModeSetting = new ConfigSettingEnum<RingConnectionMod
|
||||
formatValue: (value) =>
|
||||
value === "direct" ? "Direct to phone" : value === "health" ? "Via glasses + health sync" : "Only via glasses",
|
||||
description:
|
||||
"How the R1 ring reaches the phone. Only via glasses: the glasses relay the ring's gestures and the phone never connects to it. Via glasses + health sync: the same, plus the phone connects to the ring to sync health data. Direct to phone (experimental): the phone takes the ring over from the glasses and gets its gestures and battery itself; the glasses lose ring input. Health still syncs, but each sync (on opening Health, and at :01 and :31) pauses ring gestures for up to a minute while the phone briefly reconnects to the ring in its health role. Leaving Direct hands the ring back to the glasses. Takes effect on the next connection to the glasses.",
|
||||
"How the R1 ring reaches the phone. Only via glasses: the glasses relay the ring's gestures and the phone never connects to it. Via glasses + health sync: the same, plus the phone connects to the ring to sync health data. Direct to phone (experimental): the phone takes the ring over from the glasses and gets its gestures and battery itself; the glasses lose ring input. Health still syncs, but each sync (on opening Health, and at :01 and :31) pauses ring gestures for up to a minute while the phone briefly reconnects to the ring in its health role. Leaving Direct hands the ring back to the glasses. A RayNeo iO has no ring link of its own, so with one the phone always connects to the ring directly. Takes effect on the next connection to the glasses.",
|
||||
});
|
||||
|
||||
/**
|
||||
* The ring connection in effect: the setting with G2 glasses; Direct with a
|
||||
* RayNeo iO, which cannot relay a ring, so the phone holds the ring's
|
||||
* glasses role itself (gestures, battery; health in brief phone-role windows).
|
||||
*/
|
||||
export function effectiveRingConnectionMode(): RingConnectionMode {
|
||||
return glassesTypeSetting.get() === "rayneo-io" ? "direct" : ringConnectionModeSetting.get();
|
||||
}
|
||||
|
||||
// "whisper" (no "onboard-" prefix) is OpenAI's CLOUD realtime model
|
||||
// (gpt-realtime-whisper); "onboard-whisper" is the on-device sherpa-onnx
|
||||
// Whisper backend. Same underlying model family, two different places it
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
previewScalingSetting,
|
||||
phoneRotationSetting,
|
||||
ringConnectionModeSetting,
|
||||
glassesTypeSetting,
|
||||
sonioxApiKeySetting,
|
||||
saveTranscribeAudioSetting,
|
||||
whisperServerApiKeySetting,
|
||||
@@ -224,7 +225,7 @@ function settingsSections(): SettingsSection[] {
|
||||
items: [
|
||||
// Whether and how the phone opens its own BLE link to the R1 ring.
|
||||
// Applied at connect time.
|
||||
enumSettingMenuItem(ringConnectionModeSetting),
|
||||
ringConnectionMenuItem(),
|
||||
toggleSettingMenuItem(saveVoiceRecordingsSetting),
|
||||
toggleSettingMenuItem(firmwareDebugFlagsSetting),
|
||||
toggleSettingMenuItem(suspendEvenHubWhenScreenOffSetting),
|
||||
@@ -598,6 +599,24 @@ function readBundledDoc(fileName: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Developer > Ring connection: the setting, except with a RayNeo iO, which
|
||||
* always takes the ring directly (effectiveRingConnectionMode): then a fixed,
|
||||
* disabled "Direct" row, the stored choice kept for G2 glasses.
|
||||
*/
|
||||
function ringConnectionMenuItem(): MenuItem {
|
||||
const item = enumSettingMenuItem(ringConnectionModeSetting);
|
||||
const io = () => glassesTypeSetting.get() === "rayneo-io";
|
||||
return {
|
||||
...item,
|
||||
disabled: io,
|
||||
render: (args) => {
|
||||
if (!io()) return item.render?.(args);
|
||||
drawRightValueMenuItem(args.image, getDefaultSmallFont(), args.x, args.y, args.width, item.label, "Direct (RayNeo iO)");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function renderWatchStatus(args: { image: GrayImage; x: number; y: number; width: number }): number {
|
||||
const { image, x, y, width } = args;
|
||||
const font = getDefaultSmallFont();
|
||||
|
||||
Reference in new issue
Block a user