esp-idf/examples/peripherals/lcd/gc9a01
2022-07-14 08:26:32 +08:00
..
main lcd: don't turn on disp in init 2022-04-21 13:59:47 +00:00
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
README.md docs: changes docs supported targets tables 2022-07-14 08:26:32 +08:00
sdkconfig.defaults lcd: add i2c oled example with lvgl port 2022-01-21 11:21:38 +08:00

Supported Targets ESP32 ESP32-C2 ESP32-C3 ESP32-S2 ESP32-S3

GC9A01 porting example

esp_lcd provides several panel drivers out-of box, e.g. ST7789, SSD1306, NT35510. However, there're a lot of other panels on the market, it's beyond esp_lcd component's responsibility to include them all.

esp_lcd allows user to add their own panel drivers in the project scope (i.e. panel driver can live outside of esp-idf), so that the upper layer code like LVGL porting code can be reused without any modifications, as long as user-implemented panel driver follows the interface defined in the esp_lcd component.

This example shows how to add the GC9A01 driver in the project folder but still use the API provided by esp_lcd component. As GC9A01 is famous in the form of a circular screen, this example will draw a fancy dash board with the LVGL library. For more information about porting the LVGL library, you can also refer to another lvgl porting example.

How to use the example

Hardware Required

  • An ESP development board
  • An GC9A01 LCD panel, with SPI interface
  • An USB cable for power supply and programming

Hardware Connection

The connection between ESP Board and the LCD is as follows:

       ESP Board                           GC9A01 Panel
┌──────────────────────┐              ┌────────────────────┐
│             GND      ├─────────────►│ GND                │
│                      │              │                    │
│             3V3      ├─────────────►│ VCC                │
│                      │              │                    │
│             PCLK     ├─────────────►│ SCL                │
│                      │              │                    │
│             DATA0    ├─────────────►│ SDA                │
│                      │              │                    │
│             RST      ├─────────────►│ RES                │
│                      │              │                    │
│             DC       ├─────────────►│ DC                 │
│                      │              │                    │
│             CS       ├─────────────►│ CS                 │
│                      │              │                    │
│             BK_LIGHT ├─────────────►│ BLK                │
└──────────────────────┘              └────────────────────┘

The GPIO number used by this example can be changed in lvgl_example_main.c. Especially, please pay attention to the level used to turn on the LCD backlight, some LCD module needs a low level to turn it on, while others take a high level. You can change the backlight level macro EXAMPLE_LCD_BK_LIGHT_ON_LEVEL in lvgl_example_main.c.

Build and Flash

Run idf.py -p PORT build flash monitor to build, flash and monitor the project. A fancy animation will show up on the LCD as expected.

The first time you run idf.py for the example will cost extra time as the build system needs to address the component dependencies and downloads the missing components from registry into managed_components folder.

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

...
I (304) cpu_start: Starting scheduler.
I (308) example: Turn off LCD backlight
I (308) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (318) example: Initialize SPI bus
I (318) example: Install panel IO
I (328) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (338) example: Install GC9A01 panel driver
I (338) gpio: GPIO[3]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (468) example: Turn on LCD backlight
I (468) example: Initialize LVGL library
I (468) example: Register display driver to LVGL
I (468) example: Install LVGL tick timer
I (468) example: Display LVGL Meter Widget
...

Troubleshooting

  • Why the LCD doesn't light up?
    • Check the backlight's turn-on level, and update it in EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
  • Weird color display?
    • Each LCD panel has it's own initialize code, see the vendor_specific_init array defined in GC9A01 driver, where contains the Gama setting. You should consult your the LCD supplier.

For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.