VEX V5 C++ API
Public Member Functions | List of all members
vex::optical Class Reference

Use the optical class to control the optical sensor. More...

Inherits vex::device.

Public Member Functions

 optical (int32_t index)
 Creates a new optical sensor object on the port specified. More...
 
 ~optical ()
 
bool installed ()
 
int32_t value ()
 
double hue ()
 Gets the hue detected by the optical sensor. More...
 
double brightness (bool bRaw=false)
 Gets the brightness value detected by the optical sensor. More...
 
vex::color color ()
 Gets the detected color as saturated vex::color. More...
 
bool isNearObject ()
 Check to see if an object is detected by the optical sensor. More...
 
void setLight (ledState state)
 Turns the led on the optical sensor on or off. More...
 
void setLight (int32_t intensity, percentUnits units=percentUnits::pct)
 Set the intensity of the led on the optical sensor. More...
 
- Public Member Functions inherited from vex::device
 device ()
 
 device (int32_t index)
 
 ~device ()
 
V5_DeviceType type ()
 
void init (int32_t index)
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Use the optical class to control the optical sensor.

Constructor & Destructor Documentation

◆ optical()

vex::optical::optical ( int32_t  index)

Creates a new optical sensor object on the port specified.

Parameters
indexThe port index for this sensor. The index is zero-based.

◆ ~optical()

vex::optical::~optical ( )

Member Function Documentation

◆ installed()

bool vex::optical::installed ( )
virtual

Reimplemented from vex::device.

◆ value()

int32_t vex::optical::value ( )
virtual

Reimplemented from vex::device.

◆ hue()

double vex::optical::hue ( )

Gets the hue detected by the optical sensor.

Returns
a value that represents the hue the optical sensor has detected in range 0 to 359.999

◆ brightness()

double vex::optical::brightness ( bool  bRaw = false)

Gets the brightness value detected by the optical sensor.

Returns
a value that represents the brightness value the optical sensor has detected as a percentage, or 0 to 1.0 if bRaw = true.

◆ color()

vex::color vex::optical::color ( )

Gets the detected color as saturated vex::color.

Returns
a vex::color object that represents the hue of the closest color detected to twelve possible values.

◆ isNearObject()

bool vex::optical::isNearObject ( )

Check to see if an object is detected by the optical sensor.

Returns
a boolean that represents whether an object has been detected.

◆ setLight() [1/2]

void vex::optical::setLight ( ledState  state)

Turns the led on the optical sensor on or off.

◆ setLight() [2/2]

void vex::optical::setLight ( int32_t  intensity,
percentUnits  units = percentUnits::pct 
)

Set the intensity of the led on the optical sensor.

Parameters
intensitylight intensity, 0-100
unitspercent units, optional