"

2013 FRC Java API

"

edu.wpi.first.wpilibj
Class HiTechnicColorSensor

java.lang.Object
  extended by edu.wpi.first.wpilibj.SensorBase
      extended by edu.wpi.first.wpilibj.HiTechnicColorSensor
All Implemented Interfaces:
LiveWindowSendable, IDevice, ISensor, Sendable

public class HiTechnicColorSensor
extends SensorBase
implements ISensor, LiveWindowSendable

HiTechnic NXT Color Sensor. This class allows access to a HiTechnic NXT Color Sensor on an I2C bus. These sensors do not allow changing addresses so you cannot have more than one on a single bus. Details on the sensor can be found here: http://www.hitechnic.com/index.html?lang=en-us&target=d17.html


Nested Class Summary
 class HiTechnicColorSensor.ColorSensorException
          An exception dealing with connecting to and communicating with the HiTechnicCompass
 class HiTechnicColorSensor.RGB
          A set of three color values bundled into one object
static class HiTechnicColorSensor.tColorSensorMode
           
 
Field Summary
 
Fields inherited from class edu.wpi.first.wpilibj.SensorBase
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond
 
Constructor Summary
HiTechnicColorSensor(int slot)
          Constructor.
 
Method Summary
 void free()
          Destructor.
 int getBlue()
          Get the Blue value.
 byte getColor()
          Get the estimated color.
 int getGreen()
          Get the Green value.
 double getRawBlue()
          Get the Raw Blue value.
 double getRawGreen()
          Get the Raw Green value.
 double getRawRed()
          Get the Raw Red value.
 HiTechnicColorSensor.RGB getRawRGB()
          Get the raw value of all three colors from a single sensor reading.
 int getRed()
          Get the Red value.
 HiTechnicColorSensor.RGB getRGB()
          Get the value of all three colors from a single sensor reading.
 String getSmartDashboardType()
           
 ITable getTable()
          
 void initTable(ITable subtable)
          Initializes a table for this sendable object.
 void setMode(HiTechnicColorSensor.tColorSensorMode mode)
          Set the Mode of the color sensor This method is used to set the color sensor to one of the three modes, active, passive or raw.
 void startLiveWindowMode()
          Start having this sendable object automatically respond to value changes reflect the value on the table.
 void stopLiveWindowMode()
          Stop having this sendable object automatically respond to value changes.
 void updateTable()
          Update the table for this sendable object with the latest values.
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HiTechnicColorSensor

public HiTechnicColorSensor(int slot)
Constructor.

Parameters:
slot - The slot of the digital module that the sensor is plugged into.
Method Detail

free

public void free()
Destructor.

Overrides:
free in class SensorBase

getColor

public byte getColor()
Get the estimated color. Gets a color estimate from the sensor corresponding to the table found with the sensor or at the following site: http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NCO1038

Returns:
The estimated color.

getRGB

public HiTechnicColorSensor.RGB getRGB()
Get the value of all three colors from a single sensor reading. Using this method ensures that all three values come from the same sensor reading, using the individual color methods provides no such guarantee. The sensor must be in active mode to access the regular RGB data if the sensor is not in active mode, it will be placed into active mode by this method.

Returns:
RGB object with the three color values

getRed

public int getRed()
Get the Red value. Gets the (0-255) red value from the sensor. The sensor must be in active mode to access the regular RGB data if the sensor is not in active mode, it will be placed into active mode by this method.

Returns:
The Red sensor value.

getGreen

public int getGreen()
Get the Green value. Gets the(0-255) green value from the sensor. The sensor must be in active mode to access the regular RGB data if the sensor is not in active mode, it will be placed into active mode by this method.

Returns:
The Green sensor value.

getBlue

public int getBlue()
Get the Blue value. Gets the raw (0-255) blue value from the sensor. The sensor must be in active mode to access the regular RGB data if the sensor is not in active mode, it will be placed into active mode by this method.

Returns:
The Blue sensor value.

getRawRed

public double getRawRed()
Get the Raw Red value. Gets the (0-65536) raw red value from the sensor. The sensor must be in raw or passive mode to access the regular RGB data if the sensor is not in raw or passive mode, it will be placed into raw mode by this method.

Returns:
The Raw Red sensor value.

getRawGreen

public double getRawGreen()
Get the Raw Green value. Gets the (0-65536) raw green value from the sensor. The sensor must be in raw or passive mode to access the regular RGB data if the sensor is not in raw or passive mode, it will be placed into raw mode by this method.

Returns:
The Raw Green sensor value.

getRawBlue

public double getRawBlue()
Get the Raw Blue value. Gets the (0-65536) raw blue value from the sensor. The sensor must be in raw or passive mode to access the regular RGB data if the sensor is not in raw or passive mode, it will be placed into raw mode by this method.

Returns:
The Raw Blue sensor value.

getRawRGB

public HiTechnicColorSensor.RGB getRawRGB()
Get the raw value of all three colors from a single sensor reading. Using this method ensures that all three values come from the same sensor reading, using the individual color methods provides no such guarantee. Gets the (0-65536) raw color values from the sensor. The sensor must be in raw or passive mode to access the regular RGB data if the sensor is not in raw or passive mode, it will be placed into raw mode by this method.

Returns:
An RGB object with the raw sensor values.

setMode

public void setMode(HiTechnicColorSensor.tColorSensorMode mode)
Set the Mode of the color sensor This method is used to set the color sensor to one of the three modes, active, passive or raw. The sensor defaults to active mode which uses the internal LED and returns an interpreted color value and 3 8-bit RGB channel values. Raw mode uses the internal LED and returns 3 16-bit RGB channel values. Passive mode disables the internal LED and returns 3 16-bit RGB channel values.

Parameters:
mode - The mode to set

getSmartDashboardType

public String getSmartDashboardType()
Specified by:
getSmartDashboardType in interface Sendable
Returns:
the string representation of the named data type that will be used by the smart dashboard for this sendable

initTable

public void initTable(ITable subtable)
Initializes a table for this sendable object.

Specified by:
initTable in interface Sendable
Parameters:
subtable - The table to put the values in.

getTable

public ITable getTable()

Specified by:
getTable in interface Sendable
Returns:
the table that is currently associated with the sendable

updateTable

public void updateTable()
Update the table for this sendable object with the latest values.

Specified by:
updateTable in interface LiveWindowSendable

startLiveWindowMode

public void startLiveWindowMode()
Start having this sendable object automatically respond to value changes reflect the value on the table.

Specified by:
startLiveWindowMode in interface LiveWindowSendable

stopLiveWindowMode

public void stopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.

Specified by:
stopLiveWindowMode in interface LiveWindowSendable

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"