Skip to content

Commit

Permalink
Add action for reset in terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Dec 21, 2024
1 parent 17e7f42 commit 6d1058c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
23 changes: 20 additions & 3 deletions src/pages/terminal/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
faArrowsRotate,
faCodeBranch,
faLockOpen,
faPowerOff,
faQuestion,
faSquarePollHorizontal
} from "@fortawesome/free-solid-svg-icons";
Expand Down Expand Up @@ -135,6 +136,10 @@ const Terminal = () => {
xtermRef.current?.terminal.focus();
};

const onReset = () => {
controllerService.serialPort.write(Buffer.from([0x18]));
};

const onUnlock = () => {
controllerService?.send(new Command("$X"));
};
Expand All @@ -160,20 +165,32 @@ const Terminal = () => {
<div>
<Button
onClick={onRestart}
variant="danger"
title="Does a hard reset on the controller by setting DTR/RTS"
disabled={isLoading}
style={buttonStyle}
>
<FontAwesomeIcon
icon={faPowerOff as IconDefinition}
/>{" "}
Restart
</Button>
<Button
onClick={onReset}
variant="warning"
title="Restart"
title="Resets the controller with a 0x18 command"
disabled={isLoading}
style={buttonStyle}
>
<FontAwesomeIcon
icon={faArrowsRotate as IconDefinition}
/>{" "}
Restart
Reset
</Button>
<Button
onClick={onUnlock}
variant="secondary"
title="Unlock"
title="Unlocks the controller with $X"
disabled={isLoading}
style={buttonStyle}
>
Expand Down
8 changes: 5 additions & 3 deletions src/panels/navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
faFolderOpen,
faHome,
faPowerOff,
faRefresh,
faRightFromBracket,
faSliders,
faTerminal,
faWifi
Expand Down Expand Up @@ -88,11 +88,13 @@ const Navigation = () => {
)}
<hr />
<Nav.Link onClick={restart}>
<FontAwesomeIcon icon={faRefresh as IconDefinition} />{" "}
<FontAwesomeIcon icon={faPowerOff as IconDefinition} />{" "}
Restart
</Nav.Link>
<Nav.Link onClick={() => controllerService?.disconnect()}>
<FontAwesomeIcon icon={faPowerOff as IconDefinition} />{" "}
<FontAwesomeIcon
icon={faRightFromBracket as IconDefinition}
/>{" "}
Disconnect
</Nav.Link>
</Nav>
Expand Down
2 changes: 1 addition & 1 deletion src/services/InstallService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GithubService
} from "./GitHubService";
import { SerialPort } from "../utils/serialport/SerialPort";
import { flashDevice } from "../utils/flash";
import { FlashFile, flashDevice } from "../utils/flash";
import sha256 from "crypto-js/sha256";
import { enc } from "crypto-js/core";
import { analytics, logEvent } from "./FirebaseService";
Expand Down
2 changes: 1 addition & 1 deletion src/utils/flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NativeSerialPort } from "./serialport/typings";
import { InstallerState } from "../services";
import { convertUint8ArrayToBinaryString } from "./utils";

type FlashFile = {
export type FlashFile = {
fileName: string;
data: Uint8Array;
address: number;
Expand Down

0 comments on commit 6d1058c

Please sign in to comment.