Merge branch 'master' of https://github.com/microsoft/pxt-ev3
This commit is contained in:
		
							
								
								
									
										30
									
								
								docs/reference/motors/motor/set-brake-settle-time.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								docs/reference/motors/motor/set-brake-settle-time.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					# set Brake Settle Time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Set the time to wait after a motor stopped to allow it settle
 | 
				
			||||||
 | 
					when brake is enabled. Default is 10ms.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```sig
 | 
				
			||||||
 | 
					motors.largeA.setBrakeSettleTime(200)
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					When a the motor is stopped and brake is applied, it can still wiggle for a little while. You can use the settle time to automatically way after stopping and let the robot settle.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Parameters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **time**: a [number](/types/number) value which represents the number of milliseconds to wait after braking.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Set the brake mode and the settle time to 500ms. Run the motor connected to port **A** for 2 seconds at a speed of `30` and stop after 2s.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```blocks
 | 
				
			||||||
 | 
					motors.largeA.setBrake(true)
 | 
				
			||||||
 | 
					motors.largeA.setBrakeSettleTime(500)
 | 
				
			||||||
 | 
					motors.largeA.run(30)
 | 
				
			||||||
 | 
					pause(2000)
 | 
				
			||||||
 | 
					motors.largeA.stop()
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## See also
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[stop](/reference/motors/motor/stop)
 | 
				
			||||||
@@ -1,28 +1,28 @@
 | 
				
			|||||||
# set Brake
 | 
					# set Brake
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Set the brake on the motor so it won't turn when it has no power.
 | 
					Set the brake on the motor so it will brake when it finishes a brake command.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```sig
 | 
					```sig
 | 
				
			||||||
motors.largeA.setBrake(false)
 | 
					motors.largeA.setBrake(false)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
When a the motor is stopped, it can still rotate if an external force is applied to it. This can happen, for example, if your're tanking your brick on a inclined surface and stop the motors. Gravity will push down on the brick and might cause it to start rolling again. You can prevent this movement by setting the brake.
 | 
					When a the motor is stopped, it can still rotate if an external force is applied to it. This can happen, for example, if you're tanking your brick on a inclined surface and stop the motors. Gravity will push down on the brick and might cause it to start rolling again. You can prevent this movement by setting the brake.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Also, you can use the brake to do simple skid steering for your brick.
 | 
					Also, you can use the brake to do simple skid steering for your brick.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Paramters
 | 
					## Parameters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* **brake**: a [boolean](/types/boolean) value which is either `true` to set the brake on or `false` to set the brake off.
 | 
					* **brake**: a [boolean](/types/boolean) value which is either `true` to set the brake on or `false` to set the brake off.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Example
 | 
					## Example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and set the brake.
 | 
					Run the motor connected to port **A** for 2 seconds at a speed of `30` and stop after 2s.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```blocks
 | 
					```blocks
 | 
				
			||||||
 | 
					motors.largeA.setBrake(true)
 | 
				
			||||||
motors.largeA.run(30)
 | 
					motors.largeA.run(30)
 | 
				
			||||||
pause(2000)
 | 
					pause(2000)
 | 
				
			||||||
motors.largeA.stop()
 | 
					motors.largeA.stop()
 | 
				
			||||||
motors.largeA.setBrake(true)
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## See also
 | 
					## See also
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +0,0 @@
 | 
				
			|||||||
# Set Run Acceleration Ramp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```sig
 | 
					 | 
				
			||||||
