VEXcode Doxygen
Public Member Functions | List of all members
vex::optical Class Reference

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

#include <vex_optical.h>

Inheritance diagram for vex::optical:
vex::device

Public Member Functions

 optical (int32_t index)
 Creates a new optical sensor object on the port specified. More...
 
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 detectec color as saturated vex::color. More...
 
bool isNearObject ()
 Check to see if an object is detected by the optical sensor. More...
 
void objectDetected (void(*callback)(void))
 Calls a function when the optical sensor proximity sensor detects an object. More...
 
void objectLost (void(*callback)(void))
 Calls a function when the optical sensor proximity sensor detects an object is missing. More...
 
int32_t objectDetectThreshold (int32_t value=0)
 
void gestureUp (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement down to up. More...
 
void gestureDown (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement up to down. More...
 
void gestureLeft (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement right to left. More...
 
void gestureRight (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement left to right. More...
 
void setLight (ledState state)
 Turns the led on the optical sensor on or off.
 
void setLight (int32_t intensity, percentUnits units=percentUnits::pct)
 Set the intensity of the led on the optical sensor.
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
V5_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
uint32_t timestamp ()
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 
int32_t _threadID
 

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.

Member Function Documentation

◆ brightness()

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

Gets the brightness value detected by the optical sensor.

Returns
Returns an integer that represents the brightness value the optical sensor has detected.

◆ color()

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

Gets the detectec color as saturated vex::color.

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

◆ gestureDown()

void vex::optical::gestureDown ( void(*)(void)  callback)

Calls a function when the optical sensor gesture engine detects a movement up to down.

Parameters
callbackA reference to a function.

◆ gestureLeft()

void vex::optical::gestureLeft ( void(*)(void)  callback)

Calls a function when the optical sensor gesture engine detects a movement right to left.

Parameters
callbackA reference to a function.

◆ gestureRight()

void vex::optical::gestureRight ( void(*)(void)  callback)

Calls a function when the optical sensor gesture engine detects a movement left to right.

Parameters
callbackA reference to a function.

◆ gestureUp()

void vex::optical::gestureUp ( void(*)(void)  callback)

Calls a function when the optical sensor gesture engine detects a movement down to up.

Parameters
callbackA reference to a function.

◆ hue()

double vex::optical::hue ( )

Gets the hue detected by the optical sensor.

Returns
Returns an integer that represents the hue the optical sensor has detected.

◆ isNearObject()

bool vex::optical::isNearObject ( )

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

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

◆ objectDetected()

void vex::optical::objectDetected ( void(*)(void)  callback)

Calls a function when the optical sensor proximity sensor detects an object.

Parameters
callbackA reference to a function.

◆ objectLost()

void vex::optical::objectLost ( void(*)(void)  callback)

Calls a function when the optical sensor proximity sensor detects an object is missing.

Parameters
callbackA reference to a function.

The documentation for this class was generated from the following file: