Page 1 of 1

Lego Color Sensor values

Posted: 29 Oct 2012, 16:58
by HaWe
hello,
the meaning of color values I do actually understand (RGB, e.g. raw)
#define INPUT_RED 0
#define INPUT_GREEN 1
#define INPUT_BLUE 2
But what is a "blank value" for...?
#define INPUT_BLANK 3
Access the blank value from color sensor value arrays
and what means "number of entries"?
#define INPUT_NO_OF_COLORS 4
The number of entries in the color sensor value arrays

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 18:30
by mattallen37
In full color mode, the FW stores the phototransistor values for when the LED is red, green, blue, and off. In full color mode, there are four LED states.

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 18:58
by HaWe
thx,
so "INPUT_BLANK 3" is sort of reflected background/ambient light?

but what's about "INPUT_NO_OF_COLORS 4"

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 19:02
by mattallen37
AFAIK, yes.

Well, with red, green, blue, and blank, there are four "colors", hence "INPUT_NO_OF_COLORS 4"

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 19:35
by HaWe
well, actually no.
I mean:

Code: Select all

Color sensor array indices
Input module constants
Constants for use with color sensor value arrays to index RGB and blank return values. More...

Macros 
#define  INPUT_RED   0 
#define  INPUT_GREEN   1 
#define  INPUT_BLUE   2 
#define  INPUT_BLANK   3 
#define  INPUT_NO_OF_COLORS   4 
so:

Code: Select all

unsigned int ColorSensorRaw  ( byte  port, byte  color);

rawRed     = ColorSensorRaw(S1, INPUT_RED);
rawGreen   = ColorSensorRaw(S1, INPUT_GREEN);
rawBlue    = ColorSensorRaw(S1, INPUT_BLUE);
rawReflect = ColorSensorRaw(S1, INPUT_BLANK);
but what is THIS for?

Code: Select all

rawNumber=  ColorSensorRaw(S1, INPUT_NO_OF_COLORS); //??????????

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 20:33
by mattallen37
doc-helmut wrote:...
but what is THIS for?

Code: Select all

rawNumber=  ColorSensorRaw(S1, INPUT_NO_OF_COLORS); //??????????
Where did you find that line of code? ColorSensorRaw doesn't compile if you pass the constant INPUT_NO_OF_COLORS into the second parameter.

Code: Select all

# Error: compchk failed.  4 is not less than 4.
I still stand by my last reply.

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 20:34
by mattallen37
See here.

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 21:34
by HaWe
my guess was simply, if
#define INPUT_NO_OF_COLORS 4
stands in a line with all the other constants for color macro names then it should be able to use it like the other macro constants and - above all - it should have any meaning or effect or result if it was passed to a function.

Code: Select all

#define  INPUT_RED   0
#define  INPUT_GREEN   1
#define  INPUT_BLUE   2
#define  INPUT_BLANK   3
#define  INPUT_NO_OF_COLORS   4 
why would one need a name for a constant equal to 4 which's name is as long as the hole Genesis if it has no other meaning than just "4" ?
Just to remember what "4" was like?

Re: Lego Color Sensor values

Posted: 29 Oct 2012, 21:39
by mattallen37
For the same reason people use "LCD_LINE1", "OUT_A", "S3", "INPUT_RED", or any other macros. You certainly are not required to use them, if you instead prefer to enter the numeric equivalence.

Re: Lego Color Sensor values

Posted: 30 Oct 2012, 13:57
by HaWe
ok, thx, nevertheless
#define INPUT_RED 0
#define INPUT_GREEN 1
#define INPUT_BLUE 2
#define INPUT_BLANK 3

thoroughly make sense to prevent from confusing or reversing the inputs of the color sensor value array.