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 b3c0938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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
6 changes: 4 additions & 2 deletions ui/stage/stage-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ function useTestData(device: HIDDevice | undefined) {
const d = device;
async function update() {
const data = await requestTestData(d);
setTestData(data);
handle = requestAnimationFrame(update);
if (data) {
setTestData(data);
handle = requestAnimationFrame(update);
}
}

let handle = setInterval(update, 50);
Expand Down

0 comments on commit b3c0938

Please sign in to comment.