VEX V5 Python 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

def __init__ (self, index)
 Creates a new optical sensor object on the port specified. More...
 
def hue (self)
 Gets the hue detected by the optical sensor. More...
 
def brightness (self, raw=False)
 Gets the brightness value detected by the optical sensor. More...
 
def color (self)
 Gets the detected color as saturated vex::color. More...
 
def color_int (self)
 Gets the detected color as saturated int value. More...
 
def is_near_object (self)
 Check to see if an object is detected by the optical sensor. More...
 
def set_light (self, ledState)
 Turns the led on the optical sensor on or off. More...
 
def set_light_pct (self, intensity, percentUnits=PercentUnits.PCT)
 Set the intensity of the led on the optical sensor. More...
 
def type (self)
 Get the device type. More...
 
def installed (self)
 Gets the status of what is installed. More...
 
def value (self)
 

Detailed Description

Use the optical class to control the optical sensor.

Constructor & Destructor Documentation

◆ __init__()

def vex.Optical.__init__ (   self,
  index 
)

Creates a new optical sensor object on the port specified.

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

Reimplemented from vex.Device.

Member Function Documentation

◆ hue()

def vex.Optical.hue (   self)

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()

def vex.Optical.brightness (   self,
  raw = 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 raw = True.

◆ color()

def vex.Optical.color (   self)

Gets the detected color as saturated vex::color.

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

◆ color_int()

def vex.Optical.color_int (   self)

Gets the detected color as saturated int value.

Returns
a number in 0xRRGGBB format that represents the hue of the closest color, detected to twelve possible values.

◆ is_near_object()

def vex.Optical.is_near_object (   self)

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

Returns
True if an object has been detected, False otherwise.

◆ set_light()

def vex.Optical.set_light (   self,
  ledState 
)

Turns the led on the optical sensor on or off.

Parameters
ledStatea boolean or a vex.LedState value, ON or OFF

◆ set_light_pct()

def vex.Optical.set_light_pct (   self,
  intensity,
  percentUnits = PercentUnits.PCT 
)

Set the intensity of the led on the optical sensor.

Parameters
intensitylight intensity, 0-100
percentUnits(optional) percent unit

◆ type()

def vex.Device.type (   self)
inherited

Get the device type.

Returns
V5DeviceType enum value

◆ installed()

def vex.Device.installed (   self)
inherited

Gets the status of what is installed.

Returns
Returns a true Boolean if the triport is installed. Returns a false Boolean if the triport is not installed.

◆ value()

def vex.Device.value (   self)
inherited