diff --git a/src/lib/serial/device.ts b/src/lib/serial/device.ts index f40f11c6..b314ec4a 100644 --- a/src/lib/serial/device.ts +++ b/src/lib/serial/device.ts @@ -230,7 +230,7 @@ export class CharaDevice { * To permanently store the settings, you *must* call commit. */ async setSetting(id: number, value: number) { - const [status] = await this.send(`VAR B2 ${id.toString(16).padStart(2, "0").toUpperCase()} ${value}`) + const [status] = await this.send(`VAR B2 ${id} ${value}`) if (status !== "0") throw new Error(`Failed with status ${status}`) } @@ -238,7 +238,7 @@ export class CharaDevice { * Retrieves a setting from the device */ async getSetting(id: number): Promise { - const [value, status] = await this.send(`VAR B1 ${id.toString(16).padStart(2, "0").toUpperCase()}`) + const [value, status] = await this.send(`VAR B1 ${id}`) if (status !== "0") throw new Error(`Setting "${id}" doesn't exist (Status code ${status})`) return Number(value) } diff --git a/src/lib/setting.ts b/src/lib/setting.ts new file mode 100644 index 00000000..42b9eb2a --- /dev/null +++ b/src/lib/setting.ts @@ -0,0 +1,35 @@ +import type {Action} from "svelte/action" +import {serialPort} from "$lib/serial/connection" + +export const setting: Action = function ( + node: HTMLInputElement, + {id, inverse, scale}, +) { + node.setAttribute("disabled", "") + + const unsubscribe = serialPort.subscribe(async port => { + if (port) { + const type = node.getAttribute("type") as "number" | "checkbox" + if (type === "number") { + const value = Number(await port.getSetting(id).then(it => it.toString())) + node.value = ( + inverse !== undefined ? inverse / value : scale !== undefined ? scale * value : value + ).toString() + } else { + node.checked = await port.getSetting(id).then(it => it !== 0) + } + node.removeAttribute("disabled") + } else { + node.setAttribute("disabled", "") + } + }) + function listener() {} + node.addEventListener("input", listener) + + return { + destroy() { + node.removeEventListener("input", listener) + unsubscribe() + }, + } +} diff --git a/src/lib/tooltip.ts b/src/lib/tooltip.ts index f689f2b4..c54bfcda 100644 --- a/src/lib/tooltip.ts +++ b/src/lib/tooltip.ts @@ -2,7 +2,7 @@ import type {Action} from "svelte/action" import tippy from "tippy.js" import type {Props} from "tippy.js" -export const tooltip: Action = function (node, props?: Partial) { +export const tooltip: Action> = function (node, props) { const instance = tippy(node, props) return { diff --git a/src/routes/config/settings/+page.svelte b/src/routes/config/settings/+page.svelte index 07bfacc6..daf5b101 100644 --- a/src/routes/config/settings/+page.svelte +++ b/src/routes/config/settings/+page.svelte @@ -1,11 +1,12 @@ {#if $serialPort}
- +

"Chording only" mode which tells your device to output chords on a press rather than a press & release. It also enables you to jump from one chord to another without releasing everything and can be @@ -16,57 +17,85 @@

Spurring is toggled by chording both of the 'mirror' keys together.

- +

A quick, single key press and release used to indicate a suffix, prefix, or modifier to be associated with a chord.

- -
- -
- - - - - - -
- -
- - - - - -
- -
- +
+ +
+ + {#if $serialPort.device === "LITE"} + + {/if} + + + +
+ +
+ + + + + +
+ +
+ + Detection Tolerancems - + +
- - + + @@ -118,6 +148,11 @@ border: 1px solid var(--md-sys-color-outline); border-radius: 24px; + &:has(> legend input:not(:checked)) > :not(legend) { + pointer-events: none; + opacity: 0.7; + } + > label { display: flex; gap: 16px;