Skip to content

Commit

Permalink
Fixed config
Browse files Browse the repository at this point in the history
  • Loading branch information
fchorney committed Apr 4, 2024
1 parent 5172853 commit cf361ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions sdk/commands/enabled-sensors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ export class EnabledSensors extends StructBuffer<
return true;
}

override get byteLength() {
return 5;
}

override decode(view: DataView, littleEndian = false, offset = 0): Array<boolean>[] {
const decoded = twoEnabledSensors_t[this.count]
.decode(view, littleEndian, offset)
.flatMap<Array<boolean>>(splitTwoSensors);

// decoded now has a trailing entry for the 4 bits of padding on the end of data
// so we slice to just the desired data
return decoded.slice(0, 9);
Expand Down
4 changes: 3 additions & 1 deletion sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export async function getStageConfig(dev: HIDDevice) {
const encoded_config = smxconfig.encode();
if (encoded_config) {
const buf = new Uint8Array(encoded_config.buffer);
console.log("Same Thing:", response.slice(2, -1).toString() === buf.toString());
console.log("Config Encodes Correctly:", response.slice(2, -1).toString() === buf.toString());
}

console.log(smxconfig);
return smxconfig;
}

Expand Down
5 changes: 1 addition & 4 deletions sdk/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ export async function process_packets(dev: HIDDevice, responseType: number, debu
continue;
}

// Create the data buffer here so we can check for start flags and ACKs
const data_buffer = new Uint8Array(data.buffer);
if (responseType !== 121) {
console.log(data_buffer);
}

// If we see an ACK Command just ignore it and restart
if (data_buffer[0] === ACK_COMMAND) {
Expand All @@ -151,7 +149,6 @@ export async function process_packets(dev: HIDDevice, responseType: number, debu
}

if (!seenFirstPacket) {
console.log(responseType, current_packet[0]);
if (current_packet[0] === responseType) {
seenFirstPacket = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion ui/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const uiState = createStore();
/** backing atom of all known devices */
export const devices$ = atom<Record<number, HIDDevice | undefined>>({});

export const displayTestData$ = atom(true);
export const displayTestData$ = atom(false);

/** current p1 pad, derived from devices$ above */
export const p1Dev$ = atom<HIDDevice | undefined, [HIDDevice | undefined], void>(
Expand Down

0 comments on commit cf361ad

Please sign in to comment.