This article shows how to change the pixel format of an application after a project has been created. Concretely, this article exemplifies modifying a 24-bit RGB888 application to be 16-bit RGB565 through the TouchGFX Generator and also shows the impact on the TouchGFX project configuration. Reasons to change the pixel format could be the following:
- Modified display requirements
- Modified application requirements
- Mistake during initial project creation
Generally, the following changes could be required to change the pixel format of your application.
- Board Bring Up: Change the pixel format of the LTDC.
- HAL Development: Modify TouchGFX Generator settings to reflect LTDC settings or location of framebuffer(s) in memory.
- TouchGFX Designer: Ensure that the designer is using this new converted bit depth and correct format for image assets.
Starting from the designer we can inspect the current configuration for Display and Image and return to these screens later to validate.
If certain settings in the CubeMX project can impact the desired pixel format of the application, as is the case for LTDC, developers are required to make appropriate changes here such that TouchGFX renders in the format expected by the LTDC.
If the bit-depth of the applications changes along with the pixel format of the framebuffer (e.g. changing ARGB2222 to BRGA2222 you would still have an 8-bit application), developers may be required to modify the memory locations of the framebuffers. In the case below:
Generating code using this configuration will generate a
TouchGFXConfiguration that uses the 16-bit TouchGFX
If the project is open in TouchGFX Designer, developers will be prompted to update to reflect the newly generated configuration changes.
The table below lists the impact on opaque and non-opaque image formats given a pixel format:
|Framebuffer pixel format||Opaque format||Non-Opaque format|
Once the TouchGFX project has been updated based on the new TouchGFX Generator settings defined in CubeMX, developers will find that the TouchGFX Designer configuration has changed to match.
After generating code from within TouchGFX Designer the code for image assets now reflect the updated pixel format:
Modifying the current pixel format of an application can be done by simply using TouchGFX Generator. For MCUs with an LTDC, the layer running TouchGFX must match the Framebuffer pixel format defined in TouchGFX Generator (Limited to RGB565 and RGB888 for LTDC) settings to ensure compliance with the format rendered by TouchGFX Core.
Once code has been generated from CubeMX, the TouchGFX project will be updated and upon subsequent code generation in TouchGFX Designer both image assets and framebuffer driver will have the specified formats.