Class: ColorDistanceSensor

ColorDistanceSensor


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)

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)

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

setPFExtendedChannel(channel)

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)

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)

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


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: