cancel
Showing results for 
Search instead for 
Did you mean: 

Color corruption of text in TouchGFX 4.18.1

LMath.2
Associate II

I created my project in TouchGfx 4.15.0. Currently I'm using TouchGfx 4.18.1. After flashing/debugging ; color of the text which I've given in TouchGfx is getting corrupted. For ex : If I set red(235 ,64 ,61) color to some text, after debugging it becomes a color close to blue. But if the text color is white, it's not getting corrupted. Someone please provide a solution for this matter.

1 ACCEPTED SOLUTION

Accepted Solutions

#define ConvertTextColor(RED, GREEN, BLUE) (uint32_t)( ( (RED << 8 ) & 0xF800) + ( (GREEN << 3) & 0x07E0) + ( (BLUE >> 3) & 0x003F) )

Add this macro in Color.hpp

Then call this macro whereever you want. For ex :

Text.setColor(TextColourConvert(Red, Green, Blue) );

😎

View solution in original post

7 REPLIES 7
Romain DIELEMAN
ST Employee

Hi,

What MCU are you working with ? Are you working with a custom project or from one of the TBS avaialble in TouchGFX Designer ?

I would suggest to regenerate code from STM32CubeMX to make sure to update the Firmware package (opening your project in STM32CubeMX and migrate to the latest version).

/Romain

DHoff.3
Associate II

Hello,

I have same issue. I'm using custom board with STM32F767 mcu, display color depth 16 bit, L8 image formats and IDE Keil uVision5. Colors in the pictures are ok. Problem is with colors got by function getColorFromRGB(r, g, b). For example color (32, 60, 82) was changed to (57, 137, 131) (these values were taken from attached "frame buffer screenshots").

TouchGFX 4.16:

0693W00000JNQ2PQAX.pngTouchGFX 4.18.1:

0693W00000JNQ2oQAH.png 

Have you tried regenerating code from STM32CubeMX as well ?

/Romain

#define ConvertTextColor(RED, GREEN, BLUE) (uint32_t)( ( (RED << 8 ) & 0xF800) + ( (GREEN << 3) & 0x07E0) + ( (BLUE >> 3) & 0x003F) )

Add this macro in Color.hpp

Then call this macro whereever you want. For ex :

Text.setColor(TextColourConvert(Red, Green, Blue) );

😎

No I haven't. My project is multitarget and regenerating makes troubles.

This is working. Thanks a lot!

I finally tried to regenerate files by Cube MX but still have the same problem. At first I thought the problem could be that my project was generated two years ago in older Cube MX version. But my colleague who works on new similar project has the same issue.

After some digging in the code I found something which is corresponding with @LMath.2​  answer. In older version of Color.hpp file was function getColorFrom24BitRGB dependent on selected lcd color depth:

static colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue)

 {

    assert(HAL::getInstance() && "Cannot set color before HAL is initialized");

    return HAL::lcd().getColorFrom24BitRGB(red, green, blue);

 }

After upgrade to version 4.18.1 function getColorFromRGB(r,g,b) is used and its implementation is following:

FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)

  {

    return 0xFF000000 | (red << 16) | (green << 😎 | (blue);

  }

It is obvious that this implementation is independent on selected color depth. Maybe value should be recalculated somewhere deeper in the library core. Am I right? Because in my case it is not working and I'm not sure if modifying of getColorFromRGB function Color.hpp will not lead to other problems.