1============================ 2ST7789 LCD Controller driver 3============================ 4 5Overview 6-------- 7 8The `ST7789 <https://www.buydisplay.com/download/ic/ST7789.pdf>`__ is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 720 9source line and 320 gate line driving circuits. This chip is capable of connecting directly to an external 10microprocessor, and accepts, 8-bits/9-bits/16-bits/18-bits parallel interface. Display data can be stored in the 11on-chip display data RAM of 240x320x18 bits. It can perform display data RAM read/write operation with no 12external operation clock to minimize power consumption. In addition, because of the integrated power supply 13circuit necessary to drive liquid crystal; it is possible to make a display system with the fewest components. 14 15The ST7789 LCD controller `driver <https://github.com/lvgl/lvgl/src/drivers/display/st7789>`__ is a platform-agnostic driver, based on the `generic MIPI driver <https://github.com/lvgl/lvgl/doc/integration/drivers/display/gen_mipi.rst>`__. 16It implements display initialization, supports display rotation and implements the display flush callback. The user needs to implement only two platform-specific functions to send 17a command or pixel data to the controller via SPI or parallel bus. Typically these are implemented by calling the appropriate SDK library functions on the given platform. 18 19Prerequisites 20------------- 21 22There are no prerequisites. 23 24Configuring the driver 25---------------------- 26 27Enable the ST7789 driver support in lv_conf.h, by cmake compiler define or by KConfig 28 29.. code-block:: c 30 31 #define LV_USE_ST7789 1 32 33Usage 34----- 35 36You need to implement two platform-dependent functions: 37 38.. code-block:: c 39 40 /* Send short command to the LCD. This function shall wait until the transaction finishes. */ 41 int32_t my_lcd_send_cmd(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, const uint8_t *param, size_t param_size) 42 { 43 ... 44 } 45 46 /* Send large array of pixel data to the LCD. If necessary, this function has to do the byte-swapping. This function can do the transfer in the background. */ 47 int32_t my_lcd_send_color(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, uint8_t *param, size_t param_size) 48 { 49 ... 50 } 51 52To create an ST7789-based display use the function 53 54.. code-block:: c 55 56 /** 57 * Create an LCD display with ST7789 driver 58 * @param hor_res horizontal resolution 59 * @param ver_res vertical resolution 60 * @param flags default configuration settings (mirror, RGB ordering, etc.) 61 * @param send_cmd platform-dependent function to send a command to the LCD controller (usually uses polling transfer) 62 * @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer: must implement a 'ready' callback) 63 * @return pointer to the created display 64 */ 65 lv_display_t * lv_st7789_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags, 66 lv_st7789_send_cmd_cb_t send_cmd_cb, lv_st7789_send_color_cb_t send_color_cb); 67 68 69For additional details and a working example see the `generic MIPI driver documentation <https://github.com/lvgl/lvgl/doc/integration/drivers/display/gen_mipi.rst>`__. 70 71.. note:: 72 73 You can find a step-by-step guide and the actual implementation of the callbacks on an STM32F746 using STM32CubeIDE and the ST HAL libraries here: :ref:`lcd_stm32_guide` 74 75