Display 2.4 Inch TFT LCD (ST7789V)¶
-
group
index
Overview
This library provides functions for supporting a 2.4 inch TFT LCD driven by an ST7789V controller. This is the same display as used on the CY8CKIT-028-TFT shield.
Display: http://www.newhavendisplay.com/nhd24240320cfctxif-p-8176.html
Display Controller:
http://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdfQuick Start
TFT emWin application
Follow the steps bellow in order to create a simple emWin application and display some text.
Create an empty application
Add this library to the application
Add the emWin library to the application
Enable EMWIN_NOSNTS emWin library option by adding it to the Makefile COMPONENTS list:
COMPONENTS=EMWIN_NOSNTS
Place the following code in the main.c file:
#include "cy_pdl.h" #include "cyhal.h" #include "cybsp.h" #include "GUI.h" #include "mtb_st7789v.h" // The pins used here work with the CY8CKIT-028-TFT shield and the CY8CKIT-062-BLE // or CY8CKIT-062-WIFI-BT kit. // If the display is being used on different hardware the mappings will be different. const mtb_st7789v_pins_t tft_pins = { .db08 = CYBSP_J2_2, .db09 = CYBSP_J2_4, .db10 = CYBSP_J2_6, .db11 = CYBSP_J2_10, .db12 = CYBSP_J2_12, .db13 = CYBSP_D7, .db14 = CYBSP_D8, .db15 = CYBSP_D9, .nrd = CYBSP_D10, .nwr = CYBSP_D11, .dc = CYBSP_D12, .rst = CYBSP_D13 }; int main(void) { cy_rslt_t result; // Initialize the device and board peripherals result = cybsp_init(); CY_ASSERT(result == CY_RSLT_SUCCESS); __enable_irq(); // Initialize the display controller result = mtb_st7789v_init8(&tft_pins); CY_ASSERT(result == CY_RSLT_SUCCESS); GUI_Init(); GUI_SetFont(GUI_FONT_32B_1); GUI_SetTextAlign(GUI_ALIGN_HCENTER | GUI_ALIGN_HCENTER); GUI_DispStringAt("Hello World!", LCD_GetXSize() / 2, (LCD_GetYSize() / 2) - (GUI_GetFontSizeY() / 2)); while (1); }
Build the application and program the kit.
TFT emWin FreeRTOS application
Follow the steps bellow in order to create a simple emWin application and display some text.
Create an empty application
Add this library to the application
Add the emwin, abstraction-rtos, and freertos libraries to the application
Enable EMWIN_OSNTS emWin library option by adding it to the Makefile COMPONENTS list:
COMPONENTS=EMWIN_OSNTS FREERTOS
Edit the FreeRTOSConfig.h file in the freertos library. Or make a copy of it in the top level of your project directory. Comment out the #warning statement and update these definitions.
#define configUSE_MUTEXES (1u) #define configUSE_RECURSIVE_MUTEXES (1u) #define configUSE_COUNTING_SEMAPHORES (1u) #define configSUPPORT_STATIC_ALLOCATION (1u) #define configSUPPORT_DYNAMIC_ALLOCATION (1u) #define configTOTAL_HEAP_SIZE (1024*48u) #define configUSE_TRACE_FACILITY (1u)
Place the following code in the main.c file:
#include "FreeRTOS.h" #include "GUI.h" #include "cy_pdl.h" #include "cybsp.h" #include "cyhal.h" #include "mtb_st7789v.h" #include "task.h" // The pins used here work with the CY8CKIT-028-TFT shield and the CY8CKIT-062-BLE // or CY8CKIT-062-WIFI-BT kit. // If the display is being used on different hardware the mappings will be different. const mtb_st7789v_pins_t tft_pins = { .db08 = CYBSP_J2_2, .db09 = CYBSP_J2_4, .db10 = CYBSP_J2_6, .db11 = CYBSP_J2_10, .db12 = CYBSP_J2_12, .db13 = CYBSP_D7, .db14 = CYBSP_D8, .db15 = CYBSP_D9, .nrd = CYBSP_D10, .nwr = CYBSP_D11, .dc = CYBSP_D12, .rst = CYBSP_D13 }; void guiTask(void *arg) { GUI_Init(); GUI_SetFont(GUI_FONT_32B_1); GUI_SetTextAlign(GUI_ALIGN_HCENTER | GUI_ALIGN_HCENTER); GUI_DispStringAt("Hello World!", LCD_GetXSize() / 2, (LCD_GetYSize() / 2) - (GUI_GetFontSizeY() / 2)); } int main(void) { cy_rslt_t result; // Initialize the device and board peripherals result = cybsp_init(); CY_ASSERT(result == CY_RSLT_SUCCESS); // Initialize the display controller result = mtb_st7789v_init8(&tft_pins); CY_ASSERT(result == CY_RSLT_SUCCESS); xTaskCreate(guiTask, "GUI Task", 1024*10, 0, 1, 0); vTaskStartScheduler(); while (1); // Will never get here }
Build the application and program the kit.
TFT emWin mbed application
Follow the steps bellow in order to create a simple emWin application and display some text.
Create a new application
mbed new tft_app cd tft_app
Add this library to the application
mbed add http://devops-git.aus.cypress.com/repo-staging/display-tft-st7789v.git
Add the emwin library to the application
mbed add http://devops-git.aus.cypress.com/repo-staging/emwin.git
Enable EMWIN_OSNTS emWin library option by adding it to the mbed_app.json file
"target_overrides": { "*":{ "target.components_add": ["EMWIN_OSNTS"],
Place the following code in the main.cpp file:
#include "GUI.h" #include "cy_pdl.h" #include "cy_utils.h" #include "cybsp.h" #include "cycfg.h" #include "mbed.h" #include "mtb_st7789v.h" // The pins used here work with the CY8CKIT-028-TFT shield and the CY8CKIT-062-BLE // or CY8CKIT-062-WIFI-BT kit. // If the display is being used on different hardware the mappings will be different. const mtb_st7789v_pins_t tft_pins = { .db08 = CYBSP_J2_2, .db09 = CYBSP_J2_4, .db10 = CYBSP_J2_6, .db11 = CYBSP_J2_10, .db12 = CYBSP_J2_12, .db13 = CYBSP_D7, .db14 = CYBSP_D8, .db15 = CYBSP_D9, .nrd = CYBSP_D10, .nwr = CYBSP_D11, .dc = CYBSP_D12, .rst = CYBSP_D13 }; int main(void) { // Initialize the device and board peripherals cybsp_init(); // Initialize the display controller cy_rslt_t result = mtb_st7789v_init8(&tft_pins); CY_ASSERT(result == CY_RSLT_SUCCESS); // Initialize emWin and display some text GUI_Init(); GUI_SetFont(GUI_FONT_32B_1); GUI_SetTextAlign(GUI_ALIGN_HCENTER | GUI_ALIGN_HCENTER); GUI_DispStringAt("Hello World!", LCD_GetXSize() / 2, (LCD_GetYSize() / 2) - (GUI_GetFontSizeY() / 2)); ThisThread::sleep_for(osWaitForever); }
Build the application and program the kit.
mbed compile --target CY8CKIT_062_BLE --toolchain GCC_ARM --flash or mbed compile --target CY8CKIT_062_WIFI_BT --toolchain GCC_ARM --flash
More information
© Cypress Semiconductor Corporation, 2019-2021.