2022-01-05 04:11 AM
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.
Solved! Go to Solution.
2022-01-26 08:49 PM
#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) );
8)
2022-01-11 05:44 AM
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
2022-01-26 08:02 AM
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:
TouchGFX 4.18.1:
2022-01-26 08:44 AM
Have you tried regenerating code from STM32CubeMX as well ?
/Romain
2022-01-26 08:49 PM
#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) );
8)
2022-01-26 09:51 PM
No I haven't. My project is multitarget and regenerating makes troubles.
2022-01-26 09:52 PM
This is working. Thanks a lot!
2022-01-27 04:24 AM
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 << 8) | (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.