renaming infraredSensor to infrared (#344)

This commit is contained in:
Peli de Halleux 2018-02-26 10:39:15 -08:00 committed by Sam El-Husseini
parent 130a47d684
commit 33dcb6deee
14 changed files with 32 additions and 32 deletions

View File

@ -40,9 +40,9 @@ sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
## Infrared
```cards
sensors.infraredSensor1.onEvent(null, function () {});
sensors.infraredSensor1.pauseUntil(null);
sensors.infraredSensor1.proximity();
sensors.infrared1.onEvent(null, function () {});
sensors.infrared1.pauseUntil(null);
sensors.infrared1.proximity();
```
@ -53,5 +53,5 @@ sensors.remoteButtonCenter.onEvent(ButtonEvent.Pressed, function () {})
sensors.remoteButtonCenter.pauseUntil(ButtonEvent.Pressed);
sensors.remoteButtonCenter.isPressed()
sensors.remoteButtonCenter.wasPressed()
sensors.infraredSensor1.setRemoteChannel(null)
sensors.infrared1.setRemoteChannel(null)
```

View File

@ -5,7 +5,7 @@ sensors.remoteButtonCenter.onEvent(ButtonEvent.Pressed, function () {})
sensors.remoteButtonCenter.pauseUntil(ButtonEvent.Pressed);
sensors.remoteButtonCenter.isPressed()
sensors.remoteButtonCenter.wasPressed()
sensors.infraredSensor1.setRemoteChannel(null)
sensors.infrared1.setRemoteChannel(null)
```
## See also

View File

@ -25,7 +25,7 @@ In order to recognize a button event signalled from a remote beacon, an infrared
If the beacon button ``center`` is pressed, show a `green` status light. Otherwise, set the status light to `orange`.
```blocks
sensors.infraredSensor1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.infrared1.setRemoteChannel(InfraredRemoteChannel.Ch0)
forever(function () {
if (sensors.remoteButtonCenter.isPressed()) {
brick.setStatusLight(StatusLight.Green)

View File

@ -29,7 +29,7 @@ In order to recognize a button event signalled from a remote beacon, an infrared
Check for an event on beacon button sensor ``center``. Put an expression on the screen when the button is released.
```blocks
sensors.infraredSensor1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.infrared1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.remoteButtonCenter.onEvent(ButtonEvent.Released, function () {
brick.showImage(images.expressionsSick)
})

View File

@ -34,7 +34,7 @@ brick.showString("We're going to wait", 1);
brick.showString("for you to bump the", 2);
brick.showString("touch sensor on port 1", 3);
waitTime = control.millis();
sensors.infraredSensor1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.infrared1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.remoteButtonCenter.pauseUntil(ButtonEvent.Bumped);
brick.clearScreen();
if (control.millis() - waitTime > 5000) {

View File

@ -3,7 +3,7 @@
Set the remote infrared signal channel for an infrared sensor.
```sig
sensors.infraredSensor1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.infrared1.setRemoteChannel(InfraredRemoteChannel.Ch0)
```
An infrared sensor connected to the @boardname@ can receive messages (signals for button events) from a remote infrared beacon. In order for the sensor to know which beacon to receive messages from, a _channel_ is used. The beacon has a switch on it to select a particular channel to transmit on. The sensor needs to know which channel to receive ("listen" for) messages from the beacon.
@ -18,7 +18,7 @@ A sensor is not automatically set to listen for infrared messages on a channel.
Select channel **2** on an infrared beacon. Set the remote channel for infrared sensor ``infrared 3`` to channel ``2``. Wait for the ``center`` button press on the beacon using channel ``2``.
```blocks
sensors.infraredSensor3.setRemoteChannel(InfraredRemoteChannel.Ch2);
sensors.infrared3.setRemoteChannel(InfraredRemoteChannel.Ch2);
sensors.remoteButtonCenter.pauseUntil(ButtonEvent.Pressed);
brick.clearScreen();
brick.showString("Center button on", 1);

View File

@ -27,7 +27,7 @@ In order to recognize a button event signalled from a remote beacon, an infrared
If the beacon button ``top left`` was pressed, show a `green` status light. Otherwise, set the status light to `orange`.
```blocks
sensors.infraredSensor1.setRemoteChannel(InfraredRemoteChannel.Ch0)
sensors.infrared1.setRemoteChannel(InfraredRemoteChannel.Ch0)
forever(function () {
if (sensors.remoteButtonTopLeft.wasPressed()) {
brick.setStatusLight(StatusLight.Green)

View File

@ -1,9 +1,9 @@
# Infrared sensor
```cards
sensors.infraredSensor1.onEvent(null, function () {});
sensors.infraredSensor1.pauseUntil(null);
sensors.infraredSensor1.proximity();
sensors.infrared1.onEvent(null, function () {});
sensors.infrared1.pauseUntil(null);
sensors.infrared1.proximity();
```
## See Also

View File

@ -3,7 +3,7 @@
Run some code when an object is detected by the infrared sensor.
```sig
sensors.infraredSensor4.onEvent(InfraredSensorEvent.ObjectNear, function () {});
sensors.infrared4.onEvent(InfraredSensorEvent.ObjectNear, function () {});
```
How an object is detected depends on the light _thresholds_ set for the sensor. A threshold is a number for relative distance of the a return of reflected infrared light. The brighter the light, the nearer the object is. The value for what _near_ means is determined by this threshold. A certain minimum amount of light returned is also set to determine that an object is detected. The two thresholds you can set are:
@ -23,9 +23,9 @@ How an object is detected depends on the light _thresholds_ set for the sensor.
When the ultrasonic sensor on port 4 detects a near object, display its distance on the screen.
```blocks
sensors.infraredSensor4.onEvent(InfraredSensorEvent.ObjectNear, function () {
sensors.infrared4.onEvent(InfraredSensorEvent.ObjectNear, function () {
brick.showString("Object detected at:", 1)
brick.showNumber(sensors.infraredSensor4.proximity(), 2)
brick.showNumber(sensors.infrared4.proximity(), 2)
brick.showString("percent of range", 3)
})
```

View File

@ -3,7 +3,7 @@
Make your program wait until an some object is detected in proximity of the infrared sensor.
```sig
sensors.infraredSensor1.pauseUntil(InfraredSensorEvent.ObjectDetected);
sensors.infrared1.pauseUntil(InfraredSensorEvent.ObjectDetected);
```
How an object is detected depends on the light _thresholds_ set for the sensor. A threshold is a number for relative distance of the a return of reflected infrared light. The brighter the light, the nearer the object is. The value for what _near_ means is determined by this threshold. A certain minimum amount of light returned is also set to determine that an object is detected. The two thresholds you can set are:
@ -24,7 +24,7 @@ Wait for another object sending out infrared light. Show a message on the screen
```blocks
brick.showString("Waiting for another", 1);
brick.showString("robot to appear...", 2);
sensors.infraredSensor1.pauseUntil(InfraredSensorEvent.ObjectDetected);
sensors.infrared1.pauseUntil(InfraredSensorEvent.ObjectDetected);
brick.showString("Hey, I just saw", 1)
brick.showString("Something!", 2);
```

View File

@ -3,7 +3,7 @@
Get the proximity threshold for when objects are near and detected.
```sig
sensors.infraredSensor1.proximityThreshold(InfraredSensorEvent.ObjectNear)
sensors.infrared1.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.
@ -21,8 +21,8 @@ Infrared sensors determine proximity of an object by measuring the intensity of
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)
sensors.infrared1.onEvent(InfraredSensorEvent.ObjectNear, function () {
brick.showValue("NearObjectThreshold", sensors.infrared1.proximityThreshold(InfraredSensorEvent.ObjectNear)
, 1)
})
```

View File

@ -3,7 +3,7 @@
Get the promixity of an object measured by the infrared sensor.
```sig
sensors.infraredSensor1.proximity();
sensors.infrared1.proximity();
```
The proximity value returned is a number between `0` and `100` which is a _relative_ measurment of distance to an object. A value of `0` means something is very close and `100` means something is far away. The proximity is determined by the amount of infrared light reflected back by an object. The proximity value for an object that has a lighter color and smooth surface will be less than an object at the same distance with a darker color and a rough surface.
@ -19,9 +19,9 @@ Proximity isn't an actual measurement units of distance, like in centimeters or
When the infrared sensor on port 4 detects a near object, display its proximity value on the screen.
```blocks
sensors.infraredSensor4.onEvent(InfraredSensorEvent.ObjectNear, function () {
sensors.infrared4.onEvent(InfraredSensorEvent.ObjectNear, function () {
brick.clearScreen()
brick.showValue("proximity", sensors.infraredSensor4.proximity(), 1)
brick.showValue("proximity", sensors.infrared4.proximity(), 1)
})
```

View File

@ -3,7 +3,7 @@
Set the proximity threshold for when objects are near or detected.
```sig
sensors.infraredSensor1.setPromixityThreshold(InfraredSensorEvent.ObjectNear, 0)
sensors.infrared1.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.
@ -20,8 +20,8 @@ If you want a proximity value of `32` to mean that a detected object is near, th
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)
sensors.infrared1.setPromixityThreshold(InfraredSensorEvent.ObjectDetected, 30)
sensors.infrared1.pauseUntil(InfraredSensorEvent.ObjectDetected)
brick.clearScreen()
brick.showString("Perimeter Breach!!!", 3)
brick.setStatusLight(StatusLight.RedFlash)

View File

@ -281,16 +281,16 @@ namespace sensors {
}
//% fixedInstance whenUsed block="1" jres=icons.port1
export const infraredSensor1: InfraredSensor = new InfraredSensor(1)
export const infrared1: InfraredSensor = new InfraredSensor(1)
//% fixedInstance whenUsed block="2" jres=icons.port2
export const infraredSensor2: InfraredSensor = new InfraredSensor(2)
export const infrared2: InfraredSensor = new InfraredSensor(2)
//% fixedInstance whenUsed block="3" jres=icons.port3
export const infraredSensor3: InfraredSensor = new InfraredSensor(3)
export const infrared3: InfraredSensor = new InfraredSensor(3)
//% fixedInstance whenUsed block="4" jres=icons.port4
export const infraredSensor4: InfraredSensor = new InfraredSensor(4)
export const infrared4: InfraredSensor = new InfraredSensor(4)
/**
* Remote beacon (center) button.