# Class: ColorDistanceSensor

## ColorDistanceSensor

#### new ColorDistanceSensor()

  Source:
    - devices/colordistancesensor.js, line 25

### Extends

- Device

### Members

#### <readonly> connected

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `connected` | boolean | Check if the device is still attached.

  Inherited From:
    - Device#connected
  Source:
    - devices/device.js, line 75

#### <readonly> hub

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `hub` | Hub | The Hub the device is attached to.

  Inherited From:
    - Device#hub
  Source:
    - devices/device.js, line 82

#### <readonly> isVirtualPort

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isVirtualPort` | boolean | Is this device attached to a virtual port (ie. a combined device)

  Inherited From:
    - Device#isVirtualPort
  Source:
    - devices/device.js, line 119

#### <readonly> mode

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `mode` | number | The mode the device is currently in

  Inherited From:
    - Device#mode
  Source:
    - devices/device.js, line 109

#### <readonly> portName

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `portName` | string | The port the device is attached to.

  Inherited From:
    - Device#portName
  Source:
    - devices/device.js, line 92

#### <readonly> type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | number | The type of the device

  Inherited From:
    - Device#type
  Source:
    - devices/device.js, line 99

### 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:
    - devices/colordistancesensor.js, line 149

  ##### 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:
    - devices/colordistancesensor.js, line 167

  ##### 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:
    - devices/colordistancesensor.js, line 87

  ##### 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:
    - devices/colordistancesensor.js, line 107

  ##### 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:
    - devices/colordistancesensor.js, line 127

  ##### 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:
    - devices/colordistancesensor.js, line 39

#### 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:
    - devices/colordistancesensor.js, line 73

#### distance

  Emits when a distance sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `distance` | number | Distance, in millimeters.

  Source:
    - devices/colordistancesensor.js, line 54

#### Search results