PSoC 6 TFT Display Interface with EmWin Graphics Library
Document Number: 002-23726 Rev. *B
8
/* Start the parallel interface */
GraphicLCDIntf_1_Start();
/* Reset - High, Low (reset), High */
Cy_GPIO_Set(
LCD_RESET_N_0_PORT
,
LCD_RESET_N_0_NUM
);
GUI_Delay(20);
Cy_GPIO_Clr(
LCD_RESET_N_0_PORT
,
LCD_RESET_N_0_NUM
);
GUI_Delay(100);
Cy_GPIO_Set(
LCD_RESET_N_0_PORT
,
LCD_RESET_N_0_NUM
);
GUI_Delay(100);
….
GraphicLCDIntf_1_Write8_A0(0x28);
GraphicLCDIntf_1_Write8_A0(0x11);
//Exit Sleep mode
GUI_Delay(100);
GraphicLCDIntf_1_Write8_A0(0x36);
GraphicLCDIntf_1_Write8_A1(0xA0);
//MADCTL: memory data access control
GraphicLCDIntf_1_Write8_A0(0x3A);
GraphicLCDIntf_1_Write8_A1(0x65);
//COLMOD: Interface Pixel format
….
If a different display controller is used, this function must be modified to send the appropriate command and data bytes
as defined in the controller data sheet.
7. In the
LCDConf.c
file, the
LCD_X_Config
function configures various parameters required by the driver. Some
important parts of this function are shown below.
The
GUI_DEVICE_CreatAndLink
function sets the display driver and color palette.
GUI_DEVICE
* pDevice;
pDevice = GUI_DEVICE_CreateAndLink(
DISPLAY_DRIVER
,
COLOR_CONVERSION
, 0, 0);
The configuration structure is updated with the display orientation; the
GUIDRV_FlexColor_Config
function sets up
the display driver. The ST7789S controller has a resolution of 240x320. However, the display used in the TFT shield
has a resolution of 320x240. Because of this swapping of X and Y resolutions, the orientation is set to swap X and Y
axes and mirror the Y axis.
CONFIG_FLEXCOLOR
Config = {0};
Config.Orientation =
GUI_MIRROR_Y
|
GUI_SWAP_XY
;
GUIDRV_FlexColor_Config(pDevice, &Config);
The PortAPI structure sets the pointers to the APIs that perform read and write through the GraphicLCDIntf parallel
interface. The
GUIDRV_FlexColor_SetFunc
function is called to configure the Port APIs, specific display controller,
and interface.
GUI_PORT_API
PortAPI = {0};
PortAPI.pfWrite8_A0 = GraphicLCDIntf_1_Write8_A0;
PortAPI.pfWrite8_A1 = GraphicLCDIntf_1_Write8_A1;
PortAPI.pfWriteM8_A1 = GraphicLCDIntf_1_WriteM8_A1;
PortAPI.pfRead8_A1 = GraphicLCDIntf_1_Read8_A1;
PortAPI.pfReadM8_A1 = GraphicLCDIntf_1_ReadM8_A1;
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI,
GUIDRV_FLEXCOLOR_F66709
,
GUIDRV_FLEXCOLOR_M16C0B8
);
See Section 33.7.4
“GUIDRV_FlexColor” in the EmWin user guide for details.
8. Open the
GUIConf.c
file. This file manages the RAM allocation for the EmWin library. The value of the macro
GUI_NUMBYTES
macro must be set according to the approximate memory requirement based on EmWin library
features used by the application. This will depend on the various options enabled in the
GUIConf.h
file. See Section
37.2,
“Memory Requirements” in the EmWin user guide for details on the memory usage for various features. For this
code example, the memory size has been set to an arbitrary 0x1000 bytes. You can set this to a smaller value based
on the features used in your application.
9. The
GUI_X.c
file has timing functions used by the EmWin library. The content of this file varies based on the OS
support selected. No modifications are required in this file for this code example.