2021-09-13 10:58 PM
Hello,
This is my first attempt on using the TouchGFX library, so I'm still learning how everything works. I've a custom board running on a STM32G473CBU6 with a 1.54" ST7789V LCD interfaced through SPI.
I know the LCD driver is working because I can run a test without using TouchGFX library and I get expected results, just basic functions like drawing rect, circ, filling with colours etc they all work.
I've implemented a simple screen on ToughGFX Designer that is just a simple Text element with a colour background, this excerpt is from screenViewBase.cpp
screenViewBase::screenViewBase()
{
__background.setPosition(0, 0, 240, 240);
__background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 255));
textAreaVoltage.setXY(46, 59);
textAreaVoltage.setColor(touchgfx::Color::getColorFromRGB(0, 255, 0));
textAreaVoltage.setLinespacing(0);
textAreaVoltage.setTypedText(touchgfx::TypedText(T_RESOURCEIDVOLTAGE));
add(__background);
add(textAreaVoltage);
}
The simulator shows the right colour but the board shows colours like shown below where background should be BLUE shows GREEN and where the text should be GREEN is shown as RED.
I tried setting up the LCD Driver with RGB or BGR but I still get wrong colours. I've also tried setting the SPI clock phase in different modes but nothing.
I noticed that getColorFromRGB function seems to generate a 24bit colour but I guess the GUI engine knows that my screen is only 16bpp and it's doing the conversion before the framebuffer is sent.
Can anyone point me into the right direction on what to check next? Or things that I can try?
Solved! Go to Solution.
2021-10-19 03:52 PM
To close out this issue, I found the solution when reading the implementation of TouchGFX on STM32G071. When using SPI communication with the LCD driver in this case ST7789 (same thing applies for ILI9341) commads are sent in SPI 8bit mode but when sending data for the RGB colour switching to 16bit SPI fixes the issue as explained here under the Display section.
2021-09-15 01:10 AM
Any LCD with controllers have initial commands to setup orientation and colour space. You need change this registers in display setup ...
2021-09-15 03:02 AM
Hi MM, thanks for the suggestion. But like I mentioned I already tried that, the ST7789 has a register called MADCTL that I configure during the initial setup sequence which control de orientation, color RGB or BGR. I’ve tried changing that but it didn’t help.
note that I can draw the correct colours on the LCD if I bypass the touchGFX library and write directly into the LCD using low level function I’ve implemented so I understand the configuration is sound, but I’m not sure if there is anything else on the touchGFX configuration I’m missing.
2021-09-15 12:30 PM
2021-09-15 10:08 PM
2021-10-19 03:52 PM
To close out this issue, I found the solution when reading the implementation of TouchGFX on STM32G071. When using SPI communication with the LCD driver in this case ST7789 (same thing applies for ILI9341) commads are sent in SPI 8bit mode but when sending data for the RGB colour switching to 16bit SPI fixes the issue as explained here under the Display section.