File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ export class PanicError extends Error {
2525 }
2626}
2727
28+ export class ResetError extends Error {
29+ constructor ( ) {
30+ super ( "reset" ) ;
31+ }
32+ }
33+
2834const stoppedOpactity = "0.5" ;
2935
3036export function createBoard ( notifications : Notifications , fs : FileSystem ) {
@@ -323,6 +329,9 @@ export class Board {
323329 } catch ( e : any ) {
324330 if ( e instanceof PanicError ) {
325331 panicCode = e . code ;
332+ } else if ( e instanceof ResetError ) {
333+ const noChangeRestart = ( ) => { } ;
334+ this . afterStopped = noChangeRestart ;
326335 } else {
327336 this . notifications . onInternalError ( e ) ;
328337 }
@@ -370,6 +379,10 @@ export class Board {
370379 }
371380 }
372381
382+ /**
383+ * An external reset.
384+ * reset() in MicroPython code throws ResetError.
385+ */
373386 async reset ( ) : Promise < void > {
374387 const noChangeRestart = ( ) => { } ;
375388 this . stop ( noChangeRestart ) ;
@@ -396,6 +409,10 @@ export class Board {
396409 throw new PanicError ( code ) ;
397410 }
398411
412+ throwReset ( ) : void {
413+ throw new ResetError ( ) ;
414+ }
415+
399416 displayPanic ( code : number ) : void {
400417 const sad = [
401418 [ 9 , 9 , 0 , 9 , 9 ] ,
Original file line number Diff line number Diff line change 2424 * THE SOFTWARE.
2525 */
2626
27-
2827mergeInto ( LibraryManager . library , {
2928 mp_js_hal_init : async function ( ) {
3029 Module . board . initialize ( ) ;
@@ -83,7 +82,7 @@ mergeInto(LibraryManager.library, {
8382 } ,
8483
8584 mp_js_hal_reset : function ( ) {
86- return Module . board . reset ( ) ;
85+ Module . board . throwReset ( ) ;
8786 } ,
8887
8988 mp_js_hal_panic : function ( code ) {
@@ -284,6 +283,9 @@ mergeInto(LibraryManager.library, {
284283 } ,
285284
286285 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+ ) ;
288290 } ,
289291} ) ;
You can’t perform that action at this time.
0 commit comments