VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
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

Classes

class  gesture
 A class to collect all gesture detection data. More...
 
class  rgbc
 A class to hold raw or processed rgbc data. More...
 

Public Member Functions

 optical (int32_t index, bool enableGesture=false)
 Creates a new optical sensor object on the port specified.
 
bool installed ()
 
int32_t value ()
 
double hue ()
 Gets the hue detected by the optical sensor.
 
double brightness (bool bRaw=false)
 Gets the brightness value detected by the optical sensor.
 
vex::colorType colorname ()
 Gets the detected color as a fully saturated vex::color.
 
bool isNearObject ()
 Check to see if an object is detected by the optical sensor.
 
void objectDetected (void(*callback)(void))
 Calls a function when the optical sensor proximity sensor detects an object.
 
void objectLost (void(*callback)(void))
 Calls a function when the optical sensor proximity sensor detects an object is missing.
 
int32_t objectDetectThreshold (int32_t value=0)
 sets the value of the detection threshold
 
void gestureUp (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement down to up.
 
void gestureDown (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement up to down.
 
void gestureLeft (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement right to left.
 
void gestureRight (void(*callback)(void))
 Calls a function when the optical sensor gesture engine detects a movement left to right.
 
void setLight (ledState state)
 Turns the led on the optical sensor on or off.
 
void setLightPower (int32_t intensity, percentUnits units=percentUnits::pct)
 Set the intensity of the led on the optical sensor in percent.
 
void gestureEnable (void)
 Enable gesture detection on the optical sensor.
 
void gestureDisable (void)
 Disable gesture detection on the optical sensor.
 
optical::gesture getGesture ()
 get object with the most recent gesture detection data.
 
optical::rgbc getRgb (bool bRawColor=true)
 get raw or processed rgbc data. The default is raw.
 
void integrationTime (double timeMs)
 set sensor integration time
 
double integrationTime ()
 get sensor integration time
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
IQ_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
int32_t readDigitalPin ()
 
int32_t readAnalogPin ()
 

Additional Inherited Members

- Protected Member Functions inherited from vex::device
void setPollInterval (int32_t value)
 
bool pollValid (bool bSave)
 
- Protected Attributes inherited from vex::device
int16_t _index
 

Detailed Description

Use the optical class to control the optical sensor.

Definition at line 26 of file vex_optical.h.

Constructor & Destructor Documentation

◆ optical()

vex::optical::optical ( int32_t index,
bool enableGesture = false )

Creates a new optical sensor object on the port specified.

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

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.

◆ colorname()

vex::colorType vex::optical::colorname ( )

Gets the detected color as a fully saturated vex::color.

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

Gets the detected color as a colorType

Returns
Returns a colorType that represents the name of the closest color detected to twelve possible values.

◆ gestureDown()

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

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(* callback )(void))

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(* callback )(void))

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(* callback )(void))

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.

◆ installed()

bool vex::optical::installed ( )
virtual

Reimplemented from vex::device.

◆ 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(* callback )(void))

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

Parameters
callbackA reference to a function.

◆ objectDetectThreshold()

int32_t vex::optical::objectDetectThreshold ( int32_t value = 0)

sets the value of the detection threshold

Parameters
valueThe new detection threshold in proximity units (1 to 255). 0 means no change.
Returns
the current value of the proximity threshold

◆ objectLost()

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

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

Parameters
callbackA reference to a function.

◆ value()

int32_t vex::optical::value ( )
virtual

Reimplemented from vex::device.


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