diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 5a489751..492c2e93 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -100,8 +100,8 @@ * [Color](/reference/sensors/color-sensor) * [on color detected](/reference/sensors/color-sensor/on-color-detected) * [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) + * [on light detected](/reference/sensors/color-sensor/on-light-detected) + * [pause until light condition detected](/reference/sensors/color-sensor/pause-until-light-detected) * [color](/reference/sensors/color-sensor/color) * [light](/reference/sensors/color-sensor/ambient-light) * [Music](/reference/music) diff --git a/docs/coding/light-the-way-1.md b/docs/coding/light-the-way-1.md index c1a0399a..da7a1f38 100644 --- a/docs/coding/light-the-way-1.md +++ b/docs/coding/light-the-way-1.md @@ -1,7 +1,7 @@ # Light the way Activity 1 ```blocks -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () { +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () { brick.showImage(images.objectsLightOn) pause(5000) brick.clearScreen() diff --git a/docs/coding/light-the-way-2.md b/docs/coding/light-the-way-2.md index 64665ed9..bb2cb106 100644 --- a/docs/coding/light-the-way-2.md +++ b/docs/coding/light-the-way-2.md @@ -1,10 +1,10 @@ # Light the way Activity 2 ```blocks -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () { +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Bright, function () { brick.clearScreen() }) -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () { +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () { brick.showImage(images.objectsLightOn) }) ``` \ No newline at end of file diff --git a/docs/coding/light-the-way-3.md b/docs/coding/light-the-way-3.md index c800e7f4..fc4ad5fb 100644 --- a/docs/coding/light-the-way-3.md +++ b/docs/coding/light-the-way-3.md @@ -1,10 +1,10 @@ # Light the way Activity 3 ```blocks -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () { +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Bright, function () { brick.clearScreen() }) -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function () { +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () { brick.showImage(images.objectsLightOn) }) sensors.touch1.onEvent(ButtonEvent.Pressed, function () { diff --git a/docs/lessons/line-detection.md b/docs/lessons/line-detection.md index 6d2d1d9d..6c6766c2 100644 --- a/docs/lessons/line-detection.md +++ b/docs/lessons/line-detection.md @@ -213,12 +213,12 @@ music.playSoundEffect(sounds.systemGeneralAlert) } while (true) { while (true) { - sensors.color3.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Bright) + sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright) motors.largeB.run(10) motors.largeC.run(-10) } while (true) { - sensors.color3.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Bright) + sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright) motors.largeA.run(-10) motors.largeA.run(10) } @@ -236,12 +236,12 @@ You will need to constantly debug your program in order to make your robot trave ```blocks while (true) { while (true) { - sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, LightCondition.Bright) + sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright) motors.largeB.run(10) motors.largeC.run(-10) } while (true) { - sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, LightCondition.Bright) + sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright) motors.largeB.run(-10) motors.largeC.run(10) } diff --git a/docs/reference/sensors.md b/docs/reference/sensors.md index ce3d3da8..715065db 100644 --- a/docs/reference/sensors.md +++ b/docs/reference/sensors.md @@ -4,8 +4,8 @@ ```cards sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {}) -sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {}) -sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark) +sensors.color1.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () {}) +sensors.color1.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Dark) sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue) sensors.color1.color(); sensors.color1.light(LightIntensityMode.Ambient) diff --git a/libs/color-sensor/color.ts b/libs/color-sensor/color.ts index 7d66e7bf..63fcd37f 100644 --- a/libs/color-sensor/color.ts +++ b/libs/color-sensor/color.ts @@ -37,7 +37,7 @@ const enum ColorSensorColor { Brown } -enum LightCondition { +enum Light { //% block="dark" Dark = sensors.ThresholdState.Low, //% block="bright" @@ -184,7 +184,7 @@ namespace sensors { * @param condition the light condition * @param handler the code to run when detected */ - //% help=sensors/color-sensor/on-light-condition-detected + //% help=sensors/color-sensor/on-light-detected //% block="on **color sensor** %this|detected %mode|%condition" //% blockId=colorOnLightDetected //% parts="colorsensor" @@ -192,7 +192,7 @@ namespace sensors { //% this.fieldEditor="ports" //% weight=89 blockGap=12 //% group="Color Sensor" - onLightConditionDetected(mode: LightIntensityMode, condition: LightCondition, handler: () => void) { + onLightDetected(mode: LightIntensityMode, condition: Light, handler: () => void) { this.setMode(mode) control.onEvent(this._id, 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-until-light-condition-detected + //% help=sensors/color-sensor/pause-until-light-detected //% block="pause until **color sensor** %this|detected %mode|%condition" - //% blockId=colorPauseUntilLightConditionDetected + //% blockId=colorPauseUntilLightDetected //% parts="colorsensor" //% blockNamespace=sensors //% this.fieldEditor="ports" //% weight=88 blockGap=8 //% group="Color Sensor" - pauseUntilLightConditionDetected(mode: LightIntensityMode, condition: LightCondition) { + pauseUntilLightDetected(mode: LightIntensityMode, condition: Light) { this.setMode(mode) if (this.thresholdDetector.state != condition) control.waitForEvent(this._id, condition) @@ -252,8 +252,8 @@ namespace sensors { //% value.min=0 value.max=100 //% this.fieldEditor="ports" //% help=sensors/color-sensor/set-threshold - setThreshold(condition: LightCondition, value: number) { - if (condition == LightCondition.Dark) + setThreshold(condition: Light, value: number) { + if (condition == Light.Dark) this.thresholdDetector.setLowThreshold(value) else this.thresholdDetector.setHighThreshold(value); @@ -267,8 +267,8 @@ namespace sensors { //% group="Threshold" blockGap=8 weight=89 //% this.fieldEditor="ports" //% help=sensors/color-sensor/threshold - threshold(condition: LightCondition): number { - return this.thresholdDetector.threshold(LightCondition.Dark); + threshold(condition: Light): number { + return this.thresholdDetector.threshold(Light.Dark); } /** diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor.md b/libs/color-sensor/docs/reference/sensors/color-sensor.md index a83f7093..0d78cc91 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor.md @@ -2,8 +2,8 @@ ```cards sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {}) -sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {}) -sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark) +sensors.color1.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () {}) +sensors.color1.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Dark) sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue) sensors.color1.color(); sensors.color1.light(LightIntensityMode.Ambient) @@ -13,7 +13,7 @@ sensors.color1.light(LightIntensityMode.Ambient) [on color detected](/reference/sensors/color-sensor/on-color-detected), [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), +[on light detected](/reference/sensors/color-sensor/on-light-detected), +[pause until light detected](/reference/sensors/color-sensor/pause-until-light-detected), [color](/reference/sensors/color-sensor/color), [light](/reference/sensors/color-sensor/ambient-light) diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/on-light-condition-detected.md b/libs/color-sensor/docs/reference/sensors/color-sensor/on-light-detected.md similarity index 77% rename from libs/color-sensor/docs/reference/sensors/color-sensor/on-light-condition-detected.md rename to libs/color-sensor/docs/reference/sensors/color-sensor/on-light-detected.md index 93f85456..bd49a3a0 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/on-light-condition-detected.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/on-light-detected.md @@ -3,7 +3,7 @@ Run some code when the amount of light dectected changes. ```sig -sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () { +sensors.color1.onLightDetected(LightIntensityMode.Reflected, Light.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.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Dark, function() { +sensors.color1.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function() { brick.clearScreen(); brick.showString("It just got dark", 1) brick.showString("Can you see me?", 2) diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-condition-detected.md b/libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-detected.md similarity index 71% rename from libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-condition-detected.md rename to libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-detected.md index b6aeb927..69fe14dc 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-condition-detected.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/pause-until-light-detected.md @@ -3,7 +3,7 @@ Wait until a particular light condition is detected. ```sig -sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark) +sensors.color1.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.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.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark) +sensors.color1.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Dark) brick.clearScreen() brick.showImage(images.expressionsSick) ``` ## See also -[on light condition detected](/reference/sensors/color-sensor/on-light-condition-detected) \ No newline at end of file +[on light detected](/reference/sensors/color-sensor/on-light-detected) \ No newline at end of file diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/set-threshold.md b/libs/color-sensor/docs/reference/sensors/color-sensor/set-threshold.md index 1a0ad296..ee2246d9 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/set-threshold.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/set-threshold.md @@ -3,7 +3,7 @@ Set the threshold value for dark or bright light. ```sig -sensors.color1.setThreshold(LightCondition.Dark, 0) +sensors.color1.setThreshold(Light.Dark, 0) ``` Light intensity is measured from `0` (very dark) to `100` (very bright). You can decide what dark and bright mean for your purposes and set a _threshold_ for them. A threshold is a boundary or a limit. If you want a light intensity of `20` mean that it's dark, then you set the sensor threshold for ``dark`` to `20`. Also, if you think that `75` is bright, then you can set the threshold for ``bright`` to that. @@ -11,8 +11,8 @@ Light intensity is measured from `0` (very dark) to `100` (very bright). You can After setting a threshold, any event for that light condition won't happen until the amount of light reaches your threshold value: ```block -sensors.color1.setThreshold(LightCondition.Dark, 20) -sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () { +sensors.color1.setThreshold(Light.Dark, 20) +sensors.color1.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () { brick.showMood(moods.sleeping) }) ``` @@ -27,8 +27,8 @@ sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondi Make a daylight alarm. When the ambient light reaches `70` flash the status light and play a sound. ```blocks -sensors.color3.setThreshold(LightCondition.Bright, 70) -sensors.color3.onLightConditionDetected(LightIntensityMode.Ambient, LightCondition.Bright, function () { +sensors.color3.setThreshold(Light.Bright, 70) +sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Bright, function () { brick.setStatusLight(StatusLight.GreenFlash) for (let i = 0; i < 5; i++) { music.playSoundEffectUntilDone(sounds.mechanicalBackingAlert) diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/threshold.md b/libs/color-sensor/docs/reference/sensors/color-sensor/threshold.md index 19f31db6..19941593 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/threshold.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/threshold.md @@ -3,7 +3,7 @@ Get the threshold value for dark or bright light. ```sig -sensors.color1.threshold(LightCondition.Dark) +sensors.color1.threshold(Light.Dark) ``` Light intensity is measured from `0` (very dark) to `100` (very bright). A _threshold_ sets what dark and bright mean for your purposes. A threshold is a boundary or a limit. If a light intensity of `20` means that it's dark, then the sensor threshold for ``dark`` is `20`. Also, if `75` means bright, then the threshold value for ``bright`` is `75`. @@ -17,8 +17,8 @@ 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.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () { - brick.showValue("DarknessThresholdValue", sensors.color3.threshold(LightCondition.Dark), 1) +sensors.color3.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () { + brick.showValue("DarknessThresholdValue", sensors.color3.threshold(Light.Dark), 1) }) ``` diff --git a/libs/infrared-sensor/ir.ts b/libs/infrared-sensor/ir.ts index 4d7c56ee..bdfbf321 100644 --- a/libs/infrared-sensor/ir.ts +++ b/libs/infrared-sensor/ir.ts @@ -279,7 +279,7 @@ namespace sensors { //% group="Threshold" blockGap=8 weight=49 //% this.fieldEditor="ports" proximityThreshold(condition: InfraredSensorEvent): number { - return this._proximityThreshold.threshold(LightCondition.Dark); + return this._proximityThreshold.threshold(Light.Dark); } // TODO