Threshold api docs - 01 (#336)

* Local commit

* Throw on more topics

* Throw in threshold topics for infrared
This commit is contained in:
Galen Nickel
2018-02-21 22:35:25 -08:00
committed by Peli de Halleux
parent 84c8e31ff5
commit 8cfb70c97b
11 changed files with 240 additions and 6 deletions

View File

@ -0,0 +1,32 @@
# proximity Threshold
Get the proximity threshold for when objects are near and detected.
```sig
sensors.infraredSensor1.proximityThreshold(InfraredSensorEvent.ObjectNear)
```
Infrared sensors determine proximity of an object by measuring the intensity of the infrared light reflected from it. The proximity range of measurment is from `0` to `100`. Proximity _thresholds_ use a value in this range to decide when a proximity event should happen for a detected object.
## Parameters
* **condition**: the proximity threshold to return a value for. These are: ``near`` and ``detected``.
## Returns
* a [number](/types/number) that is the proximity value for the threshold. This is a number between `0` and `100`.
## Example
When an object with near proximity is detected, show what the threshold is.
```blocks
sensors.infraredSensor1.onEvent(InfraredSensorEvent.ObjectNear, function () {
brick.showValue("NearObjectThreshold", sensors.infraredSensor1.proximityThreshold(InfraredSensorEvent.ObjectNear)
, 1)
})
```
## See also
[set proximity threshold](/reference/sensors/infrared/set-proximity-threshold)

View File

@ -0,0 +1,35 @@
# set Proximity Threshold
Set the proximity threshold for when objects are near or detected.
```sig
sensors.infraredSensor1.setPromixityThreshold(InfraredSensorEvent.ObjectNear, 0)
```
Infrared sensors determine proximity of an object by measuring the intensity of the infrared light reflected from it. The proximity range of measurment is from `0` to `100`. You can decide what value in that range you want mean that something is near or that something was detected.
If you want a proximity value of `32` to mean that a detected object is near, then the ``near`` threshold is set to that value. If you want any object within a proximity of `95` to cause a detection event, then the ``detected`` threshold is set to `95`.
## Parameters
* **condition**: the threshold condition to use this proximity. These are: ``near`` and ``detected``.
* **value**: a proximity [number](/types/number) to set the threshold for.
## Example
Set a threshold for detecting something moving within a proximity `30`. Wait for an object to show up. When it does, flash the status light and make noise as an alarm.
```blocks
sensors.infraredSensor1.setPromixityThreshold(InfraredSensorEvent.ObjectDetected, 30)
sensors.infraredSensor1.pauseUntil(InfraredSensorEvent.ObjectDetected)
brick.clearScreen()
brick.showString("Perimeter Breach!!!", 3)
brick.setStatusLight(StatusLight.RedFlash)
for (let i = 0; i < 10; i++) {
music.playSoundEffectUntilDone(sounds.mechanicalHorn2)
}
```
## See also
[proximity threshold](/reference/sensors/infrared/proximity-threshold)