add block to stop program (#943)

* add block to stop program

* renaming
This commit is contained in:
Peli de Halleux 2019-10-09 09:30:42 -07:00 committed by GitHub
parent fb5776ec41
commit a4e02dcd03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 3 deletions

View File

@ -0,0 +1,18 @@
# exit Program
Stops the program and returns to the brick menu
```sig
brick.exitProgram();
```
## Example
Do a sequence of motor commands and stop the program.
```blocks
motors.largeA.run(50)
pause(500)
motors.stopAll()
brick.exitProgram();
```

View File

@ -26,6 +26,7 @@ namespace brick {
*/
//% blockId=brickBatteryProperty block="battery %property"
//% group="Battery"
//% blockGap=8
//% help=brick/battery-property
export function batteryInfo(property: BatteryProperty): number {
const info = sensors.internal.getBatteryInfo();

View File

@ -85,7 +85,7 @@ namespace brick {
//% blockId=buttonIsPressed
//% parts="brick"
//% blockNamespace=brick
//% weight=81 blockGap=8
//% weight=81
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
isPressed() {

13
libs/ev3/brick.ts Normal file
View File

@ -0,0 +1,13 @@
namespace brick {
/**
* Exits the program to the main menu. (in the simulator restarts it)
*/
//% blockId=loopstop block="exit program"
//% help=reference/brick/exit-program
//% weight=10
//% blockGap=8
//% group="Buttons"
export function exitProgram() {
control.reset();
}
}

View File

@ -1,6 +1,6 @@
//% color="#68C3E2" weight=100 icon="\uf106"
//% groups='["Buttons", "Screen", "Battery"]'
//% groups='["Buttons", "Screen", "Power"]'
//% labelLineWidth=60
namespace brick {
}

View File

@ -2,8 +2,9 @@
"name": "ev3",
"description": "The EV3 library",
"files": [
"README.md",
"README.md",
"ns.ts",
"brick.ts",
"startup.ts",
"images.jres",
"images.ts",