bump version to 0.1.13 (#407)
* bump version * Light Condition -> Light * roll back 0.1.11
This commit is contained in:
parent
b618bfec59
commit
ec1ceea138
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
})
|
||||
```
|
@ -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 () {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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(<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-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(<ColorSensorMode><number>mode)
|
||||
if (this.thresholdDetector.state != <number>condition)
|
||||
control.waitForEvent(this._id, <number>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(<ThresholdState><number>LightCondition.Dark);
|
||||
threshold(condition: Light): number {
|
||||
return this.thresholdDetector.threshold(<ThresholdState><number>Light.Dark);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
@ -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)
|
@ -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)
|
||||
[on light detected](/reference/sensors/color-sensor/on-light-detected)
|
@ -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)
|
||||
|
@ -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)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -279,7 +279,7 @@ namespace sensors {
|
||||
//% group="Threshold" blockGap=8 weight=49
|
||||
//% this.fieldEditor="ports"
|
||||
proximityThreshold(condition: InfraredSensorEvent): number {
|
||||
return this._proximityThreshold.threshold(<ThresholdState><number>LightCondition.Dark);
|
||||
return this._proximityThreshold.threshold(<ThresholdState><number>Light.Dark);
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
Loading…
Reference in New Issue
Block a user