diff --git a/docs/reference/sensors.md b/docs/reference/sensors.md index 8dd183be..c6532998 100644 --- a/docs/reference/sensors.md +++ b/docs/reference/sensors.md @@ -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) ``` diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon.md b/libs/infrared-sensor/docs/reference/sensors/beacon.md index 20a3a95f..60e89a4c 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon.md @@ -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 diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon/is-pressed.md b/libs/infrared-sensor/docs/reference/sensors/beacon/is-pressed.md index 61cde0de..5134c10f 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon/is-pressed.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon/is-pressed.md @@ -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) diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon/on-event.md b/libs/infrared-sensor/docs/reference/sensors/beacon/on-event.md index cac6ab00..34d5d5fd 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon/on-event.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon/on-event.md @@ -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) }) diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon/pause-until.md b/libs/infrared-sensor/docs/reference/sensors/beacon/pause-until.md index 422e82fc..5d8146ce 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon/pause-until.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon/pause-until.md @@ -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) { diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon/set-remote-channel.md b/libs/infrared-sensor/docs/reference/sensors/beacon/set-remote-channel.md index 0a2f1e2c..8e909eb4 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon/set-remote-channel.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon/set-remote-channel.md @@ -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); diff --git a/libs/infrared-sensor/docs/reference/sensors/beacon/was-pressed.md b/libs/infrared-sensor/docs/reference/sensors/beacon/was-pressed.md index 425404c2..b9bdcd97 100644 --- a/libs/infrared-sensor/docs/reference/sensors/beacon/was-pressed.md +++ b/libs/infrared-sensor/docs/reference/sensors/beacon/was-pressed.md @@ -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) diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared.md b/libs/infrared-sensor/docs/reference/sensors/infrared.md index ea3c1b33..475ef70b 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared.md @@ -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 diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared/on-event.md b/libs/infrared-sensor/docs/reference/sensors/infrared/on-event.md index 1b01045a..c33fe98e 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared/on-event.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared/on-event.md @@ -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) }) ``` diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared/pause-until.md b/libs/infrared-sensor/docs/reference/sensors/infrared/pause-until.md index c6dece68..ac3fbdb0 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared/pause-until.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared/pause-until.md @@ -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); ``` diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared/proximity-threshold.md b/libs/infrared-sensor/docs/reference/sensors/infrared/proximity-threshold.md index 6d11f380..880e4dcd 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared/proximity-threshold.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared/proximity-threshold.md @@ -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) }) ``` diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared/proximity.md b/libs/infrared-sensor/docs/reference/sensors/infrared/proximity.md index e9ff8b8d..a6285e8d 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared/proximity.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared/proximity.md @@ -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) }) ``` diff --git a/libs/infrared-sensor/docs/reference/sensors/infrared/set-proximity-threshold.md b/libs/infrared-sensor/docs/reference/sensors/infrared/set-proximity-threshold.md index f857b019..da8dd59c 100644 --- a/libs/infrared-sensor/docs/reference/sensors/infrared/set-proximity-threshold.md +++ b/libs/infrared-sensor/docs/reference/sensors/infrared/set-proximity-threshold.md @@ -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) diff --git a/libs/infrared-sensor/ir.ts b/libs/infrared-sensor/ir.ts index 4954ea4b..80253a11 100644 --- a/libs/infrared-sensor/ir.ts +++ b/libs/infrared-sensor/ir.ts @@ -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.