@@ -1,9 +1,9 @@
 | 
				
			|||||||
# Schedule
 | 
					# Ramp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Schedules an acceleration, constant and deceleration phase at a given speed.
 | 
					Schedules an acceleration, constant and deceleration phase at a given speed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```sig
 | 
					```sig
 | 
				
			||||||
motors.largeA.schedule(50, 100, 500, 100)
 | 
					motors.largeA.ramp(50, 100, 500, 100)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The speed setting is a percentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
 | 
					The speed setting is a percentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
 | 
				
			||||||
@@ -30,7 +30,7 @@ brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
 | 
				
			|||||||
    acc += -100
 | 
					    acc += -100
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
 | 
					brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
 | 
				
			||||||
    motors.largeB.schedule(50, acc, steady, dec, MoveUnit.MilliSeconds)
 | 
					    motors.largeB.ramp(50, steady, MoveUnit.MilliSeconds, acc, dec)
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
 | 
					brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
 | 
				
			||||||
    acc += 100
 | 
					    acc += 100
 | 
				
			||||||
@@ -279,7 +279,7 @@ namespace motors {
 | 
				
			|||||||
            const r: MoveSchedule = {
 | 
					            const r: MoveSchedule = {
 | 
				
			||||||
                speed: Math.clamp(-100, 100, speed >> 0),
 | 
					                speed: Math.clamp(-100, 100, speed >> 0),
 | 
				
			||||||
                useSteps: true,
 | 
					                useSteps: true,
 | 
				
			||||||
                steps: [step1, step2, step3]
 | 
					                steps: [step1 || 0, step2 || 0, step3 || 0]
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            let scale = 1;
 | 
					            let scale = 1;
 | 
				
			||||||
            switch (unit) {
 | 
					            switch (unit) {
 | 
				
			||||||
@@ -352,18 +352,20 @@ namespace motors {
 | 
				
			|||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * Schedules a run of the motor with an acceleration, constant and deceleration phase.
 | 
					         * Schedules a run of the motor with an acceleration, constant and deceleration phase.
 | 
				
			||||||
         * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
 | 
					         * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
 | 
				
			||||||
         * @param acceleration acceleration phase measured distance or rotation
 | 
					         * @param value measured distance or rotation, eg: 500
 | 
				
			||||||
         * @param value measured distance or rotation
 | 
					         * @param unit (optional) unit of the value, eg: MoveUnit.MilliSeconds
 | 
				
			||||||
         * @param deceleration deceleration phase measured distance or rotation
 | 
					         * @param acceleration acceleration phase measured distance or rotation, eg: 500
 | 
				
			||||||
         * @param unit (optional) unit of the value
 | 
					         * @param deceleration deceleration phase measured distance or rotation, eg: 500
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        //% blockId=motorSchedule block="schedule %motor at %speed=motorSpeedPicker|\\%|for %acceleration|%value|%deceleration||%unit"
 | 
					        //% blockId=motorSchedule block="ramp %motor at %speed=motorSpeedPicker|\\%|for %value|%unit||accelerate %acceleration|decelerate %deceleration"
 | 
				
			||||||
        //% weight=99 blockGap=8
 | 
					        //% weight=99 blockGap=8
 | 
				
			||||||
        //% group="Move"
 | 
					        //% group="Move"
 | 
				
			||||||
        //% motor.fieldEditor="motors"
 | 
					        //% motor.fieldEditor="motors"
 | 
				
			||||||
        //% help=motors/motor/schedule
 | 
					        //% help=motors/motor/ramp
 | 
				
			||||||
        //% inlineInputMode=inline
 | 
					        //% inlineInputMode=inline
 | 
				
			||||||
        schedule(speed: number, acceleration: number, value: number, deceleration: number, unit: MoveUnit = MoveUnit.MilliSeconds) {
 | 
					        //% expandableArgumentMode=toggle
 | 
				
			||||||
 | 
					        //% value.defl=500
 | 
				
			||||||
 | 
					        ramp(speed: number, value: number = 500, unit: MoveUnit = MoveUnit.MilliSeconds, acceleration?: number, deceleration?: number) {
 | 
				
			||||||
            this.init();
 | 
					            this.init();
 | 
				
			||||||
            const schedule = this.normalizeSchedule(speed, acceleration, value, deceleration, unit);
 | 
					            const schedule = this.normalizeSchedule(speed, acceleration, value, deceleration, unit);
 | 
				
			||||||
            // stop if speed is 0
 | 
					            // stop if speed is 0
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user