Skip to content

Commit

Permalink
Add last control state.
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasHeneka committed Dec 27, 2023
1 parent ad0e20e commit 34c826f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export enum States {
Brake = 'Brake',
StopLevitation = 'Stop Levitation',
Rolling = 'Rolling',
EndOfRun = 'End of Run'
EndOfRun = 'End of Run',
Off = 'Off'
}

interface EstablishConnectionProps {
Expand All @@ -27,7 +28,8 @@ interface EstablishConnectionProps {
setState: (state: States) => void
}

export function emergency(setConnectingPossible: (isConnecting: boolean) => void) {
export function emergency(setConnectingPossible: (isConnecting: boolean) => void, setState: (state: States) => void) {
setState(States.Off)
invoke('emergency');
setConnectingPossible(true) //TODO Remove when unnecessary
}
Expand Down Expand Up @@ -110,7 +112,7 @@ function ControlBar({
sx={{backgroundColor: '#E32B10'}}
color="error"
onClick={() => {
emergency(setConnectingPossible)
emergency(setConnectingPossible, setState)
}}
>Emergency [Space bar]</Button>
<Button variant="contained" size="large"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default function Dashboard() {
const keyDownHandler = (event: { key: string; preventDefault: () => void; }) => {
if (event.key === ' ') {
event.preventDefault()
emergency(setConnectingPossible)
emergency(setConnectingPossible, setState)
} else if (event.key === "F1") { //TODO Somebody test please, mac does not like overwriting this
event.preventDefault()
connect(setConnectingPossible, setConnectionSuccess)
Expand Down

0 comments on commit 34c826f

Please sign in to comment.