WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Classes | Public Types | Public Member Functions | List of all members
HiTechnicColorSensor Class Reference

#include <HiTechnicColorSensor.h>

Inheritance diagram for HiTechnicColorSensor:
SensorBase ErrorBase

Classes

struct  RGB
 

Public Types

enum  tColorMode { kActive = 0, kPassive = 1, kRaw = 3 }
 

Public Member Functions

 HiTechnicColorSensor (uint8_t moduleNumber)
 
virtual ~HiTechnicColorSensor ()
 
uint8_t GetColor ()
 
uint8_t GetRed ()
 
uint8_t GetGreen ()
 
uint8_t GetBlue ()
 
RGB GetRGB ()
 
uint16_t GetRawRed ()
 
uint16_t GetRawGreen ()
 
uint16_t GetRawBlue ()
 
RGB GetRawRGB ()
 
void SetMode (tColorMode mode)
 
virtual std::string GetType ()
 
virtual void InitTable (ITable *subtable)
 
virtual void UpdateTable ()
 
virtual ITable * GetTable ()
 
virtual void StartLiveWindowMode ()
 
virtual void StopLiveWindowMode ()
 
- Public Member Functions inherited from SensorBase
 SensorBase ()
 
virtual ~SensorBase ()
 
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (ErrorBase *rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
 
static uint32_t GetDefaultAnalogModule ()
 
static uint32_t GetDefaultDigitalModule ()
 
static uint32_t GetDefaultSolenoidModule ()
 
static bool CheckAnalogModule (uint8_t moduleNumber)
 
static bool CheckDigitalModule (uint8_t moduleNumber)
 
static bool CheckPWMModule (uint8_t moduleNumber)
 
static bool CheckRelayModule (uint8_t moduleNumber)
 
static bool CheckSolenoidModule (uint8_t moduleNumber)
 
static bool CheckDigitalChannel (uint32_t channel)
 
static bool CheckRelayChannel (uint32_t channel)
 
static bool CheckPWMChannel (uint32_t channel)
 
static bool CheckAnalogChannel (uint32_t channel)
 
static bool CheckSolenoidChannel (uint32_t channel)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 
- Static Public Attributes inherited from SensorBase
static const uint32_t kSystemClockTicksPerMicrosecond = 40
 
static const uint32_t kDigitalChannels = 14
 
static const uint32_t kAnalogChannels = 8
 
static const uint32_t kAnalogModules = 2
 
static const uint32_t kDigitalModules = 2
 
static const uint32_t kSolenoidChannels = 8
 
static const uint32_t kSolenoidModules = 2
 
static const uint32_t kPwmChannels = 10
 
static const uint32_t kRelayChannels = 8
 
static const uint32_t kChassisSlots = 8
 
- Protected Member Functions inherited from SensorBase
void AddToSingletonList ()
 
- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
 
static Error _globalError
 

Detailed Description

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

Constructor & Destructor Documentation

HiTechnicColorSensor::HiTechnicColorSensor ( uint8_t  moduleNumber)
explicit

Constructor.

Parameters
moduleNumberThe digital module that the sensor is plugged into (1 or 2).
HiTechnicColorSensor::~HiTechnicColorSensor ( )
virtual

Destructor.

Member Function Documentation

uint8_t HiTechnicColorSensor::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.
uint8_t HiTechnicColorSensor::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.
uint8_t HiTechnicColorSensor::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.
uint16_t HiTechnicColorSensor::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.
uint16_t HiTechnicColorSensor::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.
uint16_t HiTechnicColorSensor::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.
HiTechnicColorSensor::RGB HiTechnicColorSensor::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.
uint8_t HiTechnicColorSensor::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.
HiTechnicColorSensor::RGB HiTechnicColorSensor::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
ITable * HiTechnicColorSensor::GetTable ( )
virtual
void HiTechnicColorSensor::InitTable ( ITable *  subtable)
virtual
void HiTechnicColorSensor::SetMode ( tColorMode  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
modeThe mode to set
void HiTechnicColorSensor::StartLiveWindowMode ( )
virtual
void HiTechnicColorSensor::StopLiveWindowMode ( )
virtual
void HiTechnicColorSensor::UpdateTable ( )
virtual

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