layout viewer

This commit is contained in:
2023-07-07 02:43:02 +02:00
parent 8ae383d260
commit fd50914ae7
5 changed files with 173 additions and 34 deletions

View File

@@ -10,6 +10,9 @@ export const serialLog = writable([])
/** @type {import('svelte/store').Writable<Array<{actions: number[]; phrase: string}>>} */
export const chords = writable([])
/** @type {import('svelte/store').Writable<[number[], number[], number[]]>} */
export const layout = writable([[], [], []])
/** @type {import('svelte/store').Writable<boolean>} */
export const syncing = writable(false)
@@ -21,6 +24,14 @@ export async function initSerial() {
device ??= new CharaDevice()
serialPort.set(device)
const parsedLayout = [[], [], []]
for (let layer = 1; layer <= 3; layer++) {
for (let i = 0; i < 90; i++) {
parsedLayout[layer - 1][i] = await device.getLayoutKey(layer, i)
}
}
layout.set(parsedLayout)
const chordCount = await device.getChordCount()
const chordInfo = []
for (let i = 0; i < chordCount; i++) {

View File

@@ -179,4 +179,15 @@ export class CharaDevice {
unk: Number(b),
}
}
/**
* @param layer {number}
* @param id {number}
* @returns {Promise<number>}
*/
async getLayoutKey(layer, id) {
const layout = await this.send(`VAR B3 A${layer} ${id}`)
const [position] = layout.split(" ").map(Number)
return position
}
}