forked from Blendman974/faceclaw
Add initial voice-command support
Adds a single wakeword-style voice command, "screen on", and deals with all the wiring and permissions that entails. Currently this only supports using the phone's mic (or a bluetooth headset), not the G2 mic.
This commit is contained in:
1 parent
c4cb4f9f01
commit
9fbb985db6
35 files changed
+1722
-16
No files matched your search
@@ -25,6 +25,7 @@ import {
|
||||
loadScreenTimeoutSetting,
|
||||
loadSystemCardSettings,
|
||||
loadSystemCardName,
|
||||
loadVoiceControlEnabled,
|
||||
loadWakeModeSetting,
|
||||
nextScreenTimeoutSetting,
|
||||
nextWakeModeSetting,
|
||||
@@ -37,6 +38,7 @@ import {
|
||||
screenTimeoutMs,
|
||||
saveSystemCardSetting,
|
||||
saveSystemCardName,
|
||||
saveVoiceControlEnabled,
|
||||
wakeModeLabel,
|
||||
type DashboardSlotId,
|
||||
type NightscoutSettings,
|
||||
@@ -63,6 +65,7 @@ let dashboardState = {
|
||||
systemCardSettings: loadSystemCardSettings(),
|
||||
screenTimeout: loadScreenTimeoutSetting(),
|
||||
wakeMode: loadWakeModeSetting(),
|
||||
voiceControlEnabled: loadVoiceControlEnabled(),
|
||||
tiledWakePaintPending: false,
|
||||
nightscoutSettings: loadNightscoutSettings(),
|
||||
battery: {
|
||||
@@ -80,6 +83,7 @@ const dashboardActions: LayerActions = {
|
||||
startNightscoutSiteUrlEdit: () => {},
|
||||
startNightscoutApiTokenEdit: () => {},
|
||||
endTextSettingEdit: () => {},
|
||||
setVoiceControlEnabled: () => {},
|
||||
};
|
||||
const dashboardFont = loadEmbeddedTerminus12();
|
||||
const dashboardSystemFont = loadEmbeddedTerminus16();
|
||||
@@ -210,6 +214,14 @@ export function setDashboardSystemCardSetting(key: SystemCardSettingKey, value:
|
||||
saveSystemCardSetting(key, value);
|
||||
}
|
||||
|
||||
export function isDashboardVoiceControlEnabled(): boolean {
|
||||
return dashboardState.voiceControlEnabled;
|
||||
}
|
||||
|
||||
export function setDashboardVoiceControlEnabled(value: boolean): void {
|
||||
dashboardState.voiceControlEnabled = saveVoiceControlEnabled(value);
|
||||
}
|
||||
|
||||
export function applyDashboardScreenTimeout(nowMs = Date.now()): boolean {
|
||||
const timeoutMs = screenTimeoutMs(dashboardState.screenTimeout);
|
||||
if (timeoutMs === null || !dashboardState.screenOn) return false;
|
||||
@@ -511,6 +523,12 @@ function createSettingsMenuLayer(): MenuLayer {
|
||||
ctx.stack.push(createDashboardSettingsMenuLayer());
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Voice",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.push(createVoiceSettingsMenuLayer());
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Integrations",
|
||||
onSelect: (ctx) => {
|
||||
@@ -558,6 +576,24 @@ function setWakeMode(value: WakeModeSetting): void {
|
||||
dashboardState.wakeMode = saveWakeModeSetting(value);
|
||||
}
|
||||
|
||||
function createVoiceSettingsMenuLayer(): MenuLayer {
|
||||
return new MenuLayer(
|
||||
"Voice",
|
||||
[
|
||||
{
|
||||
label: "Enable",
|
||||
onSelect: async (ctx) => {
|
||||
await ctx.actions.setVoiceControlEnabled(!dashboardState.voiceControlEnabled);
|
||||
},
|
||||
render: ({ image, x, y, width, selected }) => {
|
||||
drawToggleMenuItem(image, dashboardFont, x, y, width, "Enable", dashboardState.voiceControlEnabled, selected);
|
||||
},
|
||||
},
|
||||
],
|
||||
TOP_LEFT_MENU_LAYOUT,
|
||||
);
|
||||
}
|
||||
|
||||
function createDashboardSettingsMenuLayer(): MenuLayer {
|
||||
return new MenuLayer(
|
||||
"Dashboard",
|
||||
|
||||
Reference in new issue
Block a user