feat: settings readout

This commit is contained in:
2023-07-25 19:42:18 +02:00
parent 2130b6c7b9
commit 06c1121983
4 changed files with 104 additions and 34 deletions

View File

@@ -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<number> {
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)
}