Skip to content

Commit

Permalink
Add checkbox for panel test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
noahm committed May 16, 2024
1 parent 1344e65 commit e29f207
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sdk/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const API_COMMAND = {
};

export enum PanelTestMode {
/** 48 represents the char "0" **/
/** 48 represents the char "0" */
Off = 48,
/** 49 represents the char "1" **/
/** 49 represents the char "1" */
PressureTest = 49,
}

Expand Down
4 changes: 4 additions & 0 deletions sdk/smx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ void SMX::SMXManager::UpdatePanelTestMode()
}
*/

getPanelTestMode() {
return this.panelTestMode;
}

setPanelTestMode(mode: PanelTestMode) {
// If we want to turn panel test mode off...
if (mode === PanelTestMode.Off) {
Expand Down
26 changes: 24 additions & 2 deletions ui/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAtomValue, useAtom } from "jotai";
import type React from "react";
import { useEffect } from "react";
import { useEffect, useState } from "react";

import { DebugCommands } from "./DebugCommands.tsx";
import { open_smx_device, promptSelectDevice } from "./pad-coms.ts";
Expand All @@ -14,6 +14,7 @@ import {
} from "./state.ts";
import { StageTest } from "./stage/stage-test.tsx";
import { TypedSelect } from "./common/typed-select.tsx";
import { PanelTestMode } from "../sdk/api.ts";

function usePreviouslyPairedDevices() {
useEffect(() => {
Expand Down Expand Up @@ -45,7 +46,7 @@ export function UI() {
<PickDevice /> <DebugCommands />
</p>
<p>
<TestDataDisplayToggle />
<TestDataDisplayToggle /> <PanelTestModeToggle />
</p>
<StatusDisplay />
</>
Expand Down Expand Up @@ -87,12 +88,14 @@ function StatusDisplay() {
}

function TestDataDisplayToggle() {
const stage = useAtomValue(selectedStage$);
const [testMode, setTestMode] = useAtom(displayTestData$);

return (
<label>
Read Test Values:{" "}
<TypedSelect
disabled={!stage}
value={testMode}
options={[
["", "None"],
Expand All @@ -106,3 +109,22 @@ function TestDataDisplayToggle() {
</label>
);
}

function PanelTestModeToggle() {
const stage = useAtomValue(selectedStage$);

return (
<label>
Panel Test Mode:{" "}
<input
type="checkbox"
style={{ height: "2em", width: "2em" }}
disabled={!stage}
defaultChecked={stage?.getPanelTestMode() === PanelTestMode.PressureTest}
onChange={(e) => {
stage?.setPanelTestMode(e.currentTarget.checked ? PanelTestMode.PressureTest : PanelTestMode.Off);
}}
/>
</label>
);
}

0 comments on commit e29f207

Please sign in to comment.