Skip to content

Commit cd73c9c

Browse files
Fix reset.
1 parent fda93f4 commit cd73c9c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/board/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export class Board {
8282
* Defined during start().
8383
*/
8484
private modulePromise: Promise<ModuleWrapper> | undefined;
85+
/**
86+
* Flag to trigger a reset after start finishes.
87+
*/
88+
private resetWhenDone: boolean = false;
8589

8690
constructor(
8791
private notifications: Notifications,
@@ -349,11 +353,17 @@ export class Board {
349353
if (panicCode !== undefined) {
350354
this.displayPanic(panicCode);
351355
} else {
352-
this.displayStoppedState();
356+
if (this.resetWhenDone) {
357+
this.resetWhenDone = false;
358+
setTimeout(() => this.start(), 0);
359+
} else {
360+
this.displayStoppedState();
361+
}
353362
}
354363
}
355364

356-
async stop(): Promise<void> {
365+
async stop(reset: boolean = false): Promise<void> {
366+
this.resetWhenDone = reset;
357367
if (this.panicTimeout) {
358368
clearTimeout(this.panicTimeout);
359369
this.panicTimeout = null;
@@ -370,8 +380,7 @@ export class Board {
370380
}
371381

372382
async reset(): Promise<void> {
373-
await this.stop();
374-
this.start();
383+
this.stop(true);
375384
}
376385

377386
async flash(filesystem: Record<string, Uint8Array>): Promise<void> {

0 commit comments

Comments
 (0)