Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:08 08 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Supported color depth of a given LCD screen

Author Message
karlelch

Senior Member

Joined: 30/10/2014
Location: Germany
Posts: 244
Posted: 06:18am 05 Sep 2025
Copy link to clipboard 
Print this post

Hi,

maybe I overlooked it, but is it possible to retrieve the usable color depth of a connected LCD display? Or is it always the same (e.g., RGB332)?

I am using a round panel with a ST7789 chip with the newest beta firmware (I don't have the full OPTION list here right now but the LCD is connected as follows:

OPTION LCD SPI GP18,GP19,GP16
OPTION LCDPANEL ST7789_320BUFF, P, GP22,GP15,GP17,GP14


I want to create color maps to represent heatmaps (e.g. from blue to white to red) using the maximum number of color steps. The trial-and-error approach is a bit unsatisfying.

Thanks
Thomas
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5221
Posted: 06:35am 05 Sep 2025
Copy link to clipboard 
Print this post

Hi Thomas,

Please note that if you use framebuffers, you are tied to the framebuffer color depth.  In most cases that color depth is inferior to the actual LCD screen.
The color depth of the framebuffers is listed in the user manual.

Volhout
PicomiteVGA PETSCII ROBOTS
 
karlelch

Senior Member

Joined: 30/10/2014
Location: Germany
Posts: 244
Posted: 07:13am 05 Sep 2025
Copy link to clipboard 
Print this post

Hi Volhout

thanks for your reply. Good point, however, currently, I don't use framebuffers because I had errors with framebuffers (earlier firmware versions). As the display is updated fast enough, I did not revisit this.

The manual says:
  Quote  MMBasic will automatically translate all colours to the format required by the individual display controller. For example, in the case of the ILI9341 LCD controller, is 64K colours in the 565 format.


I guess I was expecting a "convenience" function that reports the target format of the connected display (e.g., MM.INFO$(RGB) returning "565").

Best
Thomas

P.S. The way I currently approach the color map question is to use Claude to write me Python code that uses the MatPlotLib color map of my choice, convert it to, e.g., RGB332, show the color map, and create MMBasic code (just the DATA statements) for the map. I then displayed it on the LCD and inspected if if looked "nice"  
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10388
Posted: 07:55am 05 Sep 2025
Copy link to clipboard 
Print this post

In general LCD screens are native RGB565. ILI9488 and ILI9481IPS are RGB666. SSD1963s in 8-bit mode is RGB888. The buffered drivers are a special case. The buffer is RGB332 but they support the MAP command and function allowing you to set any of the RGB565 space to the 256 RGB332 slots (Same as various HDMI resolutions). This functionality is untested in the field. Use the manual section explaining this for HDMI for the syntax.
As Volhout notes, Framebuffers are RGB121. However, using the map command and function with the buffered drivers you could choose any 16 RGB565 colours to be displayed when you copy the framebuffer to the physical screen.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2689
Posted: 08:13am 05 Sep 2025
Copy link to clipboard 
Print this post

'A Display colour counter
Clear : Option Base 0
Dim String S$(2) = (" Blues", " Greens", " Reds")
Dim Integer a, b, c, d
For a = 0 to 2 'cycle through blue , green and red
b = 0        'initialize colour count
For c = 0 to 255 'set the brightness
 d = c << (a * 8) 'make a 24bit colour
 Pixel 9, 9, d    'send it to a pixel
 If d = Pixel(9, 9) Then  'read that pixel back from the screen
  Inc b  'if the colour is the same as the one sent count it
 EndIf
next
Print b; S$(a) 'show  counted colours
next
End


Footnote added 2025-09-06 07:47 by phil99
The Print statement can be changed to show the number of bits.
Print b; S$(a), "= "; Int(Log(b)*1.442695); " bits" 'show  counted colours


Footnote added 2025-09-06 07:52 by phil99
Typo above, use Cint instead of Int.
Print b; S$(a), "= "; CInt(Log(b)*1.4427); " bits" 'show  counted colours
 
karlelch

Senior Member

Joined: 30/10/2014
Location: Germany
Posts: 244
Posted: 08:39am 05 Sep 2025
Copy link to clipboard 
Print this post

  matherp said  In general LCD screens are native RGB565. ILI9488 and ILI9481IPS are RGB666. SSD1963s in 8-bit mode is RGB888. The buffered drivers are a special case. The buffer is RGB332 but they support the MAP command and function allowing you to set any of the RGB565 space to the 256 RGB332 slots (Same as various HDMI resolutions). This functionality is untested in the field. Use the manual section explaining this for HDMI for the syntax.
As Volhout notes, Framebuffers are RGB121. However, using the map command and function with the buffered drivers you could choose any 16 RGB565 colours to be displayed when you copy the framebuffer to the physical screen.

Thanks, Peter!
I will try as soon as I get back to my gear. One question: for the buffered driver, when I use MAP RESET and them redefine the colors, say, from 100 on and them use MAP SET, are the first 16 entries kept or do I always have to define the complete mapping?

Thanks!
 
karlelch

Senior Member

Joined: 30/10/2014
Location: Germany
Posts: 244
Posted: 08:41am 05 Sep 2025
Copy link to clipboard 
Print this post

  phil99 said  
'A Display colour counter
Clear : Option Base 0
Dim String S$(2) = (" Blues", " Greens", " Reds")
Dim Integer a, b, c, d
For a = 0 to 2 'cycle through blue , green and red
b = 0        'initialize colour count
For c = 0 to 255 'set the brightness
 d = c << (a * 8) 'make a 24bit colour
 Pixel 9, 9, d    'send it to a pixel
 If d = Pixel(9, 9) Then  'read that pixel back from the screen
  Inc b  'if the colour is the same as the one sent count it
 EndIf
next
Print b; S$(a) 'show  counted colours
next
End

Thanks, Phil. Elegant solution!
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2627
Posted: 03:14pm 05 Sep 2025
Copy link to clipboard 
Print this post

The manual says MAP command is HDMI VERSION ONLY and VGA VERSION ONLY?
Or am I mistaken?
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 661
Posted: 03:30pm 05 Sep 2025
Copy link to clipboard 
Print this post

Try reading what Peter said!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025