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

HiTechnic Color sensor (http://www.hitechnic.com/) class. More...

#include <ColorSensor.h>

List of all members.

Public Member Functions

 ColorSensor (ePortS port)
 Constructor (activate I2C).
U8 getColorNumber (void) const
 Get color number per Hi-Technic color number chart.
void getRawColor (S16 rgb[3]) const
 Get raw color data.
void get (U8 data[14]) const
 Get raw I2C data.

Detailed Description

HiTechnic Color sensor (http://www.hitechnic.com/) class.

[ How to use with TOPPERS/ATK1(OSEK) ]
I2C (derived/compositted) class and Clock class internally use RTOS features. Thus, user needs to implement a C function and RTOS provided events.

+ Invoke SleeperMonitor function in user_1msec_isr_type2 hook.
  void user_1ms_isr_type2(void)
  {
    SleeperMonitor(); // needed for I2C devices and Clock class
  }

+ Define EventSleepI2C and EventSleep Events in user oil file.
  EVENT EventSleepI2C
  {
    MASK = AUTO;
  };

  EVENT EventSleep
  {
    MASK = AUTO;
  };

  TASK TaskMain
  {
    AUTOSTART = TRUE
    {
      APPMODE = appmode1;
    };
    PRIORITY = 1;
    ACTIVATION = 1;
    SCHEDULE = FULL;
    STACKSIZE = 512;
    EVENT = EventSleepI2C; <- Here it is
    EVENT = EventSleep; <- Here it is
  };

[ How to use with TOPPERS/JSP(ITRON) ]
In case of using this class with TOPPERS/JSP(ITRON), RTOS specific definitions for the class are not needed.


Constructor & Destructor Documentation

Constructor (activate I2C).

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
Returns:
-

Member Function Documentation

void ecrobot::ColorSensor::get ( U8  data[14]) const [inline]

Get raw I2C data.

Parameters:
dataData representation from the sensor, per Hi-Technic's documentation:
data[0]: color number
data[1]: red saturation
data[2]: green saturation
data[3]: blue saturation
data[4]: raw red upper 2 bits
data[5]: raw red lower 8 bits
data[6]: raw green upper 2 bits
data[7]: raw green lower 8 bits
data[8]: raw blue upper 2 bits
data[9]: raw blue lower 8 bits
data[10]: color index (2 bits per r/g/b)
data[11]: normalized red
data[12]: normalized green
data[13]: normalized blue
Returns:
-

Get color number per Hi-Technic color number chart.

Parameters:
-
Returns:
Color number (0:Black to 17:White)
void ecrobot::ColorSensor::getRawColor ( S16  rgb[3]) const

Get raw color data.

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

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