Skip to content

Commit

Permalink
Merge pull request #202 from mackenziesalinas/Adding-to-Manager-Butto…
Browse files Browse the repository at this point in the history
…n-Features

Updated Issue #181: Updated Manager Button Features
  • Loading branch information
COChara authored Sep 20, 2023
2 parents e69dc0c + a6f36f0 commit 48cafa6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/pages/manager/components/bootLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, { ReactElement } from 'react';
import { sendCommandString, readGetNone } from '../controls/mainControls';
import {
sendCommandString,
readGetNone,
MainControls,
} from '../controls/mainControls';

async function bootLoader() {
//Sends the bootloader command to the charachorder via the serial API
Expand All @@ -9,13 +13,24 @@ async function bootLoader() {
await readGetNone();
}

function successfulBootLoader() {
if (MainControls.serialPort != null) {
alert(
'Your CharaChorder will now appear as an external storage device on your computer’s file explorer or Finder app. It might be named one of the following: “Arduino”, “Seeduino”, “TinyUSB” or “CharaChorder X.',
);
} else {
alert('There is no serial connection to bootload at this moment.');
}
}

export function BootLoaderButton(): ReactElement {
return (
<React.Fragment>
<button
className="sc-bYwzuL text-white rounded p-2 mb-4 inline-block ml-2 bg-[#333] hover:bg-[#3b3b3b] active:bg-[#222]"
color="pink"
onClick={() => bootLoader()}
onClickCapture={() => successfulBootLoader()}
>
BootLoader{' '}
</button>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/manager/components/disconnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export async function disconnectSerialConnection() {
}
}

function successfulDisconnect() {
if (MainControls.serialPort != null) {
alert('Successfully disconnected from serial port!');
} else {
alert('There is no serial connection to disconnect from at this moment.');
}
}

export function DisconnectButton(): ReactElement {
return (
<React.Fragment>
Expand All @@ -44,6 +52,7 @@ export function DisconnectButton(): ReactElement {
className="sc-bYwzuL text-white rounded p-2 mb-4 inline-block ml-2 bg-[#333] hover:bg-[#3b3b3b] active:bg-[#222] position-absolute"
color="pink"
onClick={() => disconnectSerialConnection()}
onClickCapture={() => successfulDisconnect()}
>
Disconnect{' '}
</button>
Expand Down

0 comments on commit 48cafa6

Please sign in to comment.