replacing loops.pause -> pause, loops.forever -> forever

This commit is contained in:
Peli de Halleux
2018-02-14 16:05:31 -08:00
parent 0384eb4d9d
commit daa88b299d
62 changed files with 151 additions and 151 deletions

View File

@ -3,6 +3,6 @@
### #specific
```cards
loops.forever(() => {});
loops.pause(0)
forever(() => {});
pause(0)
```

View File

@ -7,6 +7,6 @@ while (true) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
loops.pause(1);
pause(1);
}
```

View File

@ -8,6 +8,6 @@ while (true) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
loops.pause(1);
pause(1);
}
```

View File

@ -3,7 +3,7 @@
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
loops.pause(5000)
pause(5000)
brick.clearScreen()
})
```

View File

@ -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);

View File

@ -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);

View File

@ -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)
}
}
})

View File

@ -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)
})
```

View File

@ -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)
})
```

View File

@ -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)
})
```

View File

@ -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) {

View File

@ -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) {

View File

@ -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)
})
```

View File

@ -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)
})
```

View File

@ -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)
})
```

View File

@ -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 {

View File

@ -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)

View File

@ -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);
})
```

View File

@ -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:

View File

@ -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())

View File

@ -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())

View File

@ -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);
})
```

View File

@ -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)

View File

@ -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)
})
```

View File

@ -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()
})
```

View File

@ -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)
})
```

View File

@ -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)
})
```

View File

@ -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;

View File

@ -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();
```

View File

@ -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)
})
```

View File

@ -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()
```

View File

@ -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 {

View File

@ -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)

View File

@ -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)
```

View File

@ -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()
```

View File

@ -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()
```

View File

@ -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()
```

View File

@ -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()

View File

@ -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)
```

View File

@ -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)

View File

@ -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();
```

View File

@ -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()
```

View File

@ -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()
```