-
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.
- Loading branch information
Showing
9 changed files
with
149 additions
and
22 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
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,46 @@ | ||
import cn from "classnames"; | ||
import type { SMXPanelTestData } from "../../sdk/commands/sensor_test"; | ||
|
||
interface EnabledProps { | ||
data: SMXPanelTestData; | ||
} | ||
|
||
export function FsrPanel(props: EnabledProps) { | ||
const { bad_sensor_input, have_data_from_panel, sensor_level } = props.data; | ||
return ( | ||
<div className={cn("panel", { active: have_data_from_panel })}> | ||
<Fsr | ||
className="top horiz" | ||
badInput={!bad_sensor_input.up} | ||
value={sensor_level.up} | ||
/> | ||
<Fsr | ||
className="right vert" | ||
badInput={!bad_sensor_input.right} | ||
value={sensor_level.right} | ||
/> | ||
<Fsr | ||
className="bottom horiz" | ||
badInput={!bad_sensor_input.down} | ||
value={sensor_level.down} | ||
/> | ||
<Fsr | ||
className="left vert" | ||
badInput={!bad_sensor_input.left} | ||
value={sensor_level.left} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
function Fsr({ | ||
className, | ||
badInput, | ||
value, | ||
}: { | ||
className?: string; | ||
badInput: boolean; | ||
value: number; | ||
}) { | ||
return <div className={cn("fsr", className)}>{badInput ? "!!" : value}</div>; | ||
} |
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 { useEffect, useState } from "react"; | ||
import type { SMXSensorTestData } from "../../sdk/commands/sensor_test"; | ||
import { requestTestData } from "../pad-coms"; | ||
import { FsrPanel } from "./fsr-panel"; | ||
|
||
export function StageTest({ | ||
deviceAtom, | ||
}: { | ||
deviceAtom: Atom<HIDDevice | undefined>; | ||
}) { | ||
const device = useAtomValue(deviceAtom); | ||
const [testData, setTestData] = useState<SMXSensorTestData>(); | ||
|
||
useEffect(() => { | ||
if (!device) { | ||
return; | ||
} | ||
|
||
const handle = requestAnimationFrame(async () => { | ||
const data = await requestTestData(device); | ||
setTestData(data); | ||
}); | ||
|
||
return () => cancelAnimationFrame(handle); | ||
}, [device]); | ||
|
||
if (!testData) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="pad"> | ||
{Object.entries(testData.panels).map(([key, data]) => ( | ||
<FsrPanel key={key} data={data} /> | ||
))} | ||
</div> | ||
); | ||
} |
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