cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Colour issue

margce
Associate III

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.

0693W00000Dn4SOQAZ.jpg 

Can anyone point me into the right direction on what to check next? Or things that I can try?

1 ACCEPTED SOLUTION

Accepted Solutions
margce
Associate III

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.

View solution in original post

5 REPLIES 5
MM..1
Chief III

Any LCD with controllers have initial commands to setup orientation and colour space. You need change this registers in display setup ...

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.

Simply try in SPI config set MSB or LSB first.
Change LSB MSB ofcourse is bad idea, check touchGFX HAL sender SPI func...
margce
Associate III

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.