by gloomyandy » Thu Apr 01, 2010 9:16 pm
The code for the color sensor was all done in a bit of a rush to get it out for the 0.85 release. So there is not as much documentation as we would like. Much of the API has been revised and will be different in the next leJOS release. The TYPE_* constants are basically the operating mode of the sensor. The color sensor is really 4 sensors in one...
TYPE_COLORNONE: No light is generated by the sensor, so the sensor returns a passive value of ambient light.
TYPE_COLORRED, TYPE_COLORGREEN, TYPE_COLORBLUE, the sensor will emit light of the specified color and so will typically return a light reading that measures the reflected light.
TYPE_COLORFULL The sensor operates in full color sensing mode. It samples all three colors (plus ambient), very rapidly, and then uses internal calibration values to identify the color of the an illuminated object.
The above constants can be passed into the constructor to set the operating mode of the sensor, or passed to the setType method to change the operating mode dynamically.
Remember that you always have the source of the leJOS classes so if there is something you do not understand, try taking a look at the source code...
Andy