ECRobot C++ API for LEGO MINDSTORMS NXT  1.0.10
ecrobot::NxtColorSensor Class Reference

NXT2.0 Color sensor class. More...

#include <NxtColorSensor.h>

List of all members.

Public Types

enum  eSensorMode {
  _COLORSENSOR = 0, _LIGHTSENSOR_RED, _LIGHTSENSOR_GREEN, _LIGHTSENSOR_BLUE,
  _LIGHTSENSOR_WHITE, _LIGHTSENSOR_NONE, _DEACTIVATE
}
 Enum for NXT Color Sensor modes. More...
enum  eColorNumber {
  _BLACK = 0, _BLUE, _GREEN, _YELLOW,
  _ORANGE, _RED, _WHITE, _UNKNOWN = 99
}
 Enum for color number of NXT Color Sensor. More...

Public Member Functions

 NxtColorSensor (ePortS port, eSensorMode mode=_COLORSENSOR)
 Constructor.
virtual ~NxtColorSensor (void)
 Destructor.
void processBackground (void)
 Background process to communicate with the sensor.
void setSensorMode (eSensorMode mode)
 Set NXT color sensor mode.
eSensorMode getSensorMode (void) const
 Get NXT color sensor mode.
S16 get (void) const
 Get raw sensor data in the light sensor modes.
S16 getBrightness (void) const
 Get brightness in the light sensor modes.
eColorNumber getColorNumber (void) const
 Get color number in the color sensor mode.
void getRawColor (S16 rgb[3]) const
 Get raw sensor data in the color sensor mode.

Detailed Description

NXT2.0 Color sensor class.


Member Enumeration Documentation

Enum for color number of NXT Color Sensor.

Enumerator:
_BLACK 

Black of NXT Color Sensor.

_BLUE 

Blue of NXT Color Sensor.

_GREEN 

Green of NXT Color Sensor.

_YELLOW 

Yellow of NXT Color Sensor.

_ORANGE 

Orange of NXT Color Sensor.

_RED 

Red of NXT Color Sensor.

_WHITE 

White of NXT Color Sensor.

_UNKNOWN 

Unknown color of NXT Color Sensor.

Enum for NXT Color Sensor modes.

Enumerator:
_COLORSENSOR 

activates as a color sensor

_LIGHTSENSOR_RED 

activates as a light sensor with red lamp

_LIGHTSENSOR_GREEN 

activates as a light sensor with green lamp

_LIGHTSENSOR_BLUE 

activates as a light sensor with blue lamp

_LIGHTSENSOR_WHITE 

activates as a light sensor with white lamp

_LIGHTSENSOR_NONE 

activates as a light sensor with no lamp

_DEACTIVATE 

deactivates the sensor


Constructor & Destructor Documentation

Constructor.

Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object.
When the object is destructed while the system is shut down, the device is de-activated automatically.

Parameters:
portColor sensor connected port
modeSensor mode
Returns:
-
virtual ecrobot::NxtColorSensor::~NxtColorSensor ( void  ) [virtual]

Destructor.

Parameters:
-
Returns:
-

Member Function Documentation

S16 ecrobot::NxtColorSensor::get ( void  ) const

Get raw sensor data in the light sensor modes.

Parameters:
-
Returns:
Raw sensor data (0 to 1023)

Get brightness in the light sensor modes.

Parameters:
-
Returns:
Brightness value (greater value means brighter)

Get color number in the color sensor mode.

Note that the color number might be unmatch with the real color due to each sensor characteristics, ambient light, angle/distance to color object and other factors.

Parameters:
-
Returns:
Color number of NXT Color Sensor
void ecrobot::NxtColorSensor::getRawColor ( S16  rgb[3]) const

Get raw sensor data in the color sensor mode.

Parameters:
rgbrgb[0]: red
rgb[1]: green
rgb[2]: blue
Returns:
-

Get NXT color sensor mode.

Parameters:
-
Returns:
Sensor mode

Background process to communicate with the sensor.

Note that this function should be executed repeatedly in a background Task.

Parameters:
-
Returns:
-

Set NXT color sensor mode.

Parameters:
modeSensor mode
Returns:
-

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator Friends Defines