mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 00:43:04 +00:00
layout viewer
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user