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
18 changed files with 78 additions and 76 deletions

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