I am trying to set the fore and background colours of the EB076 gLCD using the standard macros. It seems that only solid colours can be set. For instance I can set the background colour to black by the setting the values of Red, Green and Blue components to 0x00 respectively.
My understanding is that, for instance, to get a mid-shade of grey values of 128 for each of the Red, Green and Blue components are required. However this gives very odd colours in both simulation and from the unit itself.
Have I understood the way this works correctly?
I have tried all different combinations and the results are not what I expect. I use the following tool to get the numbers for the Red, Green and Blue component:
http://www.calculatorcat.com/free_calcu ... ider.phtml
Having looked through the forum database I noticed that there were similar issues with version 4 of FC. As I have V5.4, I assume those changes referred to would have been incorporated into V5.4.
Any guidance please?
many thanks
Sefi
gLCD and changing fore and background colours * RESOLVED *
Moderator: Benj
-
- Posts: 56
- Joined: Mon Sep 29, 2008 10:26 am
- Has thanked: 9 times
- Been thanked: 14 times
- Contact:
Re: gLCD and changing fore andf background colours
Having used various combinations, I have found out that the following range works:
Red: 0 to 7
Green: 0 to 7
Blue: 0 to 3
This was an issue that was apparently resolved in version 4.5 of FC. Surely the changes were incorporated into V5.
I guess Benj would know the answer but for time being I am using the above range to get somewhere near the shades of colours I am trying to use.
Sefi
Red: 0 to 7
Green: 0 to 7
Blue: 0 to 3
This was an issue that was apparently resolved in version 4.5 of FC. Surely the changes were incorporated into V5.
I guess Benj would know the answer but for time being I am using the above range to get somewhere near the shades of colours I am trying to use.
Sefi
- JonnyW
- Posts: 1230
- Joined: Fri Oct 29, 2010 9:13 am
- Location: Matrix Multimedia Ltd
- Has thanked: 63 times
- Been thanked: 290 times
- Contact:
Re: gLCD and changing fore andf background colours
Hello. I believe the colours are dependant on the number of colours on the LCD. I agree this is not ideal - really the colours should be scaled down by the component from a max of (255, 255, 255). However if this is not the case with your component (with an 8-bit resolution) ensure all colours passed to the component are passed as: (red) >> 5, (green) >> 5, (blue) >> 6. There is no speed loss with you doing this as the component would have to do this anyway.
It may also be there is some legacy settings which enable/disable this as we need to support both the mechanisms, but Ben or Steve would know this better than me.
Cheers,
Jonny
It may also be there is some legacy settings which enable/disable this as we need to support both the mechanisms, but Ben or Steve would know this better than me.
Cheers,
Jonny
-
- Posts: 56
- Joined: Mon Sep 29, 2008 10:26 am
- Has thanked: 9 times
- Been thanked: 14 times
- Contact:
Re: gLCD and changing fore andf background colours
Thanks Jonny for your reply.
The component I am using is the EB076. It is all Matrix hardware (at the moment).
Keeping the colours within the range that I alluded to earlier produces results in simulation but once downloaded to the MCU produces a blank screen. I will try what you suggest and report back.
many thanks
Sefi
The component I am using is the EB076. It is all Matrix hardware (at the moment).
Keeping the colours within the range that I alluded to earlier produces results in simulation but once downloaded to the MCU produces a blank screen. I will try what you suggest and report back.
many thanks
Sefi
-
- Posts: 56
- Joined: Mon Sep 29, 2008 10:26 am
- Has thanked: 9 times
- Been thanked: 14 times
- Contact:
Re: gLCD and changing fore andf background colours
Hi Jonny,
I think the scheme used within FC is a 565 scheme to make up the 16 bits of the colour definition. The individual components of Red, Green and Blue are being correctly shifted in the Macros SetForeColor and SetBackColor in accordance with the 565 scheme.
So I am now at a total loss as to what to do. Setting the values of the RGB components to be in the 0-7, 0-7 and 0-3 respectively works to give a usable palette but I cant understand how this can be, looking at the code in the macros.
Sefi
I think the scheme used within FC is a 565 scheme to make up the 16 bits of the colour definition. The individual components of Red, Green and Blue are being correctly shifted in the Macros SetForeColor and SetBackColor in accordance with the 565 scheme.
So I am now at a total loss as to what to do. Setting the values of the RGB components to be in the 0-7, 0-7 and 0-3 respectively works to give a usable palette but I cant understand how this can be, looking at the code in the macros.
Sefi
Last edited by Sefi on Tue Aug 28, 2012 9:34 am, edited 1 time in total.
- JonnyW
- Posts: 1230
- Joined: Fri Oct 29, 2010 9:13 am
- Location: Matrix Multimedia Ltd
- Has thanked: 63 times
- Been thanked: 290 times
- Contact:
Re: gLCD and changing fore andf background colours
Hi. I am not sure which gLCD file it is that is used but by the looks of it red and green are shifted down by 5 bits and blue by 6 for LCD 1:
This means that the colour is 8-bit (for that gLCD) but is also odd as the colour you should send to this should be in the range 0-255 for each R, G, B, which is how it should be.
Could you post a sample program and we could have a look - if this code has been brought from v4 and customized it is possible it has the old v4 code in.
Cheers,
Jonny
Code: Select all
Red = Red >> 5;
Green = Green >> 5;
Blue = Blue >> 6;
Could you post a sample program and we could have a look - if this code has been brought from v4 and customized it is possible it has the old v4 code in.
Cheers,
Jonny
-
- Posts: 56
- Joined: Mon Sep 29, 2008 10:26 am
- Has thanked: 9 times
- Been thanked: 14 times
- Contact:
Re: gLCD and changing fore andf background colours
Hi Jonny,
I have had a look at the code and both the Fore and Back colours are stored in a short variable as follows:
R4R3R2R1R0G5G4G3----G2G1G0B4B3B2B1B0
==Colour msb==== ---==colour lsb=======
The shifting and set up of the msb and lsb all seem correct. These 2 bytes are sent to the gLCD via the UART. However the results are very odd. One thing I tried was to comment out the bit shifting instructions in the macros and used values of R=2, G=2 and B=1 to get a grey shade, which effectively equate to R=8, G=16 and B=4. This gives roughly the right shade of grey. However to get this colour the "levels" for the RGB components should be around 128.
I can not work out why this is happening.
Cheers
Sefi
I have had a look at the code and both the Fore and Back colours are stored in a short variable as follows:
R4R3R2R1R0G5G4G3----G2G1G0B4B3B2B1B0
==Colour msb==== ---==colour lsb=======
The shifting and set up of the msb and lsb all seem correct. These 2 bytes are sent to the gLCD via the UART. However the results are very odd. One thing I tried was to comment out the bit shifting instructions in the macros and used values of R=2, G=2 and B=1 to get a grey shade, which effectively equate to R=8, G=16 and B=4. This gives roughly the right shade of grey. However to get this colour the "levels" for the RGB components should be around 128.
I can not work out why this is happening.
Cheers
Sefi
-
- Posts: 56
- Joined: Mon Sep 29, 2008 10:26 am
- Has thanked: 9 times
- Been thanked: 14 times
- Contact:
Re: gLCD and changing fore andf background colours
Dear all,
I have now fixed this problem and it appears that it affects other gLCDs too.
In the macro SetBackColor(char red, char green, char blue), you will need to add the following line of code:
This will tell the LCD that the next 2 bytes being sent are the msb and lsb of the background colour.
The files affected are: FC5_PIC_gLCD_4.c , FC5_PIC_gLCD_5.c , FC5_PIC_gLCD_6.c
cheers
Sefi
I have now fixed this problem and it appears that it affects other gLCDs too.
In the macro SetBackColor(char red, char green, char blue), you will need to add the following line of code:
Code: Select all
%a_UART_Send('K'); // Send command for setting background colour
The files affected are: FC5_PIC_gLCD_4.c , FC5_PIC_gLCD_5.c , FC5_PIC_gLCD_6.c
cheers
Sefi