File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ export class PanicError extends Error {
25
25
}
26
26
}
27
27
28
+ export class ResetError extends Error {
29
+ constructor ( ) {
30
+ super ( "reset" ) ;
31
+ }
32
+ }
33
+
28
34
const stoppedOpactity = "0.5" ;
29
35
30
36
export function createBoard ( notifications : Notifications , fs : FileSystem ) {
@@ -322,6 +328,8 @@ export class Board {
322
328
} catch ( e : any ) {
323
329
if ( e instanceof PanicError ) {
324
330
panicCode = e . code ;
331
+ } else if ( e instanceof ResetError ) {
332
+ this . resetWhenDone = true ;
325
333
} else {
326
334
this . notifications . onInternalError ( e ) ;
327
335
}
@@ -365,6 +373,10 @@ export class Board {
365
373
}
366
374
}
367
375
376
+ /**
377
+ * An external reset.
378
+ * reset() in MicroPython code throws ResetError.
379
+ */
368
380
async reset ( ) : Promise < void > {
369
381
this . stop ( true ) ;
370
382
}
@@ -384,6 +396,10 @@ export class Board {
384
396
throw new PanicError ( code ) ;
385
397
}
386
398
399
+ throwReset ( ) : void {
400
+ throw new ResetError ( ) ;
401
+ }
402
+
387
403
displayPanic ( code : number ) : void {
388
404
const sad = [
389
405
[ 9 , 9 , 0 , 9 , 9 ] ,
Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
27
-
28
27
mergeInto ( LibraryManager . library , {
29
28
mp_js_hal_init : async function ( ) {
30
29
Module . board . initialize ( ) ;
@@ -83,7 +82,7 @@ mergeInto(LibraryManager.library, {
83
82
} ,
84
83
85
84
mp_js_hal_reset : function ( ) {
86
- return Module . board . reset ( ) ;
85
+ Module . board . throwReset ( ) ;
87
86
} ,
88
87
89
88
mp_js_hal_panic : function ( code ) {
@@ -284,6 +283,9 @@ mergeInto(LibraryManager.library, {
284
283
} ,
285
284
286
285
mp_js_hal_log_data : function ( key , value ) {
287
- return Module . board . dataLogging . logData ( UTF8ToString ( key ) , UTF8ToString ( value ) ) ;
286
+ return Module . board . dataLogging . logData (
287
+ UTF8ToString ( key ) ,
288
+ UTF8ToString ( value )
289
+ ) ;
288
290
} ,
289
291
} ) ;
You can’t perform that action at this time.
0 commit comments