gLCD Component and its color parameters

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
jmccorison
Posts: 26
Joined: Mon Aug 18, 2008 11:47 pm
Location: Orcas Island, WA
Contact:

gLCD Component and its color parameters

Post by jmccorison »

While working with the new gLCD component I decided I wanted to highlight with reverse video. No problem, I'll just flip the foreground and background colors from what the default colors are in the component properties. Hmmm, not so easy. The component properties use a 1 byte hex code, but the color set macros use three bytes, one each for red, green and blue (RGB). So I poked around in the component code to figure things out. To save others from having to do so, here's how those two fields relate.

First, sanity checking. The SetForeColor and SetBackColor macros force the color parameters into their valid range:
if red > 7 then red = 7
if green > 7 then green = 7
if blue > 3 then blue = 3

Then the RGB parameters are shifted and or'ed to create the one byte hex code you see in the default colors settings. The mapping of RGB fields to the hex byte is as follows:

bits 7-5 = red
bits 4-2 = green
bits 1-0 = blue

or, RRRGGGBB. So, Bright Green, which has a hex code of 0x3D, which is binary 00111101, and therefore red = 1, green = 3, and blue = 1.

Hopefully this is clear enough. I'm a programmer, not a tech writer.

-Jim

User avatar
Steve
Matrix Staff
Posts: 3421
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: gLCD Component and its color parameters

Post by Steve »

Thanks Jim.

Post Reply