LCD硬件规格:1.3寸,分辨率:240*240,接口:单线SPI,显示IC:ST7789;EMwin移植版本为6.16,在自带的显示驱动文件"LCDConf_FlexColor_Template.c"中更改LCD的水平分辨率和垂直分辨率.
1.更改显示分辨率
#define XSIZE_PHYS 240 // To be adapted to x-screen size
#define YSIZE_PHYS 240 // To be adapted to y-screen size
2.添加写寄存器
static void LcdWriteReg(U8 Data)
{
// ... TBD by user
LCD_Write_Cmd(Data);
}
3.添加写数据
static void LcdWriteData(U8 Data)
{
// ... TBD by user
LCD_Write_Data(Data);
}
4.添加写多个数据
static void LcdWriteDataMultiple(U8 * pData, int NumItems)
{
while (NumItems--)
{
// ... TBD by user
LCD_Write_Data(*pData++);
}
}
5.LCD配置
void LCD_X_Config(void)
{
GUI_DEVICE * pDevice;
CONFIG_FLEXCOLOR Config = {0};
GUI_PORT_API PortAPI = {0};
// Set display driver and color conversion
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
// Display driver configuration, required for Lin-driver
LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
// Orientation
//Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
Config.Orientation = 0 ;
Config.NumDummyReads = 2;
GUIDRV_FlexColor_Config(pDevice, &Config);
// Set controller and operation mode
PortAPI.pfWrite8_A0 = LcdWriteReg;
PortAPI.pfWrite8_A1 = LcdWriteData;
PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple;
PortAPI.pfReadM8_A1 = LcdReadDataMultiple;
//ST7789ΪGUIDRV_FLEXCOLOR_F66709
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8);
}
6.LCD初始化
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
{
int r;
(void) LayerIndex;
(void) pData;
switch (Cmd)
{
case LCD_X_INITCONTROLLER:
{
//
// Called during the initialization process in order to set up the
// display controller and put it into operation. If the display
// controller is not initialized by any external routine this needs
// to be adapted by the customer...
//
// ...
//调用LCD初始化
Lcd_Init();
return 0;
}
default:
r = -1;
}
return r;
}
7.在systemtick中添加GUI 1毫秒时基
void SysTick_Handler( void )
{
#include "GUI.h"
extern volatile GUI_TIMER_TIME OS_TimeMS;
++OS_TimeMS ;
}
8.main主程序中添加
GUI_Init();
WM_SetCreateFlags(WM_CF_MEMDEV); //使用内存设备进行重绘
GUI_UC_SetEncodeUTF8();
CreateWindow();
while( 1 )
{
GUI_Delay(10);
}
最终画面
|