add block to stop program (#943)
* add block to stop program * renaming
This commit is contained in:
		
							
								
								
									
										18
									
								
								docs/reference/brick/exit-program.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								docs/reference/brick/exit-program.md
									
									
									
									
									
										Normal 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();
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
@@ -26,6 +26,7 @@ namespace brick {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    //% blockId=brickBatteryProperty block="battery %property"
 | 
					    //% blockId=brickBatteryProperty block="battery %property"
 | 
				
			||||||
    //% group="Battery"
 | 
					    //% group="Battery"
 | 
				
			||||||
 | 
					    //% blockGap=8
 | 
				
			||||||
    //% help=brick/battery-property
 | 
					    //% help=brick/battery-property
 | 
				
			||||||
    export function batteryInfo(property: BatteryProperty): number {
 | 
					    export function batteryInfo(property: BatteryProperty): number {
 | 
				
			||||||
        const info = sensors.internal.getBatteryInfo();
 | 
					        const info = sensors.internal.getBatteryInfo();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@ namespace brick {
 | 
				
			|||||||
        //% blockId=buttonIsPressed
 | 
					        //% blockId=buttonIsPressed
 | 
				
			||||||
        //% parts="brick"
 | 
					        //% parts="brick"
 | 
				
			||||||
        //% blockNamespace=brick
 | 
					        //% blockNamespace=brick
 | 
				
			||||||
        //% weight=81 blockGap=8
 | 
					        //% weight=81
 | 
				
			||||||
        //% group="Buttons"
 | 
					        //% group="Buttons"
 | 
				
			||||||
        //% button.fieldEditor="brickbuttons"
 | 
					        //% button.fieldEditor="brickbuttons"
 | 
				
			||||||
        isPressed() {
 | 
					        isPressed() {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								libs/ev3/brick.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								libs/ev3/brick.ts
									
									
									
									
									
										Normal 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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
//% color="#68C3E2" weight=100 icon="\uf106"
 | 
					//% color="#68C3E2" weight=100 icon="\uf106"
 | 
				
			||||||
//% groups='["Buttons", "Screen", "Battery"]'
 | 
					//% groups='["Buttons", "Screen", "Power"]'
 | 
				
			||||||
//% labelLineWidth=60
 | 
					//% labelLineWidth=60
 | 
				
			||||||
namespace brick {
 | 
					namespace brick {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,8 +2,9 @@
 | 
				
			|||||||
    "name": "ev3",
 | 
					    "name": "ev3",
 | 
				
			||||||
    "description": "The EV3 library",
 | 
					    "description": "The EV3 library",
 | 
				
			||||||
    "files": [
 | 
					    "files": [
 | 
				
			||||||
        "README.md",
 | 
					        "README.md",        
 | 
				
			||||||
        "ns.ts",
 | 
					        "ns.ts",
 | 
				
			||||||
 | 
					        "brick.ts",
 | 
				
			||||||
        "startup.ts",
 | 
					        "startup.ts",
 | 
				
			||||||
        "images.jres",
 | 
					        "images.jres",
 | 
				
			||||||
        "images.ts",
 | 
					        "images.ts",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user