100 lines
3.2 KiB
C
100 lines
3.2 KiB
C
#ifndef _FLUXDISPLAY_PORT_H
|
|
#define _FLUXDISPLAY_PORT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/* Use C language to complete the LVGL initialization work, providing an interface for C++ calls */
|
|
|
|
#include <stdio.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "freertos/semphr.h"
|
|
#include "esp_timer.h"
|
|
#include "esp_err.h"
|
|
#include "esp_log.h"
|
|
#include "esp_lcd_panel_io.h"
|
|
#include "esp_lcd_panel_vendor.h"
|
|
#include "esp_lcd_panel_ops.h"
|
|
#include "driver/gpio.h"
|
|
#include "lvgl.h"
|
|
|
|
// Include additional touch screen driver header files
|
|
#include "driver/i2c.h"
|
|
#include "esp_lcd_touch_ft5x06.h"
|
|
|
|
|
|
/* Define some variables that need to be used */
|
|
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ CONFIG_EXAMPLE_LCD_PIXEL_CLOCK_HZ
|
|
|
|
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 0
|
|
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
|
|
|
/* Define data interfaces */
|
|
#define EXAMPLE_PIN_NUM_DATA0 GPIO_NUM_18
|
|
#define EXAMPLE_PIN_NUM_DATA1 GPIO_NUM_17
|
|
#define EXAMPLE_PIN_NUM_DATA2 GPIO_NUM_16
|
|
#define EXAMPLE_PIN_NUM_DATA3 GPIO_NUM_15
|
|
#define EXAMPLE_PIN_NUM_DATA4 GPIO_NUM_7
|
|
#define EXAMPLE_PIN_NUM_DATA5 GPIO_NUM_6
|
|
#define EXAMPLE_PIN_NUM_DATA6 GPIO_NUM_5
|
|
#define EXAMPLE_PIN_NUM_DATA7 GPIO_NUM_4
|
|
|
|
/* Define other screen display interfaces */
|
|
#define EXAMPLE_PIN_NUM_PCLK GPIO_NUM_19
|
|
#define EXAMPLE_PIN_NUM_CS GPIO_NUM_0
|
|
#define EXAMPLE_PIN_NUM_DC GPIO_NUM_20
|
|
#define EXAMPLE_PIN_NUM_RST GPIO_NUM_8
|
|
#define EXAMPLE_PIN_NUM_BK_LIGHT GPIO_NUM_3
|
|
|
|
// The pixel number in horizontal and vertical
|
|
#define EXAMPLE_LCD_H_RES 320
|
|
#define EXAMPLE_LCD_V_RES 480
|
|
// Bit number used to represent command and parameter
|
|
#define EXAMPLE_LCD_CMD_BITS 8
|
|
#define EXAMPLE_LCD_PARAM_BITS 8
|
|
|
|
|
|
/* Define the touch screen driver interface to be used */
|
|
#define EXAMPLE_I2C_NUM 0
|
|
#define EXAMPLE_I2C_SCL GPIO_NUM_39
|
|
#define EXAMPLE_I2C_SDA GPIO_NUM_38
|
|
|
|
/* Define LVGL task attributes */
|
|
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
|
|
#define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500
|
|
#define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 1
|
|
#define EXAMPLE_LVGL_TASK_STACK_SIZE (16 * 1024)
|
|
#define EXAMPLE_LVGL_TASK_PRIORITY 2
|
|
|
|
#define EXAMPLE_DMA_BURST_SIZE (64)
|
|
|
|
|
|
/* Function declarations */
|
|
static bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx);
|
|
static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
|
|
static void example_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
|
static void example_increase_lvgl_tick(void *arg);
|
|
bool example_lvgl_lock(int timeout_ms);
|
|
void example_lvgl_unlock(void);
|
|
static void example_lvgl_port_task(void *arg);
|
|
void example_init_i80_bus(esp_lcd_panel_io_handle_t *io_handle, void *user_ctx);
|
|
void example_init_lcd_panel(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_handle_t *panel);
|
|
void example_init_touch_panel(void);
|
|
void initialize_display_and_touch(void);
|
|
|
|
|
|
/* UI parameter modification interface including thread safety */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /*_FLUXDISPLAY_PORT_H*/ |