lvgl_esp32_drivers/lvgl_helpers.h

117 lines
4.1 KiB
C
Raw Normal View History

/**
* @file lvgl_helpers.h
*/
#ifndef LVGL_HELPERS_H
#define LVGL_HELPERS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include <stdbool.h>
#include "lvgl_spi_conf.h"
#include "lvgl_tft/disp_driver.h"
#include "lvgl_touch/touch_driver.h"
/*********************
* DEFINES
*********************/
/* DISP_BUF_SIZE value doesn't have an special meaning, but it's the size
* of the buffer(s) passed to LVGL as display buffers. The default values used
* were the values working for the contributor of the display controller.
*
* As LVGL supports partial display updates the DISP_BUF_SIZE doesn't
* necessarily need to be equal to the display size.
*
* When using RGB displays the display buffer size will also depends on the
* color format being used, for RGB565 each pixel needs 2 bytes.
* When using the mono theme, the display pixels can be represented in one bit,
* so the buffer size can be divided by 8, e.g. see SSD1306 display size. */
#if defined (CONFIG_CUSTOM_DISPLAY_BUFFER_SIZE)
#define DISP_BUF_SIZE CONFIG_CUSTOM_DISPLAY_BUFFER_BYTES
#else
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
2020-12-24 17:44:17 +00:00
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX/3)
2023-08-26 10:23:37 +00:00
// IMPORTANT: This will render the screen in 8 times (more and it skips lines, supposedly limited by PSRAM speed)
#elif defined (CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER)
2023-08-24 10:45:30 +00:00
#define DISP_BUF_SIZE LV_HOR_RES_MAX*(LV_VER_RES_MAX/ 8)
#elif defined (CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER)
#define DISP_BUF_SIZE LV_HOR_RES_MAX*(LV_VER_RES_MAX/10)
#elif defined (CONFIG_LV_SHARP_DISPLAY_CONTROLLER)
#define DISP_BUF_SIZE LV_HOR_RES_MAX*(LV_VER_RES_MAX)
2021-06-03 11:38:23 +00:00
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107
2021-01-09 21:04:53 +00:00
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306
2021-01-31 23:28:03 +00:00
#if defined (CONFIG_LV_THEME_MONO)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8))
2021-01-31 23:28:03 +00:00
#else
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX)
#endif
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
#define DISP_BUF_LINES 40
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * DISP_BUF_LINES)
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_IL3820)
2021-01-09 21:04:53 +00:00
#define DISP_BUF_SIZE (LV_VER_RES_MAX * IL3820_COLUMNS)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_GC9A01)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_JD79653A)
2021-01-09 21:04:53 +00:00
#define DISP_BUF_SIZE ((LV_VER_RES_MAX * LV_VER_RES_MAX) / 8) // 5KB
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D)
2021-01-09 21:04:53 +00:00
#define DISP_BUF_SIZE ((LV_VER_RES_MAX * LV_VER_RES_MAX) / 8) // 2888 bytes
#else
#error "No display controller selected"
#endif
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/* Initialize detected SPI and I2C bus and devices */
void lvgl_driver_init(void);
/* Initialize SPI master */
bool lvgl_spi_driver_init(int host, int miso_pin, int mosi_pin, int sclk_pin,
int max_transfer_sz, int dma_channel, int quadwp_pin, int quadhd_pin);
2023-08-24 10:45:30 +00:00
/* Initialize I2C master */
bool lvgl_i2c_driver_init(int port, int sda_pin, int scl_pin, int speed);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LVGL_HELPERS_H */