Skip to content

Commit 2903e85

Browse files
committed
Add halt button
1 parent 4429ec7 commit 2903e85

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<div id="serial-page" class="">
9797
<div id="serial-bar">
9898
<button class="purple-button btn-restart">Restart<i class="fa-solid fa-redo"></i></button>
99+
<button class="purple-button btn-halt">Halt<i class="fa-solid fa-hand"></i></button>
99100
<button class="purple-button btn-clear">Clear<i class="fa-solid fa-broom"></i></button>
100101
<button class="purple-button btn-plotter">Plotter<i class="fa-solid fa-chart-line"></i></button>
101102
<div id="terminal-title"></div>

js/script.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ let unchanged = 0;
3333
let connectionPromise = null;
3434

3535
const btnRestart = document.querySelector('.btn-restart');
36+
const btnHalt = document.querySelector('.btn-halt');
3637
const btnPlotter = document.querySelector('.btn-plotter');
3738
const btnClear = document.querySelector('.btn-clear');
3839
const btnConnect = document.querySelectorAll('.btn-connect');
@@ -130,6 +131,14 @@ btnRestart.addEventListener('click', async function(e) {
130131
}
131132
});
132133

134+
// Halt Button
135+
btnHalt.addEventListener('click', async function(e) {
136+
if (await checkConnected()) {
137+
// Perform a device soft halt
138+
await workflow.haltScript();
139+
}
140+
});
141+
133142
// Clear Button
134143
btnClear.addEventListener('click', async function(e) {
135144
if (workflow.plotterChart){

js/workflows/workflow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ class Workflow {
9191
}
9292

9393
async restartDevice() {
94-
this.repl.softRestart();
94+
await this.repl.softRestart();
95+
}
96+
97+
async haltScript() {
98+
await this.repl.interruptCode();
9599
}
96100

97101
makeDocState(document, docChangePos) {

0 commit comments

Comments
 (0)