#include <HiTechnicColorSensor.h>
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 Error & | GetError () |
Retrieve the current error. Get the current error information associated with this sensor. | |
virtual const Error & | GetError () 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 Error & | GetGlobalError () |
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 |
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.
|
explicit |
Constructor.
moduleNumber | The digital module that the sensor is plugged into (1 or 2). |
Definition at line 33 of file HiTechnicColorSensor.cpp.
|
virtual |
Destructor.
Definition at line 64 of file HiTechnicColorSensor.cpp.
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.
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
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.
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.
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.
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.
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.
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.
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.
Definition at line 184 of file HiTechnicColorSensor.cpp.
|
virtual |
Definition at line 369 of file HiTechnicColorSensor.cpp.
|
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.
mode | The mode to set |
Definition at line 327 of file HiTechnicColorSensor.cpp.
|
virtual |
Definition at line 377 of file HiTechnicColorSensor.cpp.
|
virtual |
Definition at line 385 of file HiTechnicColorSensor.cpp.
|
virtual |
Definition at line 354 of file HiTechnicColorSensor.cpp.