From daa88b299dc550d09dc367b6db6bbeb93c792bbd Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 14 Feb 2018 16:05:31 -0800 Subject: [PATCH] replacing loops.pause -> pause, loops.forever -> forever --- docs/blocks/loops.md | 4 ++-- docs/coding/ignition-2.md | 2 +- docs/coding/ignition-3.md | 2 +- docs/coding/light-the-way-1.md | 2 +- docs/coding/reverse-beeper-1.md | 4 ++-- docs/coding/reverse-beeper-2.md | 4 ++-- docs/coding/reverse-beeper-3.md | 2 +- docs/coding/reversing-the-robot-1.md | 4 ++-- docs/coding/reversing-the-robot-2.md | 4 ++-- docs/coding/reversing-the-robot-3.md | 4 ++-- docs/coding/roaming-1.md | 2 +- docs/coding/roaming-2.md | 2 +- docs/coding/three-point-turn-1.md | 6 ++--- docs/coding/three-point-turn-2.md | 6 ++--- docs/coding/three-point-turn-3.md | 6 ++--- docs/coding/traffic-lights-3.md | 2 +- docs/examples/core-set/gyroboy-blocks.md | 4 ++-- docs/examples/core-set/gyroboy-labview.md | 16 ++++++------- docs/examples/core-set/puppy-labview.md | 20 ++++++++-------- docs/examples/core-set/robotarm-labview.md | 2 +- docs/examples/crane-labview.md | 2 +- docs/examples/gyro-boy-labview.md | 16 ++++++------- docs/examples/line-follower-pid.md | 4 ++-- docs/labview.md | 24 +++++++++---------- docs/maker/puppet.md | 6 ++--- docs/maker/sound-machine.md | 6 ++--- docs/reference/brick/battery-level.md | 4 ++-- docs/reference/brick/button/is-pressed.md | 2 +- docs/reference/brick/clear-screen.md | 2 +- docs/reference/brick/set-status-light.md | 10 ++++---- docs/reference/motors/motor/angle.md | 2 +- docs/reference/motors/motor/clear-counts.md | 4 ++-- docs/reference/motors/motor/reset.md | 4 ++-- docs/reference/motors/motor/set-brake.md | 2 +- docs/reference/motors/motor/set-inverted.md | 6 ++--- docs/reference/motors/motor/set-regulated.md | 2 +- docs/reference/motors/motor/set-speed.md | 4 ++-- docs/reference/motors/motor/speed.md | 2 +- docs/reference/motors/motor/stop.md | 4 ++-- docs/reference/motors/motor/tacho.md | 2 +- docs/reference/motors/stop-all.md | 2 +- docs/reference/motors/synced/steer.md | 4 ++-- docs/reference/motors/synced/tank.md | 6 ++--- libs/base/shims.d.ts | 8 +++---- libs/color-sensor/color.ts | 2 +- .../sensors/color-sensor/ambient-light.md | 2 +- .../reference/sensors/color-sensor/color.md | 2 +- .../sensors/color-sensor/reflected-light.md | 2 +- libs/core/input.ts | 12 +++++----- libs/core/output.ts | 2 +- libs/core/test.ts | 8 +++---- libs/core/timer.ts | 2 +- libs/ev3/startup.ts | 2 +- .../docs/reference/sensors/gyro/rate.md | 2 +- libs/gyro-sensor/gyro.ts | 6 ++--- libs/mood/mood.ts | 2 +- libs/music/test.ts | 6 ++--- libs/tests/README.md | 2 +- .../sensors/touch-sensor/is-pressed.md | 2 +- .../sensors/touch-sensor/was-pressed.md | 4 ++-- tests/colors.ts | 4 ++-- tests/motors.ts | 14 +++++------ 62 files changed, 151 insertions(+), 151 deletions(-) diff --git a/docs/blocks/loops.md b/docs/blocks/loops.md index e7ddc85c..f0e0bf94 100644 --- a/docs/blocks/loops.md +++ b/docs/blocks/loops.md @@ -3,6 +3,6 @@ ### #specific ```cards -loops.forever(() => {}); -loops.pause(0) +forever(() => {}); +pause(0) ``` \ No newline at end of file diff --git a/docs/coding/ignition-2.md b/docs/coding/ignition-2.md index be38394e..61bafd21 100644 --- a/docs/coding/ignition-2.md +++ b/docs/coding/ignition-2.md @@ -7,6 +7,6 @@ while (true) { music.playSoundEffectUntilDone(sounds.mechanicalMotorStart) music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle); } - loops.pause(1); + pause(1); } ``` diff --git a/docs/coding/ignition-3.md b/docs/coding/ignition-3.md index c85dcceb..0b17c54c 100644 --- a/docs/coding/ignition-3.md +++ b/docs/coding/ignition-3.md @@ -8,6 +8,6 @@ while (true) { music.playSoundEffectUntilDone(sounds.mechanicalMotorStart) music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle); } - loops.pause(1); + pause(1); } ``` diff --git a/docs/coding/light-the-way-1.md b/docs/coding/light-the-way-1.md index 7341893c..19a67e48 100644 --- a/docs/coding/light-the-way-1.md +++ b/docs/coding/light-the-way-1.md @@ -3,7 +3,7 @@ ```blocks sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () { brick.showImage(images.objectsLightOn) - loops.pause(5000) + pause(5000) brick.clearScreen() }) ``` \ No newline at end of file diff --git a/docs/coding/reverse-beeper-1.md b/docs/coding/reverse-beeper-1.md index daf4588f..c77214a5 100644 --- a/docs/coding/reverse-beeper-1.md +++ b/docs/coding/reverse-beeper-1.md @@ -1,9 +1,9 @@ # Reverse Beeper Activity 1 ```blocks -loops.forever(function () { +forever(function () { music.playTone(440, sensors.ultrasonic4.distance()); - loops.pause(50) + pause(50) }) motors.largeBC.setSpeed(-20); sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear); diff --git a/docs/coding/reverse-beeper-2.md b/docs/coding/reverse-beeper-2.md index fea694b7..209b969b 100644 --- a/docs/coding/reverse-beeper-2.md +++ b/docs/coding/reverse-beeper-2.md @@ -1,10 +1,10 @@ # Reverse Beeper Activity 2 ```blocks -loops.forever(function () { +forever(function () { if (motors.largeB.speed() != 0 && sensors.ultrasonic4.distance() < 20) { music.playTone(440, sensors.ultrasonic4.distance()); - loops.pause(50) + pause(50) } }) motors.largeBC.setSpeed(-20); diff --git a/docs/coding/reverse-beeper-3.md b/docs/coding/reverse-beeper-3.md index 7e12d9d2..83406767 100644 --- a/docs/coding/reverse-beeper-3.md +++ b/docs/coding/reverse-beeper-3.md @@ -13,7 +13,7 @@ control.runInParallel(function () { while (beep) { if (sensors.ultrasonic4.distance() < 20) { music.playTone(440, sensors.ultrasonic4.distance()) - loops.pause(50) + pause(50) } } }) diff --git a/docs/coding/reversing-the-robot-1.md b/docs/coding/reversing-the-robot-1.md index ab6924d2..fc31ac03 100644 --- a/docs/coding/reversing-the-robot-1.md +++ b/docs/coding/reversing-the-robot-1.md @@ -5,10 +5,10 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.setSpeed(50) sensors.touch1.pauseUntil(ButtonEvent.Pressed) motors.largeBC.setSpeed(0) - loops.pause(1000) + pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) motors.largeBC.setSpeed(-50) - loops.pause(2000) + pause(2000) motors.largeBC.setSpeed(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 0452f3b1..49b8cadd 100644 --- a/docs/coding/reversing-the-robot-2.md +++ b/docs/coding/reversing-the-robot-2.md @@ -6,10 +6,10 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.setSpeed(50) sensors.touch2.pauseUntil(ButtonEvent.Pressed) motors.largeBC.setSpeed(0) - loops.pause(1000) + pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) motors.largeBC.setSpeed(-50) - loops.pause(2000) + pause(2000) motors.largeBC.setSpeed(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 1d09de79..cb9268a5 100644 --- a/docs/coding/reversing-the-robot-3.md +++ b/docs/coding/reversing-the-robot-3.md @@ -9,11 +9,11 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { sensors.touch2.pauseUntil(ButtonEvent.Pressed) brick.showImage(images.eyesTiredMiddle) motors.largeBC.setSpeed(0) - loops.pause(1000) + pause(1000) brick.setStatusLight(StatusLight.OrangeFlash) brick.showImage(images.eyesDizzy) motors.largeBC.setSpeed(-50) - loops.pause(2000) + pause(2000) motors.largeBC.setSpeed(0) }) ``` \ No newline at end of file diff --git a/docs/coding/roaming-1.md b/docs/coding/roaming-1.md index 689fb7d5..9e085c3e 100644 --- a/docs/coding/roaming-1.md +++ b/docs/coding/roaming-1.md @@ -15,7 +15,7 @@ brick.buttonDown.onEvent(ButtonEvent.Bumped, function () { drive.push(5) }) pauseUntil(() => drive.length >= 5) -loops.pause(1000) +pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { diff --git a/docs/coding/roaming-2.md b/docs/coding/roaming-2.md index f20c4cae..f39b0075 100644 --- a/docs/coding/roaming-2.md +++ b/docs/coding/roaming-2.md @@ -19,7 +19,7 @@ brick.buttonDown.onEvent(ButtonEvent.Bumped, function () { music.playSoundEffectUntilDone(sounds.systemClick) }) brick.buttonEnter.pauseUntil(ButtonEvent.Bumped); -loops.pause(1000) +pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { diff --git a/docs/coding/three-point-turn-1.md b/docs/coding/three-point-turn-1.md index 741d5715..5d51772e 100644 --- a/docs/coding/three-point-turn-1.md +++ b/docs/coding/three-point-turn-1.md @@ -3,10 +3,10 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) - loops.pause(1500) + pause(1500) motors.largeBC.tank(-30, -75) - loops.pause(1000) + pause(1000) motors.largeBC.tank(50, 50) - loops.pause(3000) + pause(3000) }) ``` \ No newline at end of file diff --git a/docs/coding/three-point-turn-2.md b/docs/coding/three-point-turn-2.md index ef2d81e2..9745648f 100644 --- a/docs/coding/three-point-turn-2.md +++ b/docs/coding/three-point-turn-2.md @@ -3,12 +3,12 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) - loops.pause(1500) + pause(1500) motors.largeBC.tank(-30, -75) sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear); motors.largeBC.tank(0, 0) - loops.pause(1000) + pause(1000) motors.largeBC.tank(50, 50) - loops.pause(3000) + pause(3000) }) ``` \ No newline at end of file diff --git a/docs/coding/three-point-turn-3.md b/docs/coding/three-point-turn-3.md index ddc44dac..db39fbf4 100644 --- a/docs/coding/three-point-turn-3.md +++ b/docs/coding/three-point-turn-3.md @@ -3,13 +3,13 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) - loops.pause(1500) + pause(1500) motors.largeBC.tank(-30, -75) sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear); motors.largeBC.tank(0, 0) music.playSoundEffect(sounds.animalsDogBark1) - loops.pause(1000) + pause(1000) motors.largeBC.tank(50, 50) - loops.pause(3000) + pause(3000) }) ``` \ No newline at end of file diff --git a/docs/coding/traffic-lights-3.md b/docs/coding/traffic-lights-3.md index b10b786f..58344253 100644 --- a/docs/coding/traffic-lights-3.md +++ b/docs/coding/traffic-lights-3.md @@ -1,7 +1,7 @@ # Traffic Lights Activity 3 ```blocks -loops.forever(function () { +forever(function () { if (sensors.color3.light(LightIntensityMode.Reflected) < 15) { motors.largeBC.tank(30, 12) } else { diff --git a/docs/examples/core-set/gyroboy-blocks.md b/docs/examples/core-set/gyroboy-blocks.md index 5a2bcbe5..396e9404 100644 --- a/docs/examples/core-set/gyroboy-blocks.md +++ b/docs/examples/core-set/gyroboy-blocks.md @@ -127,7 +127,7 @@ sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () { } else { controlSteering = -70 } - loops.pause(4000) + pause(4000) music.playTone(2000, 100) controlSteering = 0 controlDrive = oldControlDrive @@ -162,7 +162,7 @@ sensors.color1.onColorDetected(ColorSensorColor.White, function () { }) timestep = 0.014 // main loop -loops.forever(function () { +forever(function () { reset() while (!fallen) { control.timer3.pauseUntil(5) diff --git a/docs/examples/core-set/gyroboy-labview.md b/docs/examples/core-set/gyroboy-labview.md index ad53894d..8a1199ed 100644 --- a/docs/examples/core-set/gyroboy-labview.md +++ b/docs/examples/core-set/gyroboy-labview.md @@ -36,7 +36,7 @@ function RST() { sensors.gyro2.reset() sensors.gyro2.rate() control.timer2.reset() - loops.pause(5000) + pause(5000) mSum = 0; mPos = 0; mD = 0; @@ -65,7 +65,7 @@ function OS() { gSum = gyro; gMx = Math.max(gMx, gyro) gMn = Math.min(gMn, gyro) - loops.pause(4); + pause(4); } } while (gMx - gMn > 2); gOS = gSum / 200; @@ -121,7 +121,7 @@ function CHK() { } // M -loops.forever(function () { +forever(function () { RST(); brick.showImage(images.eyesSleeping) OS() @@ -142,7 +142,7 @@ loops.forever(function () { CHK() let t2 = control.timer1.millis(); let p = 5 - (t2 - t1); - loops.pause(Math.max(1, p)) + pause(Math.max(1, p)) } motors.stopAll() st = 0; @@ -154,7 +154,7 @@ loops.forever(function () { }) // BHV -loops.forever(function () { +forever(function () { switch (st) { case 0: Cdrv = 0; @@ -162,7 +162,7 @@ loops.forever(function () { break; case 1: Cdrv = 40; - loops.pause(4000); + pause(4000); Cdrv = 0; music.playTone(1000, 100); st = 2; @@ -203,13 +203,13 @@ loops.forever(function () { Cstr = 70; else Cstr = -70; - loops.pause(4000); + pause(4000); music.playTone(2000, 100) Cstr = 0; Cdrv = oldDr; } break; } - loops.pause(80); + pause(80); }) ``` \ No newline at end of file diff --git a/docs/examples/core-set/puppy-labview.md b/docs/examples/core-set/puppy-labview.md index 0e95532f..8ad9ce66 100644 --- a/docs/examples/core-set/puppy-labview.md +++ b/docs/examples/core-set/puppy-labview.md @@ -21,7 +21,7 @@ let GTO = 0; function DN() { motors.largeAD.setBrake(true); motors.largeAD.tank(50, 50, 1, MoveUnit.Seconds); - loops.pause(100); + pause(100); motors.largeA.clearCounts() motors.largeD.clearCounts() } @@ -100,7 +100,7 @@ function UP() { pauseUntil(() => motors.largeA.angle() < -65); motors.largeA.stop(); - loops.pause(500); + pause(500); } } @@ -277,7 +277,7 @@ function NGR() { IS(4) music.playSoundEffect(sounds.animalsDogGrowl); UP(); - loops.pause(1500); + pause(1500); music.stopAllSounds() music.playSoundEffect(sounds.animalsDogBark1) P_C--; @@ -303,11 +303,11 @@ function PPP() { NS = false; IS(2); UP(); - loops.pause(100) + pause(100) motors.largeA.setSpeed(-30, 70, MoveUnit.Degrees); - loops.pause(800); + pause(800); music.playSoundEffect(sounds.mechanicalHorn1); - loops.pause(1000); + pause(1000); for(let i = 0; i < 3; ++i) { motors.largeA.setSpeed(-30, 20, MoveUnit.Degrees); motors.largeA.setSpeed(30, 20, MoveUnit.Degrees); @@ -324,10 +324,10 @@ function HPY() { for(let i = 0; i < 3; ++i) { music.playSoundEffect(sounds.animalsDogBark1); motors.largeAD.setSpeed(-100, 0.2, MoveUnit.Seconds); - loops.pause(300) + pause(300) motors.largeAD.setSpeed(10, 0.3, MoveUnit.Seconds) } - loops.pause(500); + pause(500); music.stopAllSounds(); DN(); RST(); @@ -347,7 +347,7 @@ function WKU() { MHT(0) DN() STL() - loops.pause(1000); + pause(1000); UP() CS(0;) } @@ -358,7 +358,7 @@ MNRH(); IS(1); UP(); RST(); -loops.forever(function () { +forever(function () { MON(); switch (DB_S) { case 0: diff --git a/docs/examples/core-set/robotarm-labview.md b/docs/examples/core-set/robotarm-labview.md index d5e9f278..77abc203 100644 --- a/docs/examples/core-set/robotarm-labview.md +++ b/docs/examples/core-set/robotarm-labview.md @@ -18,7 +18,7 @@ function INI() { INI() let down = false; -loops.forever(function () { +forever(function () { brick.showImage(images.informationQuestionMark) brick.setStatusLight(StatusLight.OrangePulse); pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed()) diff --git a/docs/examples/crane-labview.md b/docs/examples/crane-labview.md index 5aca874b..3e76f00a 100644 --- a/docs/examples/crane-labview.md +++ b/docs/examples/crane-labview.md @@ -18,7 +18,7 @@ function INI() { INI() let down = false; -loops.forever(function () { +forever(function () { brick.showImage(images.informationQuestionMark) brick.setStatusLight(StatusLight.OrangePulse); pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed()) diff --git a/docs/examples/gyro-boy-labview.md b/docs/examples/gyro-boy-labview.md index 1bb9bef5..484259c5 100644 --- a/docs/examples/gyro-boy-labview.md +++ b/docs/examples/gyro-boy-labview.md @@ -36,7 +36,7 @@ function RST() { sensors.gyro2.reset() sensors.gyro2.rate() control.timer2.reset() - loops.pause(5000) + pause(5000) mSum = 0; mPos = 0; mD = 0; @@ -65,7 +65,7 @@ function OS() { gSum = gyro; gMx = Math.max(gMx, gyro) gMn = Math.min(gMn, gyro) - loops.pause(4); + pause(4); } } while (gMx - gMn > 2); gOS = gSum / 200; @@ -121,7 +121,7 @@ function CHK() { } // M -loops.forever(function () { +forever(function () { RST(); brick.showImage(images.eyesSleeping) OS() @@ -142,7 +142,7 @@ loops.forever(function () { CHK() let t2 = control.timer1.millis(); let p = 5 - (t2 - t1); - loops.pause(Math.max(1, p)) + pause(Math.max(1, p)) } motors.stopAll() st = 0; @@ -154,7 +154,7 @@ loops.forever(function () { }) // BHV -loops.forever(function () { +forever(function () { switch (st) { case 0: Cdrv = 0; @@ -162,7 +162,7 @@ loops.forever(function () { break; case 1: Cdrv = 40; - loops.pause(4000); + pause(4000); Cdrv = 0; music.playTone(1000, 100); st = 2; @@ -203,13 +203,13 @@ loops.forever(function () { Cstr = 70; else Cstr = -70; - loops.pause(4000); + pause(4000); music.playTone(2000, 100) Cstr = 0; Cdrv = oldDr; } break; } - loops.pause(80); + pause(80); }) ``` \ No newline at end of file diff --git a/docs/examples/line-follower-pid.md b/docs/examples/line-follower-pid.md index cbe40d98..744c75dc 100644 --- a/docs/examples/line-follower-pid.md +++ b/docs/examples/line-follower-pid.md @@ -26,9 +26,9 @@ while (!(brick.buttonEnter.wasPressed())) { brick.showValue("min", min, 4) brick.showValue("max", v, 5) brick.showValue("setpoint", setpoint, 6) - loops.pause(100) + pause(100) } -loops.forever(function () { +forever(function () { brick.clearScreen() v = sensors.color3.light(LightIntensityMode.Reflected) brick.showValue("light", v, 1) diff --git a/docs/labview.md b/docs/labview.md index 7b80bd1f..cb272bfb 100644 --- a/docs/labview.md +++ b/docs/labview.md @@ -15,7 +15,7 @@ The blocks in MakeCode have similar functions and go together in the same way: t ```blocks motors.largeA.setSpeed(50) -loops.pause(1000) +pause(1000) motors.largeA.stop() ``` @@ -23,7 +23,7 @@ Any block program can be converted to JavaScript and you can edit it as lines of ```typescript motors.largeA.setSpeed(50) -loops.pause(1000) +pause(1000) motors.largeA.stop() ``` @@ -133,7 +133,7 @@ It is quite common to have to wait for a task to finish or for a sensor state to ```blocks motors.largeD.setSpeed(50) -loops.pause(1000) +pause(1000) motors.largeD.stop(); ``` @@ -166,7 +166,7 @@ motors.largeD.stop() ![Single loop](/static/labview/loopinfinite.png) ```blocks -loops.forever(() => { +forever(() => { motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); }) @@ -193,7 +193,7 @@ while(k < 10) { ```blocks let light = 0; -loops.forever(function () { +forever(function () { light = sensors.color3.light(LightIntensityMode.Reflected); motors.largeD.setSpeed(light) }) @@ -206,15 +206,15 @@ You can start up multiple ``||loops:forever||`` loops that will run at the same ![Multiple loops running at the same time](/static/labview/multipleloops.png) ```blocks -loops.forever(() => { +forever(() => { motors.largeD.setSpeed(50, 1, MoveUnit.Rotations); motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations); }) -loops.forever(() => { +forever(() => { brick.showImage(images.eyesMiddleRight) - loops.pause(1000) + pause(1000) brick.showImage(images.eyesMiddleLeft) - loops.pause(1000) + pause(1000) }) ``` @@ -225,7 +225,7 @@ The ``||logic:if||`` block allows you to run different code depending on whether ![Brake block](/static/labview/ife.png) ```blocks -loops.forever(function() { +forever(function() { if(sensors.touch1.isPressed()) { motors.largeD.setSpeed(50) } else { @@ -241,8 +241,8 @@ The ``||math:pick random||`` block returns a random number selected from a range ![Brake block](/static/labview/random.png) ```blocks -loops.forever(function () { +forever(function () { motors.largeBC.steer(Math.randomRange(-5, 5), 50) - loops.pause(100) + pause(100) }) ``` \ No newline at end of file diff --git a/docs/maker/puppet.md b/docs/maker/puppet.md index be86c0fd..b651f0a7 100644 --- a/docs/maker/puppet.md +++ b/docs/maker/puppet.md @@ -3,13 +3,13 @@ Use this program with the Programmable Brick and Large Motor. ```blocks -loops.forever(function () { +forever(function () { motors.largeA.setSpeed(30) - loops.pause(100) + pause(100) motors.largeA.stop() music.playSoundEffectUntilDone(sounds.animalsCatPurr) motors.largeA.setSpeed(-30) - loops.pause(100) + pause(100) motors.largeA.stop() }) ``` diff --git a/docs/maker/sound-machine.md b/docs/maker/sound-machine.md index 30f81e6d..3f19f747 100644 --- a/docs/maker/sound-machine.md +++ b/docs/maker/sound-machine.md @@ -3,10 +3,10 @@ This example program combined with the small model will make a beat and rhythm on any surface when the program is run. ```blocks -loops.forever(function () { +forever(function () { motors.largeA.setSpeed(50) - loops.pause(200) + pause(200) motors.largeA.setSpeed(100) - loops.pause(200) + pause(200) }) ``` \ No newline at end of file diff --git a/docs/reference/brick/battery-level.md b/docs/reference/brick/battery-level.md index e2a4f2a7..18b54f27 100644 --- a/docs/reference/brick/battery-level.md +++ b/docs/reference/brick/battery-level.md @@ -16,7 +16,7 @@ Show the battery level percentage on the screen. Also, show a green light if the ```blocks let battery = 0; -loops.forever(function() { +forever(function() { brick.showString("Battery level:", 1) brick.showNumber(battery, 2) battery = brick.batteryLevel(); @@ -28,6 +28,6 @@ loops.forever(function() { } else { brick.setStatusLight(StatusLight.RedPulse) } - loops.pause(30000) + pause(30000) }) ``` \ No newline at end of file diff --git a/docs/reference/brick/button/is-pressed.md b/docs/reference/brick/button/is-pressed.md index ae0ac82e..68fc2cde 100644 --- a/docs/reference/brick/button/is-pressed.md +++ b/docs/reference/brick/button/is-pressed.md @@ -32,7 +32,7 @@ Set the brick light to green when the `down` is pressed. When the button is not ```blocks let isRed = false; -loops.forever(function() { +forever(function() { if (brick.buttonLeft.isPressed()) { brick.setStatusLight(StatusLight.Green); isRed = false; diff --git a/docs/reference/brick/clear-screen.md b/docs/reference/brick/clear-screen.md index 7ae69310..771275ca 100644 --- a/docs/reference/brick/clear-screen.md +++ b/docs/reference/brick/clear-screen.md @@ -16,7 +16,7 @@ brick.showString("self-destruct in:", 2); brick.showString("seconds", 5); for (let i = 0; i < 10; i++) { brick.showNumber(10 - i, 4); - loops.pause(1000); + pause(1000); } brick.clearScreen(); ``` diff --git a/docs/reference/brick/set-status-light.md b/docs/reference/brick/set-status-light.md index c69a64f8..bf22c0d8 100644 --- a/docs/reference/brick/set-status-light.md +++ b/docs/reference/brick/set-status-light.md @@ -24,14 +24,14 @@ brick.setStatusLight(StatusLight.Red); Repeatedly show a different color pattern for the brick light. ```blocks -loops.forever(function () { +forever(function () { brick.setStatusLight(StatusLight.Orange) - loops.pause(1000) + pause(1000) brick.setStatusLight(StatusLight.GreenFlash) - loops.pause(2000) + pause(2000) brick.setStatusLight(StatusLight.RedPulse) - loops.pause(2000) + pause(2000) brick.setStatusLight(StatusLight.Off) - loops.pause(500) + pause(500) }) ``` diff --git a/docs/reference/motors/motor/angle.md b/docs/reference/motors/motor/angle.md index c6620fa6..a04d8485 100644 --- a/docs/reference/motors/motor/angle.md +++ b/docs/reference/motors/motor/angle.md @@ -20,7 +20,7 @@ Reset the motor connected to port **A** and run it for for 2 seconds at a speed let motorAngle = 0; motors.largeA.reset() motors.largeA.setSpeed(45) -loops.pause(2000) +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 36c36573..d7c04fe1 100644 --- a/docs/reference/motors/motor/clear-counts.md +++ b/docs/reference/motors/motor/clear-counts.md @@ -16,11 +16,11 @@ See if the motor turns the same number of times for each of two count periods. R let tachoCount = 0; motors.largeA.reset() motors.largeA.setSpeed(50) -loops.pause(10000) +pause(10000) tachoCount = motors.largeA.tacho() motors.largeA.clearCounts() motors.largeA.setSpeed(50) -loops.pause(10000) +pause(10000) if (tachoCount == motors.largeA.tacho()) { brick.showString("Motor turns equal.", 1) } else { diff --git a/docs/reference/motors/motor/reset.md b/docs/reference/motors/motor/reset.md index a15a49e9..b968a9c9 100644 --- a/docs/reference/motors/motor/reset.md +++ b/docs/reference/motors/motor/reset.md @@ -14,12 +14,12 @@ See what the angle count is when a motor is stopped. Then, try it again after a ```blocks motors.largeA.setSpeed(30) -loops.pause(2000) +pause(2000) motors.largeA.stop() brick.showString("Angle count:", 1) brick.showNumber(motors.largeA.angle(), 2) motors.largeA.setSpeed(30) -loops.pause(2000) +pause(2000) motors.largeA.reset() brick.showString("Angle count:", 4) brick.showNumber(motors.largeA.angle(), 5) diff --git a/docs/reference/motors/motor/set-brake.md b/docs/reference/motors/motor/set-brake.md index ab50d334..10f100cf 100644 --- a/docs/reference/motors/motor/set-brake.md +++ b/docs/reference/motors/motor/set-brake.md @@ -20,7 +20,7 @@ Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and ```blocks motors.largeA.setSpeed(30) -loops.pause(2000) +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 de77c280..d2de503e 100644 --- a/docs/reference/motors/motor/set-inverted.md +++ b/docs/reference/motors/motor/set-inverted.md @@ -18,12 +18,12 @@ Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and ```blocks motors.largeA.setSpeed(30) -loops.pause(2000) +pause(2000) motors.largeA.stop() -loops.pause(2000) +pause(2000) motors.largeA.setInverted(true) motors.largeA.setSpeed(-30) -loops.pause(2000) +pause(2000) motors.largeA.stop() ``` diff --git a/docs/reference/motors/motor/set-regulated.md b/docs/reference/motors/motor/set-regulated.md index 28dc165a..a1779586 100644 --- a/docs/reference/motors/motor/set-regulated.md +++ b/docs/reference/motors/motor/set-regulated.md @@ -23,7 +23,7 @@ Turn off the speed regulation for the motor connected to port **A**. ```blocks motors.largeA.setRegulated(false) motors.largeA.setSpeed(75) -loops.pause(20000) +pause(20000) motors.largeA.stop() ``` diff --git a/docs/reference/motors/motor/set-speed.md b/docs/reference/motors/motor/set-speed.md index d31b3b3a..b5c75c37 100644 --- a/docs/reference/motors/motor/set-speed.md +++ b/docs/reference/motors/motor/set-speed.md @@ -69,7 +69,7 @@ Run the motor connected to port **A** continuously. Pause 20 seconds and then st ```blocks motors.largeA.setSpeed(75) -loops.pause(20000) +pause(20000) motors.largeA.stop() ``` @@ -79,7 +79,7 @@ Run the motor connected to port **A** in reverse. Pause 5 seconds and then stop ```blocks motors.largeA.setSpeed(-60) -loops.pause(5000) +pause(5000) motors.largeA.stop() ``` diff --git a/docs/reference/motors/motor/speed.md b/docs/reference/motors/motor/speed.md index d6f12079..d5ec2d39 100644 --- a/docs/reference/motors/motor/speed.md +++ b/docs/reference/motors/motor/speed.md @@ -21,7 +21,7 @@ motors.largeA.setRegulated(false) motors.largeA.setSpeed(55) brick.showString("Actual speed:", 1) for (let i = 0; i < 30; i++) { - loops.pause(500) + pause(500) brick.showNumber(motors.largeA.speed(), 3) } motors.largeA.stop() diff --git a/docs/reference/motors/motor/stop.md b/docs/reference/motors/motor/stop.md index 404b7032..fa091312 100644 --- a/docs/reference/motors/motor/stop.md +++ b/docs/reference/motors/motor/stop.md @@ -14,9 +14,9 @@ Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and ```blocks motors.largeA.setSpeed(30) -loops.pause(2000) +pause(2000) motors.largeA.stop() -loops.pause(2000) +pause(2000) motors.largeA.setSpeed(50) ``` diff --git a/docs/reference/motors/motor/tacho.md b/docs/reference/motors/motor/tacho.md index 8832bf53..8a90ff94 100644 --- a/docs/reference/motors/motor/tacho.md +++ b/docs/reference/motors/motor/tacho.md @@ -34,7 +34,7 @@ Run the motor connected to port **A** at half speed for 5 seconds. Display the n ```blocks motors.largeA.setSpeed(50) -loops.pause(5000) +pause(5000) motors.largeA.stop() brick.showString("Motor rotations:", 1) brick.showNumber(motors.largeA.tacho() / 360, 3) diff --git a/docs/reference/motors/stop-all.md b/docs/reference/motors/stop-all.md index ea52389a..42443b53 100644 --- a/docs/reference/motors/stop-all.md +++ b/docs/reference/motors/stop-all.md @@ -14,7 +14,7 @@ Tank the @boardname@ forward at half speed for 5 seconds and then stop. ```blocks motors.largeAB.tank(50, 50); -loops.pause(5000); +pause(5000); motors.stopAll(); ``` diff --git a/docs/reference/motors/synced/steer.md b/docs/reference/motors/synced/steer.md index 7a4d9f00..a52c99f3 100644 --- a/docs/reference/motors/synced/steer.md +++ b/docs/reference/motors/synced/steer.md @@ -72,9 +72,9 @@ Steer the brick in a snake pattern for a short time. ```block for (let i = 0; i < 4; i++) { motors.largeBC.steer(30, 30) - loops.pause(5000) + pause(5000) motors.largeBC.steer(-30, 30) - loops.pause(5000) + pause(5000) } motors.stopAll() ``` diff --git a/docs/reference/motors/synced/tank.md b/docs/reference/motors/synced/tank.md index b29f5e73..42152530 100644 --- a/docs/reference/motors/synced/tank.md +++ b/docs/reference/motors/synced/tank.md @@ -43,9 +43,9 @@ Move the brick straight ahead and then go backward. ```blocks motors.largeAB.tank(75, 75) -loops.pause(10000) +pause(10000) motors.largeAB.tank(-55, -55) -loops.pause(10000) +pause(10000) motors.stopAll() ``` @@ -72,7 +72,7 @@ Run both motors in opposite directions to spin the brick around to the left. ```blocks motors.largeAB.tank(-30, 30) -loops.pause(5000) +pause(5000) motors.stopAll() ``` diff --git a/libs/base/shims.d.ts b/libs/base/shims.d.ts index 9e19da92..e89e65fb 100644 --- a/libs/base/shims.d.ts +++ b/libs/base/shims.d.ts @@ -70,17 +70,17 @@ declare namespace loops { * Repeats the code forever in the background. On each iteration, allows other codes to run. * @param body code to execute */ - //% help=loops/forever weight=100 afterOnStart=true - //% blockId=forever block="forever" blockAllowMultiple=1 shim=loops::forever + //% help=loops/forever weight=100 afterOnStart=true deprecated=true + //% blockId=forever_deprecated block="forever" blockAllowMultiple=1 shim=loops::forever function forever(a: () => void): void; /** * Pause for the specified time in milliseconds * @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000 */ - //% help=loops/pause weight=99 + //% help=loops/pause weight=99 deprecated=true //% async block="pause %pause=timePicker|ms" - //% blockId=device_pause shim=loops::pause + //% blockId=device_pause_deprecated shim=loops::pause function pause(ms: int32): void; } declare namespace control { diff --git a/libs/color-sensor/color.ts b/libs/color-sensor/color.ts index 0a3c027c..e657a47d 100644 --- a/libs/color-sensor/color.ts +++ b/libs/color-sensor/color.ts @@ -294,7 +294,7 @@ namespace sensors { } // wait a bit - loops.pause(50); + pause(50); } // apply tolerance diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md b/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md index 767d875b..f416da4e 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md @@ -1,7 +1,7 @@ # Ambient Light ```blocks -loops.forever(function () { +forever(function () { if (sensors.color1.ambientLight() > 20) { brick.setStatusLight(StatusLight.Green) } else { diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/color.md b/libs/color-sensor/docs/reference/sensors/color-sensor/color.md index dc793988..50fe3960 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/color.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/color.md @@ -1,7 +1,7 @@ # color ```blocks -loops.forever(function () { +forever(function () { if (sensors.color1.color() == ColorSensorColor.Green) { brick.setStatusLight(StatusLight.Green) } else { diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md b/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md index 79f12643..5a7eee36 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md @@ -1,7 +1,7 @@ # Reflected Light ```blocks -loops.forever(function () { +forever(function () { if (sensors.color1.reflectedLight() > 20) { brick.setStatusLight(StatusLight.Green) } else { diff --git a/libs/core/input.ts b/libs/core/input.ts index 0f33da20..1daed8c2 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -15,7 +15,7 @@ namespace sensors.internal { let prev = query() changeHandler(prev, prev) while (true) { - loops.pause(periodMs) + pause(periodMs) let curr = query() if (prev !== curr) { changeHandler(prev, curr) @@ -57,9 +57,9 @@ namespace sensors.internal { uartMM = control.mmap("/dev/lms_uart", UartOff.Size, 0) if (!uartMM) control.fail("no uart sensor") - loops.forever(() => { + forever(() => { detectDevices() - loops.pause(500) + pause(500) }) for (let info_ of sensorInfos) { @@ -258,7 +258,7 @@ namespace sensors.internal { if (port < 0) return 0 let s = getUartStatus(port) if (s) return s - loops.pause(25) + pause(25) } } @@ -280,7 +280,7 @@ namespace sensors.internal { uartMM.setNumber(NumberFormat.Int8LE, UartOff.Status + port, getUartStatus(port) & 0xfffe) - loops.pause(10) + pause(10) } } @@ -299,7 +299,7 @@ namespace sensors.internal { } else { break } - loops.pause(10) + pause(10) } } diff --git a/libs/core/output.ts b/libs/core/output.ts index f9dbd450..03d1ef54 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -202,7 +202,7 @@ namespace motors { // if we've recently completed a motor command with brake // allow 500ms for robot to settle if(this._brake) - loops.pause(500); + pause(500); } /** diff --git a/libs/core/test.ts b/libs/core/test.ts index f35c193c..09335079 100644 --- a/libs/core/test.ts +++ b/libs/core/test.ts @@ -31,15 +31,15 @@ brick.buttonUp.onEvent(ButtonEvent.Bumped, () => { let num = 0 -loops.forever(() => { +forever(() => { serial.writeDmesg() - loops.pause(100) + pause(100) }) /* -loops.forever(() => { +forever(() => { let v = input.color.getColor() screen.print(10, 60, v + " ") - loops.pause(200) + pause(200) }) */ diff --git a/libs/core/timer.ts b/libs/core/timer.ts index 31e7dbc9..3fe0e16d 100644 --- a/libs/core/timer.ts +++ b/libs/core/timer.ts @@ -41,7 +41,7 @@ namespace control { //% blockId=timerPauseUntil block="%timer|pause until (ms) %ms" pauseUntil(ms: number) { const remaining = this.millis() - ms; - loops.pause(Math.max(0, remaining)); + pause(Math.max(0, remaining)); } } diff --git a/libs/ev3/startup.ts b/libs/ev3/startup.ts index 3dcce976..94ee19d3 100644 --- a/libs/ev3/startup.ts +++ b/libs/ev3/startup.ts @@ -1,4 +1,4 @@ // This is the last thing executed before user code // We pause for 100ms to give time to read sensor values, so they work in on_start block -loops.pause(100) +pause(100) diff --git a/libs/gyro-sensor/docs/reference/sensors/gyro/rate.md b/libs/gyro-sensor/docs/reference/sensors/gyro/rate.md index f73f6272..717f5aaf 100644 --- a/libs/gyro-sensor/docs/reference/sensors/gyro/rate.md +++ b/libs/gyro-sensor/docs/reference/sensors/gyro/rate.md @@ -18,7 +18,7 @@ When the brick is in motion, it moves in the direction of one of axes used to me Flash the status light to red if the roll rate of `gyro 2` is more that `30` degrees per second. ```blocks -loops.forever(function () { +forever(function () { if (sensors.gyro2.rate() > 30) { brick.setStatusLight(StatusLight.RedFlash) } else { diff --git a/libs/gyro-sensor/gyro.ts b/libs/gyro-sensor/gyro.ts index 95fbfd35..64316623 100644 --- a/libs/gyro-sensor/gyro.ts +++ b/libs/gyro-sensor/gyro.ts @@ -95,7 +95,7 @@ namespace sensors { this.calibrating = true; // may be triggered by a button click, // give time for robot to settle - loops.pause(700); + pause(700); // send a reset command super.reset(); // switch back to the desired mode @@ -103,13 +103,13 @@ namespace sensors { // wait till sensor is live pauseUntil(() => this.isActive()); // give it a bit of time to init - loops.pause(1000) + pause(1000) // compute drift this._drift = 0; if (this.mode == GyroSensorMode.Rate) { for (let i = 0; i < 200; ++i) { this._drift += this._query(); - loops.pause(4); + pause(4); } this._drift /= 200; } diff --git a/libs/mood/mood.ts b/libs/mood/mood.ts index 17c22102..a0fde397 100644 --- a/libs/mood/mood.ts +++ b/libs/mood/mood.ts @@ -33,7 +33,7 @@ namespace brick { brick.setStatusLight(this.light); brick.showImage(this.image); music.playSoundEffectUntilDone(this.sound); - loops.pause(20); + pause(20); } } diff --git a/libs/music/test.ts b/libs/music/test.ts index 676d8ac9..c701b46f 100644 --- a/libs/music/test.ts +++ b/libs/music/test.ts @@ -1,7 +1,7 @@ music.setVolume(3) music.playTone(440, 500) -loops.pause(500) +pause(500) music.playTone(1440, 500) -loops.pause(500) +pause(500) music.playTone(2440, 500) -loops.pause(500) +pause(500) diff --git a/libs/tests/README.md b/libs/tests/README.md index cda2e460..4988cf97 100644 --- a/libs/tests/README.md +++ b/libs/tests/README.md @@ -9,7 +9,7 @@ Tests are registered as event handlers. They will automatically run once ``on st ```blocks tests.test("lgB set speed 10", () => { motors.largeB.setSpeed(10); - loops.pause(100) + pause(100) tests.assertClose("speedB", 10, motors.largeB.speed(), 2) }); ``` diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md index 2d68ec5c..c6dd93f9 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md @@ -14,7 +14,7 @@ sensors.touch1.isPressed() If the touch sensor ``touch 1`` is pressed, show a `green` status light. Otherwise, set the status light to `orange`. ```blocks -loops.forever(function () { +forever(function () { if (sensors.touch1.isPressed()) { brick.setStatusLight(StatusLight.Green) } else { diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md index 8560a3d2..7942f34d 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md @@ -17,13 +17,13 @@ If a touch sensor was pressed, then that event is remembered. Once you check if If the touch sensor ``touch 1`` was pressed, show a `green` status light. Otherwise, set the status light to `orange`. ```blocks -loops.forever(function () { +forever(function () { if (sensors.touch1.wasPressed()) { brick.setStatusLight(StatusLight.Green) } else { brick.setStatusLight(StatusLight.Orange) } - loops.pause(500) + pause(500) }) ``` diff --git a/tests/colors.ts b/tests/colors.ts index f12988f6..eb9f0124 100644 --- a/tests/colors.ts +++ b/tests/colors.ts @@ -15,7 +15,7 @@ tests.test("Bright ambient light", function () { let actualLight: number for (let i = 0; i < 4; i++) { actualLight = sensors.color1.ambientLight() - loops.pause(500) + pause(500) } tests.assertClose("Light", actualLight, 20, 15) }) @@ -29,7 +29,7 @@ tests.test("Bright reflected light", function () { let actualLight: number for (let i = 0; i < 4; i++) { actualLight = sensors.color1.reflectedLight() - loops.pause(500) + pause(500) } tests.assertClose("Light", actualLight, 17, 14) }) \ No newline at end of file diff --git a/tests/motors.ts b/tests/motors.ts index df87a956..71ec9934 100644 --- a/tests/motors.ts +++ b/tests/motors.ts @@ -1,42 +1,42 @@ // add tests package tests.test("lgB set speed 10", () => { motors.largeB.setSpeed(10); - loops.pause(500) + pause(500) tests.assertClose("speedB", 10, motors.largeB.speed(), 2) }); tests.test("lgB set speed 25 (reversed)", () => { motors.largeB.setInverted(true) motors.largeB.setSpeed(25) - loops.pause(500) + pause(500) tests.assertClose("speedB", -25, motors.largeB.speed(), 2) }); tests.test("lgBC set speed 5", () => { motors.largeBC.setSpeed(5) - loops.pause(500) + pause(500) tests.assertClose("speedB", 5, motors.largeB.speed(), 1); tests.assertClose("speedC", 5, motors.largeC.speed(), 1); }); tests.test("lgBC steer 50% 2x", () => { motors.largeBC.setBrake(true) motors.largeBC.steer(50, 50, 1, MoveUnit.Rotations) - loops.pause(2000) + pause(2000) tests.assertClose("largeB", 360, motors.largeB.angle(), 5) motors.largeBC.setBrake(false) }) tests.test("lgBC steer 360deg", () => { motors.largeBC.setBrake(true) motors.largeBC.steer(50, 50, 360, MoveUnit.Degrees) - loops.pause(2000) + pause(2000) tests.assertClose("largeB", 360, motors.largeB.angle(), 5) }); tests.test("lgBC steer 50% 1s", () => { motors.largeBC.setBrake(true) motors.largeBC.steer(10, 50, 1000, MoveUnit.MilliSeconds) - loops.pause(2000) + pause(2000) }) tests.test("lgBC tank 50% 180deg", () => { motors.largeBC.setBrake(true) motors.largeBC.tank(50, 50, 180, MoveUnit.Degrees) - loops.pause(1000) + pause(1000) tests.assertClose("largeB", 180, motors.largeB.angle(), 5) });