From 77fb64043d49b87ab74afa15aab6c2ab5b82ad5e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 5 Jan 2018 22:56:11 -0800 Subject: [PATCH] stop all motors when pressing escape --- libs/core/buttons.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 0de89e8c..bd0b9292 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -165,8 +165,10 @@ namespace brick { } // this needs to be done in query(), which is run without the main JS execution mutex // otherwise, while(true){} will lock the device - if (ret & DAL.BUTTON_ID_ESCAPE) + if (ret & DAL.BUTTON_ID_ESCAPE) { + motors.stopAllMotors(); control.reset() + } return ret } @@ -190,7 +192,7 @@ namespace brick { initBtns() buttons.push(this) } - } + } initBtns() // always ON as it handles ESCAPE button @@ -231,6 +233,7 @@ namespace control { /** * Determine the version of system software currently running. */ + //% export function deviceFirmwareVersion(): string { let buf = output.createBuffer(6) brick.internal.getBtnsMM().read(buf)