|
ECRobot C++ API for LEGO MINDSTORMS NXT
1.0.10
|
NXT2.0 Color sensor class. More...
#include <NxtColorSensor.h>
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. | |
NXT2.0 Color sensor class.
Enum for color number of NXT Color Sensor.
Enum for NXT Color Sensor modes.
| ecrobot::NxtColorSensor::NxtColorSensor | ( | ePortS | port, |
| eSensorMode | mode = _COLORSENSOR |
||
| ) | [explicit] |
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.
| port | Color sensor connected port |
| mode | Sensor mode |
| virtual ecrobot::NxtColorSensor::~NxtColorSensor | ( | void | ) | [virtual] |
Destructor.
| - |
| S16 ecrobot::NxtColorSensor::get | ( | void | ) | const |
Get raw sensor data in the light sensor modes.
| - |
| S16 ecrobot::NxtColorSensor::getBrightness | ( | void | ) | const |
Get brightness in the light sensor modes.
| - |
| eColorNumber ecrobot::NxtColorSensor::getColorNumber | ( | void | ) | const |
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.
| - |
| void ecrobot::NxtColorSensor::getRawColor | ( | S16 | rgb[3] | ) | const |
Get raw sensor data in the color sensor mode.
| rgb | rgb[0]: red rgb[1]: green rgb[2]: blue |
| eSensorMode ecrobot::NxtColorSensor::getSensorMode | ( | void | ) | const [inline] |
| void ecrobot::NxtColorSensor::processBackground | ( | void | ) |
Background process to communicate with the sensor.
Note that this function should be executed repeatedly in a background Task.
| - |
| void ecrobot::NxtColorSensor::setSensorMode | ( | eSensorMode | mode | ) |