cancel
Showing results for 
Search instead for 
Did you mean: 

GPU2D and RGB565: Can the GPU2D use dithering in gradients?

Jack3
Senior III

Hello, I'm using an STM32U5G7VJTx MCU with a 480x320 display, connected to the FMC in 16-bit mode, and everything works fine using the GPU2D. I'm not using an existing GUI framework.

The pixel format used by the display is RGB565 (16bpp), so for gradients, I want to use dithering to soften the banding. I found this definition in the 'nema_graphics.h' file:

#define NEMA_DITHER     0x80U  /**< Nema Dithering */

However, it seems undocumented. How do I make use of it?

Kind regerds, Jack.

1 ACCEPTED SOLUTION

Accepted Solutions
JBJOE.1
ST Employee

Hi @Jack3 

You’re right, there is a dither option in nema_graphics.h. I haven’t actively used it in a project yet, but from what I can see it’s a feature you enable on the destination (framebuffer), so it performs dithering at runtime when blitting. You need to specify both the color format and the dither option, like this:

img_obj_t fb;
fb.w = RESX;
fb.h = RESY;
fb.format = NEMA_RGBA8888 | NEMA_DITHER;
fb.stride = RESX*4;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

 Regards, 
Jakob

Jakob BJOERN
Senior Software Engineer | STM32 Graphics

View solution in original post

10 REPLIES 10
mƎALLEm
ST Employee

Hello,


@Jack3 wrote:

I'm not using an existing GUI framework.


If you are not using a specific GUI framework why posting in STM32 MCUs TouchGFX and GUI forum board?

Where you find that 'nema_graphics.h' file? a ST package? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
JBJOE.1
ST Employee

Hi @Jack3 

You’re right, there is a dither option in nema_graphics.h. I haven’t actively used it in a project yet, but from what I can see it’s a feature you enable on the destination (framebuffer), so it performs dithering at runtime when blitting. You need to specify both the color format and the dither option, like this:

img_obj_t fb;
fb.w = RESX;
fb.h = RESY;
fb.format = NEMA_RGBA8888 | NEMA_DITHER;
fb.stride = RESX*4;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

 Regards, 
Jakob

Jakob BJOERN
Senior Software Engineer | STM32 Graphics

Hi Jakob, thank you very much!
That works like a charm!
It is much desired on 16-bit famebuffers like below:

img_obj_t fb;
fbo.w = ILI9488_SIZE_X;
fbo.h = ILI9488_SIZE_Y;
fbo.stride = fbo.w * ILI9488_BYTES_PER_PIXEL;  /* ILI9488_BYTES_PER_PIXEL = 2 */
fbo.format = NEMA_BGR565 | NEMA_DITHER;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

You are a super-hero!
Regards,
Jack.

That is abundantly clear: it says "and GUI", and this concerns exactly a GUI, albeit my own.
BTW, GUI stands for "Graphical User Interface".
Thank you for your concern. I hope this helps.

I know what GUI means and this forum board is only focusing on TouchGFX solution. Therefore this post will be moved to the correct forum board.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

The GPU2D is all about GUIs, and because it says "and GUI", I thought this was exactly the right place. I would definitely look here first for anything related to the GPU2D, right?

That depends on the question.

If a it was about GPU2D configuration using the HAL that needs to be posted in "STM32 MCUs Embedded software" forum board.

If it was a question related to something related to the documentation: datasheet, reference manual, errata it should be posted in "STM32 MCUs Products" forum board.

Nema GUI is not a ST solution so that needs to be posted in  "Others: STM32 MCUs related"

This is how we are organized in this community.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
mƎALLEm
ST Employee

After checking with @Osman SOYKURT , it seems that Nema knowledge (Think Silicon was the owner of that solution) was transferred to ST (something that I was not aware of as moderator).

Therefore, any other Nema related questions need to be posted in TouchGFX forum board to be treated by TouchGFX team as they can handle it.

PS: meanwhile we (as admins) keep the same position: questions about solutions not provided by ST while using STM32 MCUs need to be posted in "Others: STM32 MCUs related" forum board such as LVGL, QT GUI etc..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Note that the GPU2D and NemaGFX libraries aren't covered by the reference manuals at all, as you figured.

So I had the assumption that the TouchGFX team has the most knowledge about GPU2D and the NemaGFX libraries, much more than "Others: STM32 MCUs related", or am I wrong about that?