• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Colors inverted on CYB/ESP32 display

Q&A Forum › Category: ESP32 › Colors inverted on CYB/ESP32 display
0 Vote Up Vote Down
Christian Lease asked 11 months ago

I am just staring the LVGL/ESP32 course and I am very much a beginner with more complex code. I hope I am using this forum correctly by posting this here.
I am using a CYD from AliExpress. Every sketch I upload (including those from outside the course) to the board ends up with inverted colors. After some searching, I understand this is an issue with some boards with a USBC connector .
My solution which seems to work every time:
Insert in header: TFT_eSPI tft = TFT_eSPI();
Insert at end of void setup: ft.invertDisplay( true );
Is this a reasonable way to deal with this? Are there other options?
I appreciate any insight on this point!
Thank you.

9 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 11 months ago

Hi.
 
What do you mean by “inverted colors”?
 
Yes, that seems a good way to deal with that. Does that completely fix your issue?
I never encountered that issue before…
 
Regards,
Sara

0 Vote Up Vote Down
Christian Lease answered 10 months ago

Hi Sara. Thanks for the reply!
It’s as if the invert color toggle is on when the unit boots. White is black, red is light blue, green is purple, blue is yellow, etc.
It does fix the issue. And i’s good to know the fix is a reasonable approach. I’ll just keep on adding those lines of code until this board dies and I get another one :).
Best, Christian

0 Vote Up Vote Down
Sara Santos Staff answered 10 months ago

Great.
Thanks for letting me know. I think I’ll create a list of this kind of issues and how to fix them.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara
Regards,
Sara

0 Vote Up Vote Down
Ivan Tarozzi answered 10 months ago

I can confirm the same issue in my CYD; also #define LV_THEME_DEFAULT_DARK 0 in lv_conf.h was working revesed.
Thanks to Christian for the brilliant solution.

I will try to see if there are some options in User_Setup.h to solve the issue too, without call invertDisplay() in the setup

1 Vote Up Vote Down
Ivan Tarozzi answered 10 months ago

Ok, confirmed another workaround:

uncomment

#define TFT_INVERSION_ON

in User_Setup.h

So you can build examples from the book without other modifications

0 Vote Up Vote Down
Christian Lease answered 10 months ago

That’s great Ivan. I’ll try it out this evening …

0 Vote Up Vote Down
Sara Santos Staff answered 10 months ago

Hi ivan.
Thanks for sharing that solution.
I’ll add some information about that in the next eBook update.
Thank you so much for sharing.
Regards,
Sara

0 Vote Up Vote Down
Christian Lease answered 10 months ago

Yepp – that worked. Nice solution!!

0 Vote Up Vote Down
Robert Fleming answered 10 months ago

Arduino Files->Examples->TFT_eSPI->Test and diagnostics->ColourTest may be useful to you in figuring out how to set the following in User_Setup.h:

// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red


and

// If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion.
//#define TFT_INVERSION_ON
//#define TFT_INVERSION_OFF


My display seems to have red and blue swapped, and the colors are inverted.

If you think your colors are inverted, look in the loop() of the ColourTest sketch and change

tft.invertDisplay( true ); to tft.invertDisplay( false );


and

tft.invertDisplay( false ); to tft.invertDisplay( true );


and see what results you get.

Note that these lines of code appear to override the setting in User_Setup.h, unless I’ve managed to totally confuse myself.

With #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red uncommented and colors inverted, I get:
https://drive.google.com/file/d/1kpCgUdO2Uhuuy_ABOS0OFTafLb-qLBMr/view?usp=drive_link
for the non-inverted display, and
https://drive.google.com/file/d/1kkb-DvX74wXn-pD3buyesTjMtawAaomI/view?usp=drive_link
for the inverted display. Note that the moire pattern in the second picture is the result of the phone camera pixels sampling the display pixels, and is not visible when viewing the display directly.

For use with LVGL, I uncommented both
#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red

and

#define TFT_INVERSION_ON

and now my display seems to display colors correctly in my touchscreen calibration sketch.

 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.