Skip to content

Commit

Permalink
Only try to read test data if it's actual test data
Browse files Browse the repository at this point in the history
  • Loading branch information
fchorney committed Apr 2, 2024
1 parent d3d5588 commit 1f1a5a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ui/pad-coms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDeviceInfo, getSensorTestData, getStageConfig } from "../sdk";
import { SMX_USB_PRODUCT_ID, SMX_USB_VENDOR_ID } from "../sdk/api";
import { API_COMMAND, SMX_USB_PRODUCT_ID, SMX_USB_VENDOR_ID } from "../sdk/api";
import { SMXConfig } from "../sdk/commands/config";
import { SMXDeviceInfo } from "../sdk/commands/data_info";
import { SMXSensorTestData } from "../sdk/commands/sensor_test";
Expand Down Expand Up @@ -75,6 +75,9 @@ export async function requestConfig(dev: HIDDevice) {

export async function requestTestData(dev: HIDDevice) {
const response = await getSensorTestData(dev);
if (response[0] !== API_COMMAND.GET_SENSOR_TEST_DATA) {
return null;
}
return new SMXSensorTestData(response);
}

Expand Down
4 changes: 3 additions & 1 deletion ui/stage/stage-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function useTestData(device: HIDDevice | undefined) {
const d = device;
async function update() {
const data = await requestTestData(d);
setTestData(data);
if (data) {
setTestData(data);
}
handle = requestAnimationFrame(update);
}

Expand Down

0 comments on commit 1f1a5a3

Please sign in to comment.