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.
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
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
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
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
Ok, confirmed another workaround:
uncomment
#define TFT_INVERSION_ON
in User_Setup.h
So you can build examples from the book without other modifications
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
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.