Running GUI on Display

This application note explains how to run a sample GUI on the LCD, from the FreeRTOS demo application.

1. Understanding FreeRTOS LCD Interfaces

1.1. FreeRTOS LCD Implementation

The FreeRTOS BSP makes use of the STM32CubeH7 software component to provide a device driver for the LCD controller. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_LTDC_MODULE_ENABLED configuration option, defined in the stm32h7xx_hal_conf.h file.

The display video frame buffer resides in SDRAM, in a non-cached memory region. Depending on the value of the configGUI_INITIALIZED build-time parameter defined in the FreeRTOSConfig.h file, the driver initialises the LCD controller (configGUI_INITIALIZED is equal 1) or rely on the LCD controller settings defined by U-boot.

1.2. FreeRTOS LCD C-Binding API

The display driver implements the following C-binding API:

Function

Description

Comments

uint8_t BSP_LCD_Init(void);

Initialise LCD and backlight

 

uint8_t BSP_LCD_DeInit(void);

De-initialise LCD and backlight

 

uint32_t BSP_LCD_GetXSize(void);

Return LCD width in pixels

 

uint32_t BSP_LCD_GetYSize(void);

Return LCD height in pixels

 

void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FrameBuffer);

Set frame buffer address of layer LayerIndex

 

void BSP_LCD_SelectLayer(uint32_t LayerIndex);

Activate layer LayerIndex

 

void BSP_LCD_Clear(uint32_t Color);

Fill frame buffer with color Color

 

void BSP_LCD_DisplayOn(void);

Turn LCD on

 

void BSP_LCD_DisplayOff(void);

Turn LCD off

 

void BSP_LCD_SetBrightness(uint8_t BrightnessValue);

Set LCD brightness

BrightnessValue is from 0 (dimmest) to 100 (brightest)

1.3. LCD CLI Command

The FreeRTOS application implements the following display related CLI command:

Command

Description

Comments

lcdtest

Write a certain graphical pattern to the LCD display

 

2. Understanding FreeRTOS Touch Panel Interfaces

2.1. FreeRTOS Touch Panel Implementation

The FreeRTOS BSP makes use of the STM32CubeH7 software component to provide a device driver for the I2C touch controller. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_I2C_MODULE_ENABLED configuration option, defined in the stm32h7xx_hal_conf.h file.

2.2. FreeRTOS Touch Panel C-Binding API

The touch driver implements the following C-binding API:

Function

Description

Comments

Function

Description

Comments

ts_goodix_handler * ts_goodix_init(uint8_t bus, uint8_t i2c_addr, uint16_t max_width, uint16_t max_height, GPIO_TypeDef * port, uint32_t pin)

 

Initialize the I2C touch controller

bus is the I2C bus of the I2C touch controller; i2c_addr is the I2C address of the I2C touch controller on the specified I2C bus; max_width is a max width resolution of the touch screen; max_height is a max height resolution of the touch screen; port is the GPIO port which specify an interrupt of the I2C touch controller; pin is the GPIO pin which specify an interrupt of the I2C touch controller; returns the I2C touch controller handle or 0 in case of error

int ts_goodix_read_input(ts_goodix_handler * hts, uint16_t * x, uint16_t * y)

 

Read data from the I2C touch controller

hts is the I2C touch controller handle; x is coordinates along the X-axis; y coordinates along the Y-axis; returns number of touches in case if the value is from 1 to 5 otherwise operation error (need to rerun the operation)

The ts_goodix_handler data structure used in the driver API has the following definition:

typedef struct { I2C_HandleTypeDef * hi2c; /* handle to the I2C interface */ uint16_t devid; /* device id of the I2C touch controller */ uint16_t i2c_addr; /* I2C address of the I2C touch controller */ uint32_t cfg_len; /* length of the configuration data */ uint16_t max_width; /* max width resolution */ uint16_t max_height; /* max heigth resolution */ } ts_goodix_handler;

3. Understanding Sample GUI

3.1. Sample GUI Implementation

The FreeRTOS test application implements a separate thread called GUI thread, which provides a sample GUI application running on the LCD display and the touch panel controller.

The sample GUI functions as follows:

  • Write a test pattern to the LCD display.

  • Initialise the touch controller driver, and then run an endless loop that waits for interrupts from the touch controller and, upon each touch event, print to the serial console a message with detailed information on the touch event.

  • In addition to the printing of the message with detailed information on the touch event, touching the display panel changes the shown picture between the two images. One of them is drawn using the DMA2D Chrom-Art Accelerator, the other fills the display frame buffer directly.

3.2. Sample GUI Session

Perform the following step-wise procedure, to validate the sample GUI functionality:

  1. Power cycle the board and let it boot to the FreeRTOS CLI.

  2. Validate that the test pattern is visible on the LCD display.

  3. Validate that any touch to the display panel results in the correct coordinates (within the 480x272 constrains) printed to the serial console.

  4. Validate that any touch to the display panel changes the shown picture between the two images.