DevKitBoard.c配置
配置显示器:st7789, 分配哪些引脚,分配SPI接口
配置触摸屏: iic, 配置iic引脚
按键: 配置按键
触摸屏配置
显示部分
SPI配置
SPI1_PLATFORM_DATA_BEGIN(spi1_data)
.clk = 96000000,
.mode = SPI_1WIRE_MODE,
.port = 'B',
.attr = SPI_SCLK_L_UPL_SMPH | SPI_UNIDIR_MODE,//主机,CLK低 更新数据低,单向模式
SPI1_PLATFORM_DATA_END()
接口定义
static const struct ui_lcd_platform_data pdata = {
.spi_id = "spi1",
.bl_pin = IO_PORTH_02,
.cs_pin = IO_PORTH_03,
.rs_pin = IO_PORTH_04,
.rst_pin = IO_PORTH_05,
.touch_reset_pin = IO_PORTH_06,
.touch_int_pin = IO_PORTH_07,
.te_pin = -1,
.lcd_if = LCD_SPI,//屏幕接口类型还有 PAP , SPI
};
配置完成之后,记得要检查REGISTER_DEVICES(device_table)中有没有配置,app_config.h中有没有启用
在lcd_drive.c的第343行添加如下代码
#if TCFG_LCD_ST7789V_ENABLE//客户屏放最后
lcd_w = 240;
lcd_h = 280;
lcd_bk_on = 1;
lcd_bk_off = 0;
lcd_choice = CONFIG_ST7789V_ID;
printf("\n [lcd_drive] %s -[find_check_ST7789] %d\n", __FUNCTION__, __LINE__);
#endif
触摸部分
iic配置
#ifdef CONFIG_IIC_ENABLE
HW_IIC0_PLATFORM_DATA_BEGIN(hw_iic1_data)//硬件IIC
.clk_pin = IO_PORTH_00,
.dat_pin = IO_PORTH_01,
.baudrate = 0x3f,
HW_IIC0_PLATFORM_DATA_END()
SW_IIC_PLATFORM_DATA_BEGIN(sw_iic0_data)//软件iic
.clk_pin = IO_PORTH_00,
.dat_pin = IO_PORTH_01,
.sw_iic_delay = 50,
SW_IIC_PLATFORM_DATA_END()
#endif
配置完成之后,记得要检查REGISTER_DEVICES(device_table)中有没有配置,app_config.h中有没有启用
替换驱动文件
lcd_st7789v.c
cst816t.c
lcd_drive.h
lcd_drive.c
需要修改ui/include/lcd_config.h
#define LCD_W 240
#define LCD_H 280
app_config.h配置
里面有非常多的宏定义,根据这些宏定义,开关相应的功能
#define TCFG_LCD_ST7789V_ENABLE 1
#define TCFG_TOUCH_CST816T_ENABLE 1
#define USE_LVGL_UI_DEMO 1
#define CONFIG_UI_ENABLE 1
#define CONFIG_BT_ENABLE 1
注意将没有用到的UI配置全都禁用掉
#define USE_LCD_240X320 0
#define USE_LCD_320X480 0
#if USE_LCD_240X320
#define TCFG_TOUCH_GT911_ENABLE 0
#define TCFG_LCD_ILI9341_ENABLE 0
#endif //USE_LCD_240X320_ILI9341
#if USE_LCD_320X480
#define TCFG_TOUCH_FT6236_ENABLE 0
#define TCFG_LCD_ILI9488_ENABLE 0
#define TCFG_LCD_ILI9481_ENABLE 0
#endif //USE_LCD_320X480_ILI9481
其它配置
- 禁用ui_main.c
- wifi_demo_task.c 文件注释掉568行的 //stats_display();