renaming pauseforcolor to pause until color detected (#405)

* renaming pauseforcolor to pause until color detected

* pauseForLight -> pauseUntilLightConditionDetected

* on light changed -> on light condition detected

* fixing docs

* docs tweaks
This commit is contained in:
Peli de Halleux 2018-04-03 05:05:01 -07:00 committed by GitHub
parent 69194b0b76
commit 2467b3c4c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 78 additions and 76 deletions

View File

@ -99,9 +99,9 @@
* [set remote channel](/reference/sensors/beacon/set-remote-channel)
* [Color](/reference/sensors/color-sensor)
* [on color detected](/reference/sensors/color-sensor/on-color-detected)
* [pause for color](/reference/sensors/color-sensor/pause-for-color)
* [on light changed](/reference/sensors/color-sensor/on-light-changed)
* [pause for light](/reference/sensors/color-sensor/pause-for-light)
* [pause until color detected](/reference/sensors/color-sensor/pause-until-color-detected)
* [on-light-condition-detected](/reference/sensors/color-sensor/on-light-condition-detected)
* [pause until light condition detected](/reference/sensors/color-sensor/pause-until-light-condition-detected)
* [color](/reference/sensors/color-sensor/color)
* [light](/reference/sensors/color-sensor/ambient-light)
* [Music](/reference/music)

View File

@ -1,7 +1,7 @@
# Light the way Activity 1
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
pause(5000)
brick.clearScreen()

View File

@ -1,10 +1,10 @@
# Light the way Activity 2
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () {
brick.clearScreen()
})
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
})
```

View File

@ -1,10 +1,10 @@
# Light the way Activity 3
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () {
brick.clearScreen()
})
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
})
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {

View File

@ -54,7 +54,7 @@ loops.forever(function () {
})
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
```
@ -70,7 +70,7 @@ motors.stopAll()
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
})
```
@ -94,9 +94,9 @@ Now add to your program and have your robot to drive forward again when the ligh
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
})
```
@ -134,10 +134,10 @@ music.playSoundEffect(sounds.systemGeneralAlert)
```blocks
loops.forever(function () {
motors.largeBC.steer(-30, 20)
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
music.playSoundEffect(sounds.systemGeneralAlert)
motors.largeBC.steer(30, 20)
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
})
```
@ -185,11 +185,11 @@ if (true) {
```blocks
forever(function () {
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})
@ -204,10 +204,10 @@ Else the Color Sensor detects the color white, start motors ``B`` and ``C`` (dri
```blocks
forever(function () {
if (true) {
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
} else {
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})

View File

@ -3,7 +3,7 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(20, 20)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.largeBC.tank(0, 0)
})
```

View File

@ -135,7 +135,7 @@ Keeping the Large Motor connected to **Port D**, connect the Color Sensor to **P
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
@ -143,7 +143,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
* Using the same program, replace the ``||sensors:pause until touch 1||`` block with a ``||sensors:pause color sensor 3||`` for color block.
```block
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
```
* Select the color you want to detect (e.g., green).

View File

@ -60,18 +60,18 @@ while (true) {
### Step 3
Place a ``||sensors:pause for color||`` from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause until color detected||`` from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
```
### Step 4
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause until color detected||`` block.
Study the program...what do you think the program will do?
@ -80,7 +80,7 @@ Study the program...what do you think the program will do?
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
```
@ -128,26 +128,26 @@ while (true) {
### Step 5
Place a ``||sensors:pause for color||`` block from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause until color detected||`` block from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
}
```
### Step 6
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause until color detected||`` block.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
}
@ -161,7 +161,7 @@ Place a ``||loops:while||`` loop block under the second ``||loops:while||`` loop
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
@ -172,7 +172,7 @@ while (true) {
### Step 8
Place a ``||sensors:pause for color||`` block inside the new ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause unril color detected||`` block inside the new ``||loops:while||`` loop block. Change the color to red.
What do you think the program will do?
@ -182,11 +182,11 @@ What do you think the program will do?
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
}
```
@ -208,16 +208,17 @@ Think about what you have learned, then document it. Describe your pseudocode fo
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Yellow)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Yellow)
music.playSoundEffect(sounds.systemGeneralAlert)
}
while (true) {
while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
while (true) {
sensors.color3.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
sensors.color3.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeA.run(-10)
motors.largeA.run(10)
}
@ -234,12 +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)
while (true) {
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(-10)
motors.largeC.run(10)
}

View File

@ -143,13 +143,13 @@ You can also tinker with the use of sensors.
```blocks
forever(function () {
if (true) {
sensors.color3.pauseForColor(ColorSensorColor.Blue)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Blue)
music.playTone(392, music.beat(BeatFraction.Whole))
} else if (false) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
music.playTone(523, music.beat(BeatFraction.Half))
} else {
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
music.playTone(587, music.beat(BeatFraction.Half))
}
})

