-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into nm/struct-buffer-6
- Loading branch information
Showing
21 changed files
with
1,897 additions
and
1,702 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[tools] | ||
node = "22.9" | ||
node = "22.13" |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-4.5.0.cjs | ||
yarnPath: .yarn/releases/yarn-4.6.0.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useAtomValue, type Atom } from "jotai"; | ||
import type { SMXStage } from "../../sdk"; | ||
import { useConfig } from "./hooks"; | ||
|
||
export function ConfigValues(props: { stageAtom: Atom<SMXStage | undefined> }) { | ||
const stage = useAtomValue(props.stageAtom); | ||
const config = useConfig(stage); | ||
|
||
const ranges = config?.enabledSensors.flatMap((panel, idx) => { | ||
if (!panel.some((sensor) => sensor)) { | ||
return []; // skip panels will all disabled sensors | ||
} | ||
|
||
const { fsrHighThreshold: highs, fsrLowThreshold: lows } = config.panelSettings[idx]; | ||
|
||
return { | ||
idx, | ||
lows, | ||
highs, | ||
}; | ||
}); | ||
|
||
if (!ranges) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<h3>Sensitivity settings</h3> | ||
<ul> | ||
{ranges.map((range) => ( | ||
<li key={range.idx}> | ||
Panel {range.idx + 1}: {range.lows[0]} - {range.highs[0]} | ||
</li> | ||
))} | ||
</ul> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { useAtomValue } from "jotai"; | ||
import { useState, useEffect, useRef } from "react"; | ||
import { type SMXStage, type SMXSensorTestData, SensorTestMode } from "../../sdk"; | ||
import { displayTestData$ } from "../state"; | ||
|
||
// UI Update Rate in Milliseconds | ||
const UI_UPDATE_RATE = 50; | ||
|
||
export function useInputState(stage: SMXStage | undefined) { | ||
const readTestData = useAtomValue(displayTestData$); | ||
const [panelStates, setPanelStates] = useState<Array<boolean> | null>(); | ||
useEffect(() => { | ||
return stage?.inputState$.throttle(UI_UPDATE_RATE).onValue(setPanelStates); | ||
}, [stage]); | ||
return panelStates; | ||
} | ||
|
||
export function useTestData(stage: SMXStage | undefined) { | ||
const testDataMode = useAtomValue(displayTestData$); | ||
const [testData, setTestData] = useState<SMXSensorTestData | null>(null); | ||
|
||
// request updates on an interval | ||
useEffect(() => { | ||
if (!stage || !testDataMode) { | ||
return; | ||
} | ||
let testMode = SensorTestMode.UncalibratedValues; | ||
switch (testDataMode) { | ||
case "calibrated": | ||
testMode = SensorTestMode.CalibratedValues; | ||
break; | ||
case "noise": | ||
testMode = SensorTestMode.Noise; | ||
break; | ||
case "tare": | ||
testMode = SensorTestMode.Tare; | ||
} | ||
const handle = setInterval(() => stage.updateTestData(testMode), UI_UPDATE_RATE); | ||
return () => clearInterval(handle); | ||
}, [stage, testDataMode]); | ||
|
||
// ingest responses and display in UI | ||
useEffect(() => { | ||
return stage?.testDataResponse$.onValue(setTestData); | ||
}, [stage]); | ||
|
||
return testData; | ||
} | ||
|
||
export function useConfig(stage: SMXStage | undefined) { | ||
const stageRef = useRef(stage); | ||
const [configData, setConfig] = useState(stage?.config); | ||
|
||
useEffect(() => { | ||
if (stageRef.current !== stage) { | ||
// detected the stage has changed, so keep the config in sync | ||
setConfig(stage?.config); | ||
stageRef.current = stage; | ||
} | ||
}, [stage]); | ||
|
||
useEffect(() => { | ||
return stage?.configResponse$.onValue((config) => setConfig(config.config)); | ||
}, [stage]); | ||
|
||
return configData; | ||
} |
Oops, something went wrong.