From fad4ca98db7afcdad24bac84e60c5b14314c1c03 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 19 Feb 2018 07:35:08 -0800 Subject: [PATCH] renaming 'set speed' to 'run' (#327) --- docs/SUMMARY.md | 2 +- docs/about.md | 6 +-- docs/coding/cruise-control-1.md | 2 +- docs/coding/cruise-control-2.md | 4 +- docs/coding/cruise-control-3.md | 2 +- docs/coding/reverse-beeper-1.md | 2 +- docs/coding/reverse-beeper-2.md | 2 +- docs/coding/reverse-beeper-3.md | 2 +- docs/coding/reversing-the-robot-1.md | 8 ++-- docs/coding/reversing-the-robot-2.md | 8 ++-- docs/coding/reversing-the-robot-3.md | 8 ++-- docs/coding/roaming-1.md | 8 ++-- docs/coding/roaming-2.md | 8 ++-- docs/examples/core-set/gyroboy-blocks.md | 10 ++--- docs/examples/core-set/gyroboy-labview.md | 10 ++--- docs/examples/core-set/puppy-labview.md | 34 +++++++-------- docs/examples/core-set/robotarm-labview.md | 30 ++++++------- docs/examples/crane-labview.md | 30 ++++++------- docs/examples/gyro-boy-labview.md | 10 ++--- docs/examples/line-follower-pid.md | 2 +- docs/labview.md | 42 +++++++++---------- docs/lessons/line-detection.md | 16 +++---- docs/maker/puppet.md | 4 +- docs/maker/sound-machine.md | 4 +- docs/reference/motors.md | 2 +- docs/reference/motors/motor/angle.md | 2 +- docs/reference/motors/motor/clear-counts.md | 4 +- docs/reference/motors/motor/reset.md | 4 +- .../motors/motor/{set-speed.md => run.md} | 24 +++++------ docs/reference/motors/motor/set-brake.md | 2 +- docs/reference/motors/motor/set-inverted.md | 4 +- docs/reference/motors/motor/set-regulated.md | 4 +- docs/reference/motors/motor/speed.md | 4 +- docs/reference/motors/motor/stop.md | 4 +- docs/reference/motors/motor/tacho.md | 4 +- docs/reference/motors/synced/steer.md | 4 +- docs/reference/motors/synced/tank.md | 4 +- libs/core/output.ts | 16 +++---- libs/tests/README.md | 4 +- package.json | 2 +- tests/motors.ts | 12 +++--- 41 files changed, 177 insertions(+), 177 deletions(-) rename docs/reference/motors/motor/{set-speed.md => run.md} (82%) diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 300a01f1..1c717280 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -67,7 +67,7 @@ * [set light](/reference/brick/set-status-light) * [battery level](/reference/brick/battery-level) * [Motors](/reference/motors) - * [set speed](/reference/motors/motor/set-speed) + * [run](/reference/motors/motor/run) * [stop](/reference/motors/motor/stop) * [reset](/reference/motors/motor/reset) * [set brake](/reference/motors/motor/set-brake) diff --git a/docs/about.md b/docs/about.md index c94b689d..490f5984 100644 --- a/docs/about.md +++ b/docs/about.md @@ -8,12 +8,12 @@ You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascr ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { - motors.largeA.setSpeed(50) + motors.largeA.run(50) }) ``` ```typescript brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { - motors.largeA.setSpeed(50) + motors.largeA.run(50) }) ``` @@ -34,6 +34,6 @@ The simulator has support for the LED screen, buttons, as well as compass, accel ```sim brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { - motors.largeA.setSpeed(50) + motors.largeA.run(50) }) ``` diff --git a/docs/coding/cruise-control-1.md b/docs/coding/cruise-control-1.md index 2b58db38..a0490ec2 100644 --- a/docs/coding/cruise-control-1.md +++ b/docs/coding/cruise-control-1.md @@ -5,6 +5,6 @@ let speed = 0; sensors.touch1.onEvent(ButtonEvent.Pressed, function () { if (speed < 100) speed = speed + 10; - motors.largeBC.setSpeed(speed); + motors.largeBC.run(speed); }) ``` \ No newline at end of file diff --git a/docs/coding/cruise-control-2.md b/docs/coding/cruise-control-2.md index 34cf6d55..e7f39ccc 100644 --- a/docs/coding/cruise-control-2.md +++ b/docs/coding/cruise-control-2.md @@ -5,11 +5,11 @@ let speed = 0; sensors.touch1.onEvent(ButtonEvent.Pressed, function () { if (speed < 100) speed = speed + 10; - motors.largeBC.setSpeed(speed); + motors.largeBC.run(speed); }) sensors.touch2.onEvent(ButtonEvent.Pressed, function () { if (speed > -100) speed = speed - 10; - motors.largeBC.setSpeed(speed); + motors.largeBC.run(speed); }) ``` \ No newline at end of file diff --git a/docs/coding/cruise-control-3.md b/docs/coding/cruise-control-3.md index 0cdb0822..751a55b4 100644 --- a/docs/coding/cruise-control-3.md +++ b/docs/coding/cruise-control-3.md @@ -15,7 +15,7 @@ function accelerate() { function update() { brick.clearScreen() brick.showString("speed: " + speed, 1) - motors.largeBC.setSpeed(speed) + motors.largeBC.run(speed) } sensors.touch2.onEvent(ButtonEvent.Pressed, function () { accelerate() diff --git a/docs/coding/reverse-beeper-1.md b/docs/coding/reverse-beeper-1.md index c77214a5..daf19003 100644 --- a/docs/coding/reverse-beeper-1.md +++ b/docs/coding/reverse-beeper-1.md @@ -5,7 +5,7 @@ forever(function () { music.playTone(440, sensors.ultrasonic4.distance()); pause(50) }) -motors.largeBC.setSpeed(-20); +motors.largeBC.run(-20); sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear); motors.largeBC.stop(); ``` diff --git a/docs/coding/reverse-beeper-2.md b/docs/coding/reverse-beeper-2.md index 209b969b..8657f443 100644 --- a/docs/coding/reverse-beeper-2.md +++ b/docs/coding/reverse-beeper-2.md @@ -7,7 +7,7 @@ forever(function () { pause(50) } }) -motors.largeBC.setSpeed(-20); +motors.largeBC.run(-20); sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear); motors.largeBC.stop(); ``` diff --git a/docs/coding/reverse-beeper-3.md b/docs/coding/reverse-beeper-3.md index 83406767..3790f62a 100644 --- a/docs/coding/reverse-beeper-3.md +++ b/docs/coding/reverse-beeper-3.md @@ -4,7 +4,7 @@ let beep = false beep = true control.runInParallel(function () { - motors.largeBC.setSpeed(-20) + motors.largeBC.run(-20) sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear) motors.largeBC.stop() beep = false diff --git a/docs/coding/reversing-the-robot-1.md b/docs/coding/reversing-the-robot-1.md index fc31ac03..a268d545 100644 --- a/docs/coding/reversing-the-robot-1.md +++ b/docs/coding/reversing-the-robot-1.md @@ -2,13 +2,13 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { - motors.largeBC.setSpeed(50) + motors.largeBC.run(50) sensors.touch1.pauseUntil(ButtonEvent.Pressed) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) - motors.largeBC.setSpeed(-50) + motors.largeBC.run(-50) pause(2000) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) }) ``` \ No newline at end of file diff --git a/docs/coding/reversing-the-robot-2.md b/docs/coding/reversing-the-robot-2.md index 49b8cadd..77c92fbb 100644 --- a/docs/coding/reversing-the-robot-2.md +++ b/docs/coding/reversing-the-robot-2.md @@ -3,13 +3,13 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { sensors.touch1.pauseUntil(ButtonEvent.Pressed) - motors.largeBC.setSpeed(50) + motors.largeBC.run(50) sensors.touch2.pauseUntil(ButtonEvent.Pressed) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) - motors.largeBC.setSpeed(-50) + motors.largeBC.run(-50) pause(2000) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) }) ``` \ No newline at end of file diff --git a/docs/coding/reversing-the-robot-3.md b/docs/coding/reversing-the-robot-3.md index cb9268a5..0ad4f1bd 100644 --- a/docs/coding/reversing-the-robot-3.md +++ b/docs/coding/reversing-the-robot-3.md @@ -5,15 +5,15 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { brick.showImage(images.eyesSleeping) sensors.touch1.pauseUntil(ButtonEvent.Pressed) brick.showImage(images.eyesNeutral) - motors.largeBC.setSpeed(50) + motors.largeBC.run(50) sensors.touch2.pauseUntil(ButtonEvent.Pressed) brick.showImage(images.eyesTiredMiddle) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) brick.showImage(images.eyesDizzy) - motors.largeBC.setSpeed(-50) + motors.largeBC.run(-50) pause(2000) - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) }) ``` \ No newline at end of file diff --git a/docs/coding/roaming-1.md b/docs/coding/roaming-1.md index 9e085c3e..548eae24 100644 --- a/docs/coding/roaming-1.md +++ b/docs/coding/roaming-1.md @@ -19,13 +19,13 @@ pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { - motors.largeC.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeC.run(50, 360, MoveUnit.Degrees) } else if (d == 3) { - motors.largeB.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeB.run(50, 360, MoveUnit.Degrees) } else if (d == 4) { - motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeBC.run(50, 360, MoveUnit.Degrees) } else { - motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees) + motors.largeBC.run(-50, 360, MoveUnit.Degrees) } } music.playSoundEffectUntilDone(sounds.communicationGameOver) diff --git a/docs/coding/roaming-2.md b/docs/coding/roaming-2.md index f39b0075..540482c0 100644 --- a/docs/coding/roaming-2.md +++ b/docs/coding/roaming-2.md @@ -23,13 +23,13 @@ pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { - motors.largeC.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeC.run(50, 360, MoveUnit.Degrees) } else if (d == 3) { - motors.largeB.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeB.run(50, 360, MoveUnit.Degrees) } else if (d == 4) { - motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees) + motors.largeBC.run(50, 360, MoveUnit.Degrees) } else { - motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees) + motors.largeBC.run(-50, 360, MoveUnit.Degrees) } } music.playSoundEffectUntilDone(sounds.communicationGameOver) diff --git a/docs/examples/core-set/gyroboy-blocks.md b/docs/examples/core-set/gyroboy-blocks.md index 396e9404..47113c53 100644 --- a/docs/examples/core-set/gyroboy-blocks.md +++ b/docs/examples/core-set/gyroboy-blocks.md @@ -119,9 +119,9 @@ sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () { controlSteering = 0 oldControlDrive = controlDrive controlDrive = -10 - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); - motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees); - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); + motors.mediumC.run(-30, 60, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); if (Math.randomRange(-1, 1) >= 1) { controlSteering = 70 } else { @@ -149,8 +149,8 @@ sensors.color1.onColorDetected(ColorSensorColor.Blue, function () { }) // apply power to motors function controlMotors() { - motors.largeA.setSpeed(power + controlSteering * 0.1) - motors.largeD.setSpeed(power - controlSteering * 0.1) + motors.largeA.run(power + controlSteering * 0.1) + motors.largeD.run(power - controlSteering * 0.1) } sensors.color1.onColorDetected(ColorSensorColor.Yellow, function () { moods.middleLeft.show() diff --git a/docs/examples/core-set/gyroboy-labview.md b/docs/examples/core-set/gyroboy-labview.md index 8a1199ed..1860ca3d 100644 --- a/docs/examples/core-set/gyroboy-labview.md +++ b/docs/examples/core-set/gyroboy-labview.md @@ -137,8 +137,8 @@ forever(function () { GM(); EQ(); cntrl(); - motors.largeA.setSpeed(lpwr) - motors.largeD.setSpeed(rpwr) + motors.largeA.run(lpwr) + motors.largeD.run(rpwr) CHK() let t2 = control.timer1.millis(); let p = 5 - (t2 - t1); @@ -196,9 +196,9 @@ forever(function () { Cstr = 0; oldDr = Cdrv; Cdrv = -10; - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); - motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees); - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); + motors.mediumC.run(-30, 60, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); if (Math.randomRange(-1, 1) >= 1) Cstr = 70; else diff --git a/docs/examples/core-set/puppy-labview.md b/docs/examples/core-set/puppy-labview.md index 8ad9ce66..b02fb9ff 100644 --- a/docs/examples/core-set/puppy-labview.md +++ b/docs/examples/core-set/puppy-labview.md @@ -32,9 +32,9 @@ function MNRH() { brick.setStatusLight(StatusLight.OrangePulse) while (!brick.buttonEnter.wasPressed()) { if (brick.buttonUp.wasPressed()) { - motors.mediumC.setSpeed(-100); + motors.mediumC.run(-100); } else if (brick.buttonDown.wasPressed()) { - motors.mediumC.setSpeed(100); + motors.mediumC.run(100); } else { motors.mediumC.stop(); } @@ -83,20 +83,20 @@ function UP() { if (motors.largeA.angle() > -50) { control.runInParallel(function () { motors.largeD.clearCounts() - motors.largeD.setSpeed(-35); + motors.largeD.run(-35); pauseUntil(() => motors.largeD.angle() < -25); motors.largeD.stop(); motors.largeD.setRegulated(false) - motors.largeD.setSpeed(-15) + motors.largeD.run(-15) pauseUntil(() => motors.largeD.angle() < -65); motors.largeD.stop(); }) motors.largeA.clearCounts() - motors.largeA.setSpeed(-35); + motors.largeA.run(-35); pauseUntil(() => motors.largeA.angle() < -25); motors.largeA.stop(); motors.largeA.setRegulated(false) - motors.largeA.setSpeed(-15) + motors.largeA.run(-15) pauseUntil(() => motors.largeA.angle() < -65); motors.largeA.stop(); @@ -231,9 +231,9 @@ function IDL() { function MHT(Pos: number) { let _R = Pos - motors.mediumC.angle(); if (_R >= 0) { - motors.mediumC.setSpeed(100, _R, MoveUnit.Degrees); + motors.mediumC.run(100, _R, MoveUnit.Degrees); } else { - motors.mediumC.setSpeed(-100, Math.abs(_R), MoveUnit.Degrees); + motors.mediumC.run(-100, Math.abs(_R), MoveUnit.Degrees); } } @@ -304,15 +304,15 @@ function PPP() { IS(2); UP(); pause(100) - motors.largeA.setSpeed(-30, 70, MoveUnit.Degrees); + motors.largeA.run(-30, 70, MoveUnit.Degrees); pause(800); music.playSoundEffect(sounds.mechanicalHorn1); pause(1000); for(let i = 0; i < 3; ++i) { - motors.largeA.setSpeed(-30, 20, MoveUnit.Degrees); - motors.largeA.setSpeed(30, 20, MoveUnit.Degrees); + motors.largeA.run(-30, 20, MoveUnit.Degrees); + motors.largeA.run(30, 20, MoveUnit.Degrees); } - motors.largeA.setSpeed(30, 70, MoveUnit.Degrees); + motors.largeA.run(30, 70, MoveUnit.Degrees); F_C = 1; CS(0); } @@ -320,12 +320,12 @@ function PPP() { function HPY() { IS(8) MHT(0); - motors.largeAD.setSpeed(10, 0.8, MoveUnit.Seconds); + motors.largeAD.run(10, 0.8, MoveUnit.Seconds); for(let i = 0; i < 3; ++i) { music.playSoundEffect(sounds.animalsDogBark1); - motors.largeAD.setSpeed(-100, 0.2, MoveUnit.Seconds); + motors.largeAD.run(-100, 0.2, MoveUnit.Seconds); pause(300) - motors.largeAD.setSpeed(10, 0.3, MoveUnit.Seconds) + motors.largeAD.run(10, 0.3, MoveUnit.Seconds) } pause(500); music.stopAllSounds(); @@ -335,9 +335,9 @@ function HPY() { function STL() { UP(); - motors.largeAD.setSpeed(-20, 60, MoveUnit.Degrees); + motors.largeAD.run(-20, 60, MoveUnit.Degrees); music.playSoundEffect(sounds.animalsDogWhine); - motors.largeAD.setSpeed(20, 60, MoveUnit.Degrees); + motors.largeAD.run(20, 60, MoveUnit.Degrees); } function WKU() { diff --git a/docs/examples/core-set/robotarm-labview.md b/docs/examples/core-set/robotarm-labview.md index 77abc203..6f91123d 100644 --- a/docs/examples/core-set/robotarm-labview.md +++ b/docs/examples/core-set/robotarm-labview.md @@ -5,14 +5,14 @@ function INI() { motors.largeB.setBrake(true) motors.largeC.setBrake(true) motors.mediumA.setBrake(true) - motors.largeB.setSpeed(-50) + motors.largeB.run(-50) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop(); - motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds); - motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees); - motors.largeC.setSpeed(50) + motors.mediumA.run(30, 1, MoveUnit.Seconds); + motors.mediumA.run(-50, 90, MoveUnit.Degrees); + motors.largeC.run(50) sensors.touch1.pauseUntil(ButtonEvent.Pressed); - motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations); + motors.largeC.run(-50, 0.86, MoveUnit.Rotations); } INI() @@ -27,24 +27,24 @@ forever(function () { brick.showImage(images.informationAccept) if (down) { brick.showImage(images.informationForward) - motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations); + motors.largeC.run(65, 0.85, MoveUnit.Rotations); } else { brick.showImage(images.informationBackward) - motors.largeC.setSpeed(-65, 0.85, MoveUnit.Rotations); + motors.largeC.run(-65, 0.85, MoveUnit.Rotations); } - motors.largeB.setSpeed(20, 275, MoveUnit.Degrees) - motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds) - motors.largeB.setSpeed(-55) + motors.largeB.run(20, 275, MoveUnit.Degrees) + motors.mediumA.run(30, 1, MoveUnit.Seconds) + motors.largeB.run(-55) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop(); if (down) { - motors.largeC.setSpeed(-65, 0.86, MoveUnit.Rotations); + motors.largeC.run(-65, 0.86, MoveUnit.Rotations); } else { - motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations); + motors.largeC.run(65, 0.85, MoveUnit.Rotations); } - motors.largeB.setSpeed(20, 275, MoveUnit.Degrees); - motors.mediumA.setSpeed(-30, 90, MoveUnit.Degrees); - motors.largeB.setSpeed(-55) + motors.largeB.run(20, 275, MoveUnit.Degrees); + motors.mediumA.run(-30, 90, MoveUnit.Degrees); + motors.largeB.run(-55) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop() }) diff --git a/docs/examples/crane-labview.md b/docs/examples/crane-labview.md index 3e76f00a..1cccd1c0 100644 --- a/docs/examples/crane-labview.md +++ b/docs/examples/crane-labview.md @@ -5,14 +5,14 @@ function INI() { motors.largeB.setBrake(true) motors.largeC.setBrake(true) motors.mediumA.setBrake(true) - motors.largeB.setSpeed(-50) + motors.largeB.run(-50) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop(); - motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds); - motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees); - motors.largeC.setSpeed(50) + motors.mediumA.run(30, 1, MoveUnit.Seconds); + motors.mediumA.run(-50, 90, MoveUnit.Degrees); + motors.largeC.run(50) sensors.touch1.pauseUntil(ButtonEvent.Pressed); - motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations); + motors.largeC.run(-50, 0.86, MoveUnit.Rotations); } INI() @@ -27,24 +27,24 @@ forever(function () { brick.showImage(images.informationAccept) if (down) { brick.showImage(images.informationForward) - motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations); + motors.largeC.run(65, 0.85, MoveUnit.Rotations); } else { brick.showImage(images.informationBackward) - motors.largeC.setSpeed(-65, 0.85, MoveUnit.Rotations); + motors.largeC.run(-65, 0.85, MoveUnit.Rotations); } - motors.largeB.setSpeed(20, 275, MoveUnit.Degrees) - motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds) - motors.largeB.setSpeed(-55) + motors.largeB.run(20, 275, MoveUnit.Degrees) + motors.mediumA.run(30, 1, MoveUnit.Seconds) + motors.largeB.run(-55) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop(); if (down) { - motors.largeC.setSpeed(-65, 0.86, MoveUnit.Rotations); + motors.largeC.run(-65, 0.86, MoveUnit.Rotations); } else { - motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations); + motors.largeC.run(65, 0.85, MoveUnit.Rotations); } - motors.largeB.setSpeed(20, 275, MoveUnit.Degrees); - motors.mediumA.setSpeed(-30, 90, MoveUnit.Degrees); - motors.largeB.setSpeed(-55) + motors.largeB.run(20, 275, MoveUnit.Degrees); + motors.mediumA.run(-30, 90, MoveUnit.Degrees); + motors.largeB.run(-55) pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25); motors.largeB.stop() }) diff --git a/docs/examples/gyro-boy-labview.md b/docs/examples/gyro-boy-labview.md index 484259c5..fd444dac 100644 --- a/docs/examples/gyro-boy-labview.md +++ b/docs/examples/gyro-boy-labview.md @@ -137,8 +137,8 @@ forever(function () { GM(); EQ(); cntrl(); - motors.largeA.setSpeed(lpwr) - motors.largeD.setSpeed(rpwr) + motors.largeA.run(lpwr) + motors.largeD.run(rpwr) CHK() let t2 = control.timer1.millis(); let p = 5 - (t2 - t1); @@ -196,9 +196,9 @@ forever(function () { Cstr = 0; oldDr = Cdrv; Cdrv = -10; - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); - motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees); - motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); + motors.mediumC.run(-30, 60, MoveUnit.Degrees); + motors.mediumC.run(30, 30, MoveUnit.Degrees); if (Math.randomRange(-1, 1) >= 1) Cstr = 70; else diff --git a/docs/examples/line-follower-pid.md b/docs/examples/line-follower-pid.md index 744c75dc..da06bd62 100644 --- a/docs/examples/line-follower-pid.md +++ b/docs/examples/line-follower-pid.md @@ -43,7 +43,7 @@ forever(function () { motors.largeBC.steer(P + (I + D), 100) lasterror = error if (brick.buttonEnter.wasPressed()) { - motors.largeBC.setSpeed(0) + motors.largeBC.run(0) brick.buttonDown.pauseUntil(ButtonEvent.Bumped) } }) diff --git a/docs/labview.md b/docs/labview.md index cb272bfb..dcc8d398 100644 --- a/docs/labview.md +++ b/docs/labview.md @@ -14,7 +14,7 @@ Take a look a the LabView program below: it **starts**, turns on motor A, waits The blocks in MakeCode have similar functions and go together in the same way: they snap into the ``||loops:on start||`` block and then connect to each other vertically. ```blocks -motors.largeA.setSpeed(50) +motors.largeA.run(50) pause(1000) motors.largeA.stop() ``` @@ -22,7 +22,7 @@ motors.largeA.stop() Any block program can be converted to JavaScript and you can edit it as lines of code too. ```typescript -motors.largeA.setSpeed(50) +motors.largeA.run(50) pause(1000) motors.largeA.stop() ``` @@ -40,10 +40,10 @@ This program controls a large motor on port A in several different ways. It sets ![Single motor blocks](/static/labview/motors.png) ```blocks -motors.largeA.setSpeed(50); -motors.largeA.setSpeed(50, 1000, MoveUnit.MilliSeconds); -motors.largeA.setSpeed(50, 360, MoveUnit.Degrees); -motors.largeA.setSpeed(50, 1, MoveUnit.Rotations); +motors.largeA.run(50); +motors.largeA.run(50, 1000, MoveUnit.MilliSeconds); +motors.largeA.run(50, 360, MoveUnit.Degrees); +motors.largeA.run(50, 1, MoveUnit.Rotations); motors.largeA.stop(); ``` @@ -83,7 +83,7 @@ By default, all motors coast when any command used to move finishes. You can kee ```blocks motors.largeD.setBrake(true); -motors.largeD.setSpeed(50, 1, MoveUnit.Rotations) +motors.largeD.run(50, 1, MoveUnit.Rotations) ``` ## Inverting and regulating motors @@ -132,7 +132,7 @@ It is quite common to have to wait for a task to finish or for a sensor state to ![pause for time](/static/labview/pausefortime.png) ```blocks -motors.largeD.setSpeed(50) +motors.largeD.run(50) pause(1000) motors.largeD.stop(); ``` @@ -140,7 +140,7 @@ motors.largeD.stop(); ![pause for touch](/static/labview/pausefortouch.png) ```blocks -motors.largeD.setSpeed(50) +motors.largeD.run(50) sensors.touch1.pauseUntil(ButtonEvent.Pressed) motors.largeD.stop(); ``` @@ -148,7 +148,7 @@ motors.largeD.stop(); ![pause for distance](/static/labview/pausefordistance.png) ```blocks -motors.largeD.setSpeed(50) +motors.largeD.run(50) sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear) motors.largeD.stop(); ``` @@ -156,7 +156,7 @@ motors.largeD.stop(); You can also use the ``||loops:pause until||`` block to wait on any [boolean](/types/boolean) expression. As your program runs, it waits until the condition (expression) inside becomes true. ```blocks -motors.largeD.setSpeed(50) +motors.largeD.run(50) pauseUntil(() => sensors.touch1.isPressed()) motors.largeD.stop() ``` @@ -167,8 +167,8 @@ motors.largeD.stop() ```blocks forever(() => { - motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); - motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); + motors.largeD.run(50, 1, MoveUnit.Rotations); + motors.largeD.run(-50, 1, MoveUnit.Rotations); }) ``` @@ -176,13 +176,13 @@ forever(() => { ```blocks for(let i = 0; i < 10; i++) { - motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); - motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); + motors.largeD.run(50, 1, MoveUnit.Rotations); + motors.largeD.run(-50, 1, MoveUnit.Rotations); } let k = 0; while(k < 10) { - motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); - motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); + motors.largeD.run(50, 1, MoveUnit.Rotations); + motors.largeD.run(-50, 1, MoveUnit.Rotations); k++; } ``` @@ -195,7 +195,7 @@ while(k < 10) { let light = 0; forever(function () { light = sensors.color3.light(LightIntensityMode.Reflected); - motors.largeD.setSpeed(light) + motors.largeD.run(light) }) ``` @@ -207,8 +207,8 @@ You can start up multiple ``||loops:forever||`` loops that will run at the same ```blocks forever(() => { - motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); - motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); + motors.largeD.run(50, 1, MoveUnit.Rotations); + motors.largeD.run(-50, 1, MoveUnit.Rotations); }) forever(() => { brick.showImage(images.eyesMiddleRight) @@ -227,7 +227,7 @@ The ``||logic:if||`` block allows you to run different code depending on whether ```blocks forever(function() { if(sensors.touch1.isPressed()) { - motors.largeD.setSpeed(50) + motors.largeD.run(50) } else { motors.largeD.stop() } diff --git a/docs/lessons/line-detection.md b/docs/lessons/line-detection.md index c9c0bff5..1ad526cc 100644 --- a/docs/lessons/line-detection.md +++ b/docs/lessons/line-detection.md @@ -213,13 +213,13 @@ music.playSoundEffect(sounds.systemGeneralAlert) } while (true) { while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright) - motors.largeB.setSpeed(10) - motors.largeC.setSpeed(-10) + motors.largeB.run(10) + motors.largeC.run(-10) } while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright) - motors.largeA.setSpeed(-10) - motors.largeA.setSpeed(10) + motors.largeA.run(-10) + motors.largeA.run(10) } } ``` @@ -235,13 +235,13 @@ You will need to constantly debug your program in order to make your robot trave ```blocks while (true) { while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright) - motors.largeB.setSpeed(10) - motors.largeC.setSpeed(-10) + motors.largeB.run(10) + motors.largeC.run(-10) } while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright) - motors.largeB.setSpeed(-10) - motors.largeC.setSpeed(10) + motors.largeB.run(-10) + motors.largeC.run(10) } } ``` diff --git a/docs/maker/puppet.md b/docs/maker/puppet.md index b651f0a7..93572b65 100644 --- a/docs/maker/puppet.md +++ b/docs/maker/puppet.md @@ -4,11 +4,11 @@ Use this program with the Programmable Brick and Large Motor. ```blocks forever(function () { - motors.largeA.setSpeed(30) + motors.largeA.run(30) pause(100) motors.largeA.stop() music.playSoundEffectUntilDone(sounds.animalsCatPurr) - motors.largeA.setSpeed(-30) + motors.largeA.run(-30) pause(100) motors.largeA.stop() }) diff --git a/docs/maker/sound-machine.md b/docs/maker/sound-machine.md index 3f19f747..24f013da 100644 --- a/docs/maker/sound-machine.md +++ b/docs/maker/sound-machine.md @@ -4,9 +4,9 @@ This example program combined with the small model will make a beat and rhythm o ```blocks forever(function () { - motors.largeA.setSpeed(50) + motors.largeA.run(50) pause(200) - motors.largeA.setSpeed(100) + motors.largeA.run(100) pause(200) }) ``` \ No newline at end of file diff --git a/docs/reference/motors.md b/docs/reference/motors.md index 64abbd95..a1812d1c 100644 --- a/docs/reference/motors.md +++ b/docs/reference/motors.md @@ -3,7 +3,7 @@ ## Motion ```cards -motors.largeA.setSpeed(50) +motors.largeA.run(50) motors.largeAB.tank(50, 50) motors.largeAB.steer(0, 50) motors.largeA.pauseUntilReady() diff --git a/docs/reference/motors/motor/angle.md b/docs/reference/motors/motor/angle.md index a04d8485..9d139d86 100644 --- a/docs/reference/motors/motor/angle.md +++ b/docs/reference/motors/motor/angle.md @@ -19,7 +19,7 @@ Reset the motor connected to port **A** and run it for for 2 seconds at a speed ```blocks let motorAngle = 0; motors.largeA.reset() -motors.largeA.setSpeed(45) +motors.largeA.run(45) pause(2000) motors.largeA.stop() motorAngle = motors.largeA.angle() diff --git a/docs/reference/motors/motor/clear-counts.md b/docs/reference/motors/motor/clear-counts.md index d7c04fe1..8ec43d0f 100644 --- a/docs/reference/motors/motor/clear-counts.md +++ b/docs/reference/motors/motor/clear-counts.md @@ -15,11 +15,11 @@ See if the motor turns the same number of times for each of two count periods. R ```blocks let tachoCount = 0; motors.largeA.reset() -motors.largeA.setSpeed(50) +motors.largeA.run(50) pause(10000) tachoCount = motors.largeA.tacho() motors.largeA.clearCounts() -motors.largeA.setSpeed(50) +motors.largeA.run(50) pause(10000) if (tachoCount == motors.largeA.tacho()) { brick.showString("Motor turns equal.", 1) diff --git a/docs/reference/motors/motor/reset.md b/docs/reference/motors/motor/reset.md index b968a9c9..3d8a9ffd 100644 --- a/docs/reference/motors/motor/reset.md +++ b/docs/reference/motors/motor/reset.md @@ -13,12 +13,12 @@ The motor's speed is set back to `0` and the **tacho**, **angle**, and **speed** See what the angle count is when a motor is stopped. Then, try it again after a reset. ```blocks -motors.largeA.setSpeed(30) +motors.largeA.run(30) pause(2000) motors.largeA.stop() brick.showString("Angle count:", 1) brick.showNumber(motors.largeA.angle(), 2) -motors.largeA.setSpeed(30) +motors.largeA.run(30) pause(2000) motors.largeA.reset() brick.showString("Angle count:", 4) diff --git a/docs/reference/motors/motor/set-speed.md b/docs/reference/motors/motor/run.md similarity index 82% rename from docs/reference/motors/motor/set-speed.md rename to docs/reference/motors/motor/run.md index b5c75c37..0a3a4ea7 100644 --- a/docs/reference/motors/motor/set-speed.md +++ b/docs/reference/motors/motor/run.md @@ -1,9 +1,9 @@ -# set Speed +# run Set the rotation speed of the motor as a percentage of maximum speed. ```sig -motors.largeA.setSpeed(50) +motors.largeA.run(50) ``` The speed setting is a pecentage 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. @@ -19,7 +19,7 @@ If you use a number of milliseconds as movement units, then you don't need to in To run the motor for 500 milliseconds: ```block -motors.largeA.setSpeed(50, 500) +motors.largeA.run(50, 500) ``` ## ~ @@ -28,19 +28,19 @@ Here is how you use each different movement unit to run the motor for a fixed ro ```typescript // Run motor for 700 Milliseconds. -motors.largeA.setSpeed(25, 700, MoveUnit.MilliSeconds); +motors.largeA.run(25, 700, MoveUnit.MilliSeconds); // Run motor for 700 Milliseconds again but no units specified. -motors.largeA.setSpeed(25, 700); +motors.largeA.run(25, 700); // Run the motor for 45 seconds -motors.largeA.setSpeed(50, 45, MoveUnit.Seconds); +motors.largeA.run(50, 45, MoveUnit.Seconds); // Turn the motor for 270 degrees -motors.largeA.setSpeed(50, 270, MoveUnit.Degrees) +motors.largeA.run(50, 270, MoveUnit.Degrees) // Turn the motor at full speed for 9 full rotations -motors.largeA.setSpeed(100, 9, MoveUnit.Rotations); +motors.largeA.run(100, 9, MoveUnit.Rotations); ``` ## Parameters @@ -56,7 +56,7 @@ motors.largeA.setSpeed(100, 9, MoveUnit.Rotations); Turning the motor in the opposite direction (reverse) is simple. Reverse is just a negative speed setting. To drive the motor in reverse at 25% speed: ```block -motors.largeB.setSpeed(-25) +motors.largeB.run(-25) ``` ## ~ @@ -68,7 +68,7 @@ motors.largeB.setSpeed(-25) Run the motor connected to port **A** continuously. Pause 20 seconds and then stop the motor. ```blocks -motors.largeA.setSpeed(75) +motors.largeA.run(75) pause(20000) motors.largeA.stop() ``` @@ -78,7 +78,7 @@ motors.largeA.stop() Run the motor connected to port **A** in reverse. Pause 5 seconds and then stop the motor. ```blocks -motors.largeA.setSpeed(-60) +motors.largeA.run(-60) pause(5000) motors.largeA.stop() ``` @@ -88,7 +88,7 @@ motors.largeA.stop() Run the motor connected to port **B** for 35 full rotations and then stop. ```blocks -motors.largeB.setSpeed(50, 35, MoveUnit.Rotations) +motors.largeB.run(50, 35, MoveUnit.Rotations) ``` ## See also diff --git a/docs/reference/motors/motor/set-brake.md b/docs/reference/motors/motor/set-brake.md index 10f100cf..6c215ebd 100644 --- a/docs/reference/motors/motor/set-brake.md +++ b/docs/reference/motors/motor/set-brake.md @@ -19,7 +19,7 @@ Also, you can use the brake to do simple skid steering for your brick. Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and set the brake. ```blocks -motors.largeA.setSpeed(30) +motors.largeA.run(30) pause(2000) motors.largeA.stop() motors.largeA.setBrake(true) diff --git a/docs/reference/motors/motor/set-inverted.md b/docs/reference/motors/motor/set-inverted.md index d2de503e..db29d2d2 100644 --- a/docs/reference/motors/motor/set-inverted.md +++ b/docs/reference/motors/motor/set-inverted.md @@ -17,12 +17,12 @@ You use a positive value (some number greater than `0`) to drive you motor in th Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and switch the direciton of rotation. Run the motor at a speed of `-30`. Watch and see if the motor turns in the same direction as before. ```blocks -motors.largeA.setSpeed(30) +motors.largeA.run(30) pause(2000) motors.largeA.stop() pause(2000) motors.largeA.setInverted(true) -motors.largeA.setSpeed(-30) +motors.largeA.run(-30) pause(2000) motors.largeA.stop() ``` diff --git a/docs/reference/motors/motor/set-regulated.md b/docs/reference/motors/motor/set-regulated.md index a1779586..dd6e9b03 100644 --- a/docs/reference/motors/motor/set-regulated.md +++ b/docs/reference/motors/motor/set-regulated.md @@ -22,11 +22,11 @@ Turn off the speed regulation for the motor connected to port **A**. ```blocks motors.largeA.setRegulated(false) -motors.largeA.setSpeed(75) +motors.largeA.run(75) pause(20000) motors.largeA.stop() ``` ## See also -[set speed](/reference/motors/motor/set-speed), [stop](/reference/motors/motor/stop) +[run](/reference/motors/motor/run), [stop](/reference/motors/motor/stop) diff --git a/docs/reference/motors/motor/speed.md b/docs/reference/motors/motor/speed.md index d5ec2d39..8b0461ba 100644 --- a/docs/reference/motors/motor/speed.md +++ b/docs/reference/motors/motor/speed.md @@ -6,7 +6,7 @@ Get the current speed of motor rotation as a percentage of maximum speed. motors.largeA.speed() ``` -The actual speed of the motor is the same or very close to it's current speed setting when the motor is regulated. If not regulated, the actual speed can change from the set speed when a force, or load, is applied to it. +The actual speed of the motor is the same or very close to it's current speed setting when the motor is regulated. If not regulated, the actual speed can change from the set point speed when a force, or load, is applied to it. ## Returns @@ -18,7 +18,7 @@ Turn speed regulation off and report the actual speed of the large motor in the ```blocks motors.largeA.setRegulated(false) -motors.largeA.setSpeed(55) +motors.largeA.run(55) brick.showString("Actual speed:", 1) for (let i = 0; i < 30; i++) { pause(500) diff --git a/docs/reference/motors/motor/stop.md b/docs/reference/motors/motor/stop.md index fa091312..3cf47397 100644 --- a/docs/reference/motors/motor/stop.md +++ b/docs/reference/motors/motor/stop.md @@ -13,11 +13,11 @@ The motor stops but any motion caused from previously running the motor continue Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and wait for 2 seconds, then continue at a speed of `50`. ```blocks -motors.largeA.setSpeed(30) +motors.largeA.run(30) pause(2000) motors.largeA.stop() pause(2000) -motors.largeA.setSpeed(50) +motors.largeA.run(50) ``` ## See also diff --git a/docs/reference/motors/motor/tacho.md b/docs/reference/motors/motor/tacho.md index 8a90ff94..9a7c298c 100644 --- a/docs/reference/motors/motor/tacho.md +++ b/docs/reference/motors/motor/tacho.md @@ -33,12 +33,12 @@ A standard way to know how fast a motor is turning is by measuring its _revoluti Run the motor connected to port **A** at half speed for 5 seconds. Display the number of full rotations on the screen. ```blocks -motors.largeA.setSpeed(50) +motors.largeA.run(50) pause(5000) motors.largeA.stop() brick.showString("Motor rotations:", 1) brick.showNumber(motors.largeA.tacho() / 360, 3) -motors.largeA.setSpeed(50) +motors.largeA.run(50) ``` ## See also diff --git a/docs/reference/motors/synced/steer.md b/docs/reference/motors/synced/steer.md index a52c99f3..b9155176 100644 --- a/docs/reference/motors/synced/steer.md +++ b/docs/reference/motors/synced/steer.md @@ -18,7 +18,7 @@ The speed setting is a pecentage of the motor's full speed. Full speed is the sp If you use just the **speed** number, the motors run continously and won't stop unless you tell them to. You can also give a value for a certain amount of distance you want the motors to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations. -If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [set speed](/reference/motors/motor/set-speed) shows how to use different movement units. +If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [run](/reference/motors/motor/run) shows how to use different movement units. ## Parameters @@ -81,4 +81,4 @@ motors.stopAll() ## See also -[tank](/reference/motors/synced/tank), [set speed](/reference/motors/motor/set-speed) \ No newline at end of file +[tank](/reference/motors/synced/tank), [run](/reference/motors/motor/run) \ No newline at end of file diff --git a/docs/reference/motors/synced/tank.md b/docs/reference/motors/synced/tank.md index 42152530..53c4aab2 100644 --- a/docs/reference/motors/synced/tank.md +++ b/docs/reference/motors/synced/tank.md @@ -14,7 +14,7 @@ The speed setting is a pecentage of the motor's full speed. Full speed is the sp If you use just the **speed** number, the motors run continously and won't stop unless you tell them to. You can also give a value for a certain amount of distance you want the motors to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations. -If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [set speed](/reference/motors/motor/set-speed) shows how to use different movement units. +If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [run](/reference/motors/motor/run) shows how to use different movement units. ## Parameters @@ -78,4 +78,4 @@ motors.stopAll() ## See also -[steer](/reference/motors/synced/steer), [set speed](/reference/motors/motor/set-speed) \ No newline at end of file +[steer](/reference/motors/synced/steer), [run](/reference/motors/motor/run) \ No newline at end of file diff --git a/libs/core/output.ts b/libs/core/output.ts index 03d1ef54..b0fa3e4c 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -134,17 +134,17 @@ namespace motors { protected _brake: boolean; private _initialized: boolean; private _init: () => void; - private _setSpeed: (speed: number) => void; + private _run: (speed: number) => void; private _move: (steps: boolean, stepsOrTime: number, speed: number) => void; - constructor(port: Output, init: () => void, setSpeed: (speed: number) => void, move: (steps: boolean, stepsOrTime: number, speed: number) => void) { + constructor(port: Output, init: () => void, run: (speed: number) => void, move: (steps: boolean, stepsOrTime: number, speed: number) => void) { super(); this._port = port; this._portName = outputToName(this._port); this._brake = false; this._initialized = false; this._init = init; - this._setSpeed = setSpeed; + this._run = run; this._move = move; } @@ -218,17 +218,17 @@ namespace motors { } /** - * Sets the motor speed for limited time or distance. + * Runs the motor at a given speed for limited time or distance. * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50 * @param value (optional) measured distance or rotation * @param unit (optional) unit of the value */ - //% blockId=motorSetSpeed block="set %motor speed to %speed=motorSpeedPicker|\\%||for %value %unit" + //% blockId=motorRun block="run %motor at %speed=motorSpeedPicker|\\%||for %value %unit" //% weight=100 blockGap=8 //% group="Move" //% expandableArgumentMode=toggle - //% help=motors/motor/set-speed - setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) { + //% help=motors/motor/run + run(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) { this.init(); speed = Math.clamp(-100, 100, speed >> 0); // stop if speed is 0 @@ -238,7 +238,7 @@ namespace motors { } // special: 0 is infinity if (value == 0) { - this._setSpeed(speed); + this._run(speed); return; } // timed motor moves diff --git a/libs/tests/README.md b/libs/tests/README.md index 4988cf97..03a60c4a 100644 --- a/libs/tests/README.md +++ b/libs/tests/README.md @@ -7,8 +7,8 @@ A unit test framework Tests are registered as event handlers. They will automatically run once ``on start`` is finished. ```blocks -tests.test("lgB set speed 10", () => { - motors.largeB.setSpeed(10); +tests.test("lgB run 10", () => { + motors.largeB.run(10); pause(100) tests.assertClose("speedB", 10, motors.largeB.speed(), 2) }); diff --git a/package.json b/package.json index 0e6df9f3..3c815d9f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "dependencies": { "pxt-common-packages": "0.19.5", - "pxt-core": "3.4.3" + "pxt-core": "3.4.5" }, "scripts": { "test": "node node_modules/pxt-core/built/pxt.js travis" diff --git a/tests/motors.ts b/tests/motors.ts index 71ec9934..c52cd316 100644 --- a/tests/motors.ts +++ b/tests/motors.ts @@ -1,17 +1,17 @@ // add tests package -tests.test("lgB set speed 10", () => { - motors.largeB.setSpeed(10); +tests.test("lgB run 10", () => { + motors.largeB.run(10); pause(500) tests.assertClose("speedB", 10, motors.largeB.speed(), 2) }); -tests.test("lgB set speed 25 (reversed)", () => { +tests.test("lgB run 25 (reversed)", () => { motors.largeB.setInverted(true) - motors.largeB.setSpeed(25) + motors.largeB.run(25) pause(500) tests.assertClose("speedB", -25, motors.largeB.speed(), 2) }); -tests.test("lgBC set speed 5", () => { - motors.largeBC.setSpeed(5) +tests.test("lgBC run 5", () => { + motors.largeBC.run(5) pause(500) tests.assertClose("speedB", 5, motors.largeB.speed(), 1); tests.assertClose("speedC", 5, motors.largeC.speed(), 1);