View File

@ -4,9 +4,9 @@
```cards
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {})
sensors.color1.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseForLight(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseForColor(ColorSensorColor.Blue)
sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue)
sensors.color1.color();
sensors.color1.light(LightIntensityMode.Ambient)
sensors.color(ColorSensorColor.Blue)

View File

@ -145,15 +145,15 @@ namespace sensors {
* Waits for the given color to be detected
* @param color the color to detect
*/
//% help=sensors/color-sensor/pause-for-color
//% block="pause **color sensor** %this|for %color=colorEnumPicker"
//% blockId=colorPauseForColorDetected
//% help=sensors/color-sensor/pause-until-color-detected
//% block="pause until **color sensor** %this|detected %color=colorEnumPicker"
//% blockId=colorpauseUntilColorDetectedDetected
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=99 blockGap=8
//% group="Color Sensor"
pauseForColor(color: number) {
pauseUntilColorDetected(color: number) {
this.setMode(ColorSensorMode.Color);
if (this.color() != color) {
const v = this._colorEventValue(<number>color);
@ -184,15 +184,15 @@ namespace sensors {
* @param condition the light condition
* @param handler the code to run when detected
*/
//% help=sensors/color-sensor/on-light-changed
//% block="on **color sensor** %this|%mode|%condition"
//% blockId=colorOnLightChanged
//% help=sensors/color-sensor/on-light-condition-detected
//% block="on **color sensor** %this|detected %mode|%condition"
//% blockId=colorOnLightDetected
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=89 blockGap=12
//% group="Color Sensor"
onLightChanged(mode: LightIntensityMode, condition: LightCondition, handler: () => void) {
onLightConditionDetected(mode: LightIntensityMode, condition: LightCondition, handler: () => void) {
this.setMode(<ColorSensorMode><number>mode)
control.onEvent(this._id, <number>condition, handler);
}
@ -201,15 +201,15 @@ namespace sensors {
* Wait for the given color to be detected
* @param color the color to detect
*/
//% help=sensors/color-sensor/pause-for-light
//% block="pause **color sensor** %this|for %mode|%condition"
//% blockId=colorPauseForLight
//% help=sensors/color-sensor/pause-until-light-condition-detected
//% block="pause until **color sensor** %this|detected %mode|%condition"
//% blockId=colorPauseUntilLightConditionDetected
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=88 blockGap=8
//% group="Color Sensor"
pauseForLight(mode: LightIntensityMode, condition: LightCondition) {
pauseUntilLightConditionDetected(mode: LightIntensityMode, condition: LightCondition) {
this.setMode(<ColorSensorMode><number>mode)
if (this.thresholdDetector.state != <number>condition)
control.waitForEvent(this._id, <number>condition)

View File

@ -2,9 +2,9 @@
```cards
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {})
sensors.color1.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseForLight(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseForColor(ColorSensorColor.Blue)
sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue)
sensors.color1.color();
sensors.color1.light(LightIntensityMode.Ambient)
```
@ -12,8 +12,8 @@ sensors.color1.light(LightIntensityMode.Ambient)
## See slso
[on color detected](/reference/sensors/color-sensor/on-color-detected),
[pause for color](/reference/sensors/color-sensor/pause-for-color),
[on light changed](/reference/sensors/color-sensor/on-light-changed),
[pause for light](/reference/sensors/color-sensor/pause-for-light),
[pause until color detected](/reference/sensors/color-sensor/pause-until-color-detected),
[on light condition detected](/reference/sensors/color-sensor/on-light-condition-detected),
[pause until light condition detected](/reference/sensors/color-sensor/pause-until-light-condition-detected),
[color](/reference/sensors/color-sensor/color),
[light](/reference/sensors/color-sensor/ambient-light)

View File

@ -24,4 +24,4 @@ sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {
```
## See also
[pause for color](/reference/sensors/color-sensor/pause-for-color), [color](/reference/sensors/color)
[pause until color detected](/reference/sensors/color-sensor/pause-until-color-detected), [color](/reference/sensors/color)

