I'm trying to use a 1.8" TFT display that uses the ST7735 and it appears to be working but I cannot figure out how to 'calculate' what numbers to put in to create the other 262k color shades that are available.
In the ST7735 data sheet starting on page 38 are Data Color Coding tables and starting on page 73 are Color Depth Conversion Look Up Tables. Apparently, you are supposed to use these to derive the different color shades.
How do you decipher these tables?
In the GCB Help file it says:
ST7735_BLACK 'hexidecimal value 0x0000
ST7735_BLUE 'hexidecimal value 0xF800
ST7735_RED 'hexidecimal value 0x001F
ST7735_GREEN 'hexidecimal value 0x07E0
ST7735_CYAN 'hexidecimal value 0xFFE0
ST7735_MAGENTA 'hexidecimal value 0xF81F
ST7735_YELLOW 'hexidecimal value 0x07FF
ST7735_WHITE 'hexidecimal value 0xFFFF
How did you come up with these numbers for each color?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well the values are bit inversion of the RGB-565 colors. Where a 16-bit value is essentially bit flipped, so, RGB 565 RED is 0xF800 > 0b1111 1000 > flipped = 0b0001 1111 > 0x01F
Why? Deep inside the datasheet at 10.1.26 MADCTL (36h): Memory Data Access Control the value we send is 0xC8 this set the direction of screen data write and the COLOR handling at bit D3. As we set the write direction and color handling as BGR565.
There are many articles on BGR565 color formats.
This makes sense as an explanation but this does not make sense in the context of the 'norm'. This driver was a very early driver. I can tell this because the driver identification #2. So, my first attempt at a GLCD driver.
However, if you compare these color definitions to the latest norm (the later GLCD drivers) where I clearly use RGB565, the TFT colors can be found in GLCD.h. Where TFT_RED is 0xF800 and therefore RGB565.
I'm trying to use a 1.8" TFT display that uses the ST7735 and it appears to be working but I cannot figure out how to 'calculate' what numbers to put in to create the other 262k color shades that are available.
In the ST7735 data sheet starting on page 38 are Data Color Coding tables and starting on page 73 are Color Depth Conversion Look Up Tables. Apparently, you are supposed to use these to derive the different color shades.
How do you decipher these tables?
In the GCB Help file it says:
ST7735_BLACK 'hexidecimal value 0x0000
ST7735_BLUE 'hexidecimal value 0xF800
ST7735_RED 'hexidecimal value 0x001F
ST7735_GREEN 'hexidecimal value 0x07E0
ST7735_CYAN 'hexidecimal value 0xFFE0
ST7735_MAGENTA 'hexidecimal value 0xF81F
ST7735_YELLOW 'hexidecimal value 0x07FF
ST7735_WHITE 'hexidecimal value 0xFFFF
How did you come up with these numbers for each color?
What a great question.
Well the values are bit inversion of the RGB-565 colors. Where a 16-bit value is essentially bit flipped, so, RGB 565 RED is 0xF800 > 0b1111 1000 > flipped = 0b0001 1111 > 0x01F
Why? Deep inside the datasheet at 10.1.26 MADCTL (36h): Memory Data Access Control the value we send is 0xC8 this set the direction of screen data write and the COLOR handling at bit D3. As we set the write direction and color handling as BGR565.
There are many articles on BGR565 color formats.
This makes sense as an explanation but this does not make sense in the context of the 'norm'. This driver was a very early driver. I can tell this because the driver identification #2. So, my first attempt at a GLCD driver.
However, if you compare these color definitions to the latest norm (the later GLCD drivers) where I clearly use RGB565, the TFT colors can be found in GLCD.h. Where TFT_RED is 0xF800 and therefore RGB565.
So, try this. https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/glcd_ST7735.h?format=raw
I have revised to RGB use TFT colors. I also updated GLCDCLS to be a lot faster and updated GLCDRotate to support bits not constants.
This now exposes the following plus you can now pass any RGB565 color code.
' Define Colors
Summary
I have updated the library to support TFT RGB-565 colors.
Last edit: Anobium 2018-12-16
My test program is attached.
And, now you can use http://www.barth-dev.de/online/rgb565-color-picker/
That was a great explanation.
Thanks!
Pleasure.
So, update your install with the revised .h file and all should be good.
Trying to load the demonstration I get this error message
Yes, that happens.
Can you use the Textual based IDE. This will work for you.
yes it worked but it would be more comfort to me if its possible to make it directly from GCG
Yes. I understand.
Let me look into the root cause of the issue.
Meanwhile, use the IDE.
:=)
ok I tested it on my adafruit with a 16f887 pic and it worked. But why is its drawing so slow? is that normal?
887.... what frequency?
8MHz, the internal osc
A little slow for a color GLCD. Try an 18f at 64mhz