new ColorDistanceSensor()
- Source:
Extends
Members
(readonly) connected
Properties:
Name | Type | Description |
---|---|---|
connected |
boolean | Check if the device is still attached. |
- Inherited From:
- Source:
(readonly) hub
Properties:
Name | Type | Description |
---|---|---|
hub |
Hub | The Hub the device is attached to. |
- Inherited From:
- Source:
(readonly) isVirtualPort
Properties:
Name | Type | Description |
---|---|---|
isVirtualPort |
boolean | Is this device attached to a virtual port (ie. a combined device) |
- Inherited From:
- Source:
(readonly) mode
Properties:
Name | Type | Description |
---|---|---|
mode |
number | The mode the device is currently in |
- Inherited From:
- Source:
(readonly) portName
Properties:
Name | Type | Description |
---|---|---|
portName |
string | The port the device is attached to. |
- Inherited From:
- Source:
(readonly) type
Properties:
Name | Type | Description |
---|---|---|
type |
number | The type of the device |
- Inherited From:
- Source:
Methods
sendPFIRMessage(message) → {Promise}
Send a raw Power Functions IR command
Parameters:
Name | Type | Description |
---|---|---|
message |
Buffer | 2 byte payload making up a Power Functions protocol command. NOTE: Only specify nibbles 1-3, nibble 4 should be zeroed. |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
setColor(color) → {Promise}
Set the color of the LED on the sensor via a color value.
Parameters:
Name | Type | Description |
---|---|---|
color |
Color |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
setDistanceCount(distance) → {Promise}
Set the distance count value.
Parameters:
Name | Type | Description |
---|---|---|
distance |
count | count between 0 and 2^32 |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
setPFExtendedChannel(channel) → {Promise}
Switches the IR receiver into extended channel mode. After setting this, use channels 5-8 instead of 1-4 for this receiver.
NOTE: Calling this with channel 5-8 with switch off extended channel mode for this receiver.
Parameters:
Name | Type | Description |
---|---|---|
channel |
number | Channel number, between 1-8 |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
setPFPower(channel, output, power) → {Promise}
Set the power of a Power Functions motor via IR
Parameters:
Name | Type | Description |
---|---|---|
channel |
number | Channel number, between 1-4 |
output |
string | Outport port, "RED" (A) or "BLUE" (B) |
power |
number | 7 (full reverse) to 7 (full forward). 0 is stop. 8 is brake. |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
startPFMotors(channel, powerA, powerB) → {Promise}
Start Power Functions motors running via IR
NOTE: This command is designed for bang-bang style operation. To keep the motors running, the sensor needs to be within range of the IR receiver constantly.
Parameters:
Name | Type | Description |
---|---|---|
channel |
Buffer | Channel number, between 1-4 |
powerA |
Buffer | 7 (full reverse) to 7 (full forward). 0 is stop. 8 is brake. |
powerB |
Buffer | 7 (full reverse) to 7 (full forward). 0 is stop. 8 is brake. |
- Source:
Returns:
Resolved upon successful issuance of the command.
- Type
- Promise
Events
ambient
Event measuring abient light change, emits when the sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
percentage |
number | from 0 to 100. |
- Source:
color
Emits when a color sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
color |
Color |
- Source:
colorAndDistance
A combined color and distance event, emits when the sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
color |
Color | |
distance |
number | Distance, in millimeters. |
- Source:
distance
Emits when a distance sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
distance |
number | Distance, in millimeters. |
- Source:
distanceCount
Emits when distance is reduced to less than 10 centimeters.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
number |
number | of distance events. |
- Source:
reflect
Event measuring reflection change, emits when the sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
percentage |
number | from 0 to 100. |
- Source:
rgbIntensity
Emits when a color sensor is activated.
Type:
- object
Parameters:
Name | Type | Description |
---|---|---|
red |
number | |
green |
number | |
blue |
number |
- Source: