Now you can download a copy of these docs so you can use them offline! Download now
HiTechnicColorSensor Class Reference

#include <HiTechnicColorSensor.h>

Inheritance diagram for HiTechnicColorSensor:
Collaboration diagram for HiTechnicColorSensor:

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

Definition at line 26 of file HiTechnicColorSensor.h.

Constructor & Destructor Documentation

HiTechnicColorSensor::HiTechnicColorSensor ( uint8_t  moduleNumber)
explicit

Constructor.

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

Definition at line 33 of file HiTechnicColorSensor.cpp.

HiTechnicColorSensor::~HiTechnicColorSensor ( )
virtual

Destructor.

Definition at line 64 of file HiTechnicColorSensor.cpp.

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.

Definition at line 157 of file HiTechnicColorSensor.cpp.

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.

Definition at line 79 of file HiTechnicColorSensor.cpp.

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.

Definition at line 131 of file HiTechnicColorSensor.cpp.

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.

Definition at line 268 of file HiTechnicColorSensor.cpp.

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.

Definition at line 242 of file HiTechnicColorSensor.cpp.

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.

Definition at line 216 of file HiTechnicColorSensor.cpp.

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.

Definition at line 297 of file HiTechnicColorSensor.cpp.

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.

Definition at line 105 of file HiTechnicColorSensor.cpp.

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

Definition at line 184 of file HiTechnicColorSensor.cpp.

ITable * HiTechnicColorSensor::GetTable ( )
virtual

Definition at line 369 of file HiTechnicColorSensor.cpp.

void HiTechnicColorSensor::InitTable ( ITable subtable)
virtual

Definition at line 346 of file HiTechnicColorSensor.cpp.

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

Definition at line 327 of file HiTechnicColorSensor.cpp.

void HiTechnicColorSensor::StartLiveWindowMode ( )
virtual

Definition at line 377 of file HiTechnicColorSensor.cpp.

void HiTechnicColorSensor::StopLiveWindowMode ( )
virtual

Definition at line 385 of file HiTechnicColorSensor.cpp.

void HiTechnicColorSensor::UpdateTable ( )
virtual

Definition at line 354 of file HiTechnicColorSensor.cpp.


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

Generated on Sat Apr 26 2014 12:26:46 for WPILibC++ by doxygen 1.8.6