View File

@ -3,7 +3,7 @@
Run some code when the amount of light dectected changes.
```sig
sensors.color1.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {
sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {
})
```
@ -21,7 +21,7 @@ You can check for a change in either _ambient_ or _reflected_ light and run some
Show a message on the screen when the ambient light goes dark.
```blocks
sensors.color1.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function() {
sensors.color1.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function() {
brick.clearScreen();
brick.showString("It just got dark", 1)
brick.showString("Can you see me?", 2)

View File

@ -1,9 +1,9 @@
# pause For Color
# pause Until Color Detected
Wait for the sensor to see a certain color.
```sig
sensors.color1.pauseForColor(ColorSensorColor.Blue)
sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue)
```
The [color](/reference/sensors/color) you choose to look for is one of the colors that the sensor can detect. If you want to use colors for tracking, it's best to use a color that is the same or very close to the ones the sensor detects.
@ -18,7 +18,7 @@ Wait for the sensor to see ``blue``. Then, show an expression on the screen.
```blocks
brick.showString("Waiting for blue", 1)
sensors.color1.pauseForColor(ColorSensorColor.Blue)
sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue)
brick.clearScreen()
brick.showImage(images.expressionsSick)
```

View File

@ -1,9 +1,9 @@
# pause For Light
# pause Until Light Condition Detected
Wait for the light condition to change.
Wait until a particular light condition is detected.
```sig
sensors.color1.pauseForLight(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark)
```
You can wait for a change in either _ambient_ or _reflected_ light. This event happens when the sensor detects light going to ``dark`` or to ``bright``. You choose what condition you will wait for.
@ -19,11 +19,11 @@ Wait for the ambient light to go dark, then show an expression on the screen.
```blocks
brick.showString("Waiting for dark", 1)
sensors.color1.pauseForLight(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark)
brick.clearScreen()
brick.showImage(images.expressionsSick)
```
## See also
[on light changed](/reference/sensors/color-sensor/on-light-changed)
[on light condition detected](/reference/sensors/color-sensor/on-light-condition-detected)

View File

@ -12,7 +12,7 @@ After setting a threshold, any event for that light condition won't happen until
```block
sensors.color1.setThreshold(LightCondition.Dark, 20)
sensors.color1.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {
sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {
brick.showMood(moods.sleeping)
})
```
@ -28,7 +28,7 @@ Make a daylight alarm. When the ambient light reaches `70` flash the status ligh
```blocks
sensors.color3.setThreshold(LightCondition.Bright, 70)
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () {
brick.setStatusLight(StatusLight.GreenFlash)
for (let i = 0; i < 5; i++) {
music.playSoundEffectUntilDone(sounds.mechanicalBackingAlert)

View File

@ -17,7 +17,7 @@ Light intensity is measured from `0` (very dark) to `100` (very bright). A _thre
Find out what light level is set as the ``dark`` threshold when a dark light event happens.
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {
sensors.color3.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {
brick.showValue("DarknessThresholdValue", sensors.color3.threshold(LightCondition.Dark), 1)
})
```