motors.largeD.setRunAccelerationRamp(1, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Examples
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```blocks
 | 
					 | 
				
			||||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
 | 
					 | 
				
			||||||
    motors.largeB.run(50, 6, MoveUnit.Rotations)
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
 | 
					 | 
				
			||||||
    motors.largeC.run(50, 6, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
motors.largeB.setRunAccelerationRamp(360, MoveUnit.Degrees)
 | 
					 | 
				
			||||||
motors.largeB.setRunDecelerationRamp(360, MoveUnit.Degrees)
 | 
					 | 
				
			||||||
motors.largeC.setRunAccelerationRamp(2, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
motors.largeC.setRunDecelerationRamp(2, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
@@ -1,20 +0,0 @@
 | 
				
			|||||||
# Set Run Deceleration Ramp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```sig
 | 
					 | 
				
			||||||
motors.largeD.setRunDecelerationRamp(1, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Examples
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```blocks
 | 
					 | 
				
			||||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
 | 
					 | 
				
			||||||
    motors.largeB.run(50, 6, MoveUnit.Rotations)
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
 | 
					 | 
				
			||||||
    motors.largeC.run(50, 6, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
motors.largeB.setRunAccelerationRamp(360, MoveUnit.Degrees)
 | 
					 | 
				
			||||||
motors.largeB.setRunDecelerationRamp(360, MoveUnit.Degrees)
 | 
					 | 
				
			||||||
motors.largeC.setRunAccelerationRamp(2, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
motors.largeC.setRunDecelerationRamp(2, MoveUnit.Seconds)
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
							
								
								
									
										26
									
								
								docs/reference/motors/motor/set-run-phase.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								docs/reference/motors/motor/set-run-phase.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					# Set Run Phase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Allows to specify an acceleration or deceleration phases for run commands.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```sig
 | 
				
			||||||
 | 
					motors.largeD.setRunPhase(MovePhase.Acceleration, 1, MoveUnit.Seconds)
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Once the run phase is specified on a motor (or pair of motors),
 | 
				
			||||||
 | 
					it will be automatically applied to [run](/reference/motors/run) commands.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Time vs Rotation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The phases specified for time units (seconds, milliseconds) only apply to run with time
 | 
				
			||||||
 | 
					moves. Similarly, the phases specified for rotation units (# rotation, degrees) only
 | 
				
			||||||
 | 
					apply to run with rotation units.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Examples
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```blocks
 | 
				
			||||||
 | 
					motors.largeB.setRunPhase(MovePhase.Acceleration, 0.5, MoveUnit.Seconds)
 | 
				
			||||||
 | 
					motors.largeB.setRunPhase(MovePhase.Deceleration, 0.2, MoveUnit.Seconds)
 | 
				
			||||||
 | 
					forever(function () {
 | 
				
			||||||
 | 
					    motors.largeB.run(50, 1, MoveUnit.Seconds)
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
@@ -36,6 +36,13 @@ enum MoveUnit {
 | 
				
			|||||||
    MilliSeconds
 | 
					    MilliSeconds
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum MovePhase {
 | 
				
			||||||
 | 
					    //% block="acceleration"
 | 
				
			||||||
 | 
					    Acceleration,
 | 
				
			||||||
 | 
					    //% block="deceleration"
 | 
				
			||||||
 | 
					    Deceleration
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace motors {
 | 
					namespace motors {
 | 
				
			||||||
    let pwmMM: MMap
 | 
					    let pwmMM: MMap
 | 
				
			||||||
    let motorMM: MMap
 | 
					    let motorMM: MMap
 | 
				
			||||||
@@ -226,6 +233,7 @@ namespace motors {
 | 
				
			|||||||
        //% weight=1 blockGap=8
 | 
					        //% weight=1 blockGap=8
 | 
				
			||||||
        //% group="Properties"
 | 
					        //% group="Properties"
 | 
				
			||||||
        //% millis.defl=200 millis.min=0 millis.max=500
 | 
					        //% millis.defl=200 millis.min=0 millis.max=500
 | 
				
			||||||
 | 
					        //% help=motors/motor/set-brake-settle-time
 | 
				
			||||||
        setBrakeSettleTime(millis: number) {
 | 
					        setBrakeSettleTime(millis: number) {
 | 
				
			||||||
            this.init();
 | 
					            this.init();
 | 
				
			||||||
            // ensure in [0,500]
 | 
					            // ensure in [0,500]
 | 
				
			||||||
@@ -388,50 +396,41 @@ namespace motors {
 | 
				
			|||||||
         * Specifies the amount of rotation or time for the acceleration
 | 
					         * Specifies the amount of rotation or time for the acceleration
 | 
				
			||||||
         * of run commands.
 | 
					         * of run commands.
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        //% blockId=outputMotorsetRunAcceleration block="set %motor|run acceleration ramp to $value||$unit"
 | 
					        //% blockId=outputMotorsetRunRamp block="set %motor|run %ramp to $value||$unit"
 | 
				
			||||||
        //% motor.fieldEditor="motors"
 | 
					        //% motor.fieldEditor="motors"
 | 
				
			||||||
        //% weight=21 blockGap=8
 | 
					        //% weight=21 blockGap=8
 | 
				
			||||||
        //% group="Properties"
 | 
					        //% group="Properties"
 | 
				
			||||||
        //% help=motors/motor/set-run-acceleration-ramp
 | 
					        //% help=motors/motor/set-run-phase
 | 
				
			||||||
        setRunAccelerationRamp(value: number, unit: MoveUnit = MoveUnit.MilliSeconds) {
 | 
					        setRunPhase(phase: MovePhase, value: number, unit: MoveUnit = MoveUnit.MilliSeconds) {
 | 
				
			||||||
 | 
					            let temp: number;
 | 
				
			||||||
            switch (unit) {
 | 
					            switch (unit) {
 | 
				
			||||||
                case MoveUnit.Rotations:
 | 
					                case MoveUnit.Rotations:
 | 
				
			||||||
                    this._accelerationSteps = Math.max(0, (value * 360) | 0);
 | 
					                    temp = Math.max(0, (value * 360) | 0);
 | 
				
			||||||
 | 
					                    if (phase == MovePhase.Acceleration)
 | 
				
			||||||
 | 
					                        this._accelerationSteps = temp;
 | 
				
			||||||
 | 
					                    else 
 | 
				
			||||||
 | 
					                        this._decelerationSteps = temp;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case MoveUnit.Degrees:
 | 
					                case MoveUnit.Degrees:
 | 
				
			||||||
                    this._accelerationSteps = Math.max(0, value | 0);
 | 
					                    temp = Math.max(0, value | 0);
 | 
				
			||||||
 | 
					                    if (phase == MovePhase.Acceleration)
 | 
				
			||||||
 | 
					                        this._accelerationSteps = temp;
 | 
				
			||||||
 | 
					                    else 
 | 
				
			||||||
 | 
					                        this._decelerationSteps = temp;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case MoveUnit.Seconds:
 | 
					                case MoveUnit.Seconds:
 | 
				
			||||||
                    this._accelerationTime = Math.max(0, (value * 1000) | 0);
 | 
					                    temp = Math.max(0, (value * 1000) | 0);
 | 
				
			||||||
 | 
					                    if (phase == MovePhase.Acceleration)
 | 
				
			||||||
 | 
					                        this._accelerationTime = temp;
 | 
				
			||||||
 | 
					                    else 
 | 
				
			||||||
 | 
					                        this._decelerationTime = temp;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case MoveUnit.MilliSeconds:
 | 
					                case MoveUnit.MilliSeconds:
 | 
				
			||||||
                    this._accelerationTime = Math.max(0, value | 0);
 | 
					                    temp = Math.max(0, value | 0);
 | 
				
			||||||
                    break;
 | 
					                    if (phase == MovePhase.Acceleration)
 | 
				
			||||||
            }
 | 
					                        this._accelerationTime = temp;
 | 
				
			||||||
        }
 | 
					                    else 
 | 
				
			||||||
 | 
					                        this._decelerationTime = temp;
 | 
				
			||||||
        /**
 | 
					 | 
				
			||||||
         * Specifies the amount of rotation or time for the acceleration
 | 
					 | 
				
			||||||
         * of run commands.
 | 
					 | 
				
			||||||
         */
 | 
					 | 
				
			||||||
        //% blockId=outputMotorsetRunDeceleration block="set %motor|run deceleration ramp to $value||$unit"
 | 
					 | 
				
			||||||
        //% motor.fieldEditor="motors"
 | 
					 | 
				
			||||||
        //% weight=20 blockGap=8
 | 
					 | 
				
			||||||
        //% group="Properties"
 | 
					 | 
				
			||||||
        //% help=motors/motor/set-run-deceleration-ramp
 | 
					 | 
				
			||||||
        setRunDecelerationRamp(value: number, unit: MoveUnit = MoveUnit.MilliSeconds) {
 | 
					 | 
				
			||||||
            switch (unit) {
 | 
					 | 
				
			||||||
                case MoveUnit.Rotations:
 | 
					 | 
				
			||||||
                    this._decelerationSteps = Math.max(0, (value * 360) | 0);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case MoveUnit.Degrees:
 | 
					 | 
				
			||||||
                    this._decelerationSteps = Math.max(0, value | 0);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case MoveUnit.Seconds:
 | 
					 | 
				
			||||||
                    this._decelerationTime = Math.max(0, (value * 1000) | 0);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case MoveUnit.MilliSeconds:
 | 
					 | 
				
			||||||
                    this._decelerationTime = Math.max(0, value | 0);
 | 
					 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user