help with LCD

hey guys, so I'm a bit new to all this. got myself the uno R3 and a sparkfun nokia 6100 LCD shield. Color LCD Shield - LCD-09363 - SparkFun Electronics
so I'm able to program it all and get a image displaying on the screen, but for some reason it wont display the colours properly. might be brightness of the backlight, I dont know. basicly if I put the example here SparkFun Color LCD Shield LCD-09363 on the board the sparkfun logo appears, but not properly, most of the screen is white and just half an outline of the logo in red. I created my own program to just continuously display a red rectangle on the screen and keep refreshing it but it shows up as white.

please help a noob in need :smiley:

hey guys, I worked it out. but still need your help. I need to invert the hex colour codes. can anyone point me in the right direction of a list of inverse 12bit colour codes? I've been looking around and can find plenty of sites with the whole range but not inverted.

Could you let the sketch do it for you? Something like the following:
int hexConstant = 0xfff
int hexColorCode = 0xwhatever color code
int invertedHex = (hexConstant-hexColorCode)

Subtracting your desired color from FFF will give you the inverse in a variable you could call elsewhere. I'm sure it is less than ideal, but it's the best my noob brain can think of

cool, I just changed the presets in the code so they're right now. but now I have another issue, not all colours are showing up. it doesnt matter what I program the colours as, they always show up as pink, white, black or red. I cant get any other colours.

getting closer, found a inversion command which was switched on. so I've turned it off now. :D.
now some colours are appearing correctly, but reds and blues appear to be swapped. for example, take the last table on this page Triple Hex #C00 to #FFF
F00 through to F0F. if I just have a whole lot of LCDClear(colour) commands one after the other so it scales through them all, it starts as BLUE instead of red and ends up at fuchsia. same if I went with one of the tables that had blue in it, it'd start at red.

any ideas? I think I'm going to be stuck with this one, and if I dont find an answer I'll be stuck with experimenting with hex codes till I find the colour I want.

I am not on the right machine to provide the whole answer to this but if you download the 4DShield Library, The old one, not the one at the beginning of this forum, there is a bit of code to translate RGB numbers to 16bit hex to send to the display.

One of the things that threw me in this routine was the shift. Since your reds and blues are reversed, it sounds like you need to shift to the left as you build your number. I don't remember exactly how it was done but it works. What I ended up doing to save code space was to use this routine to calculate my numbers that I needed for the various colors and print them to serial. Then I put these numbers in as constants.

16bit color uses a 565 format where there are 5 bits of red, 6 bits of green and 5 bits of blue. An interesting side note is that the human eye is able to differentiate shades of green better than the other two so it gets 6 bits.

In 12 bit you get 4 bits for each color. With only 4 bits of color available, you have to convert your 0 -255 to 0 - 15 since 15 is the highest possible 4 bit number.

These three numbers are all then combined together to make your 12bit number.

I found the C file. This is how the 16bit number is built:

int outR = ((red * 31) / 255);
int outG = ((green * 63) / 255);
int outB = ((blue * 31) / 255);

return (outR << 11) | (outG << 5) | outB;

So if you have to convert to 12bit, I am thinking that this should work:

// The red, green and blue numbers are passed and the color is returned.
//in your loop it would be:
unsigned int color = getcolor(255,51,51); // Whatever RGB values you want to pass.


unsigned int getcolor(unsigned int red, unsigned int green, unsigned int blue) 
{

int outR = ((red * 15) / 255);
int outG = ((green * 15) / 255);
int outB = ((blue * 15) / 255);

return (outR << 8) | (outG << 4) | outB;          //I think my shifts are right here
}

For the 4D displays, when you send color to the display, you have to do it one byte at a time and it is done like so:

Serial.write(color >> 8);				// MSB			
Serial.write(color & 0xFF);				// LSB

I have no idea how to translate this to the Nokia. I am very surprised this function isn't included in the library for those knockoffs.

All good, with some help I worked out some code to swap the red and blue bits.
color = ((color & 0x0f) << 8) | (color & 0xf0) | ((color >> 8) & 0x0f);