1.69-inch Color Display
Module Source
Purchase link: https://item.taobao.com/item.htm?id=636002776097&_u=n1q56pn3e33f Materials download link: https://pan.baidu.com/s/1Q4s3fk0uy8AP5aqNZ3fBmg Materials extraction code: 8888
Specifications
File 5.2-1 Screen Specification Operating voltage: 3.3V Operating current: 90 mA Module size: 31(H) x 48(V) mm Pixel size: 240(H) x 280(V) RGB Driver chip: ST7789V2 Communication protocol: SPI Number of pins: 8 Pin (2.54mm pitch header)
Principle Analysis
Similar to I2C, SPI also has both software SPI and hardware SPI.
The ESP32-S3 chip integrates four SPI controllers: • SPI0 • SPI1 • General-purpose SPI2, i.e., GP-SPI2 • and General-purpose SPI3, i.e., GP-SPI3
The SPI0 and SPI1 controllers are mainly used internally to access external flash and PSRAM. We can only use SPI2 and SPI3. Hardware SPI supports the following features:
Porting Process
Our goal is to port the example to the ESP32-S3 dev board. Complete driver code has been provided for you. Follow the steps below to complete the porting.
Software SPI Porting
This screen requires 8 interfaces. For specific interface descriptions, see Table 5.4.1-1 Pin Descriptions.
The module is an SPI communication protocol slave. SCL is the SPI signal line (SCK), SDA is the SPI output line (MOSI), and CS is the SPI chip select line (NSS).
If the MCU has insufficient GPIO pins, you can leave two of the screen's pin interfaces unconnected to the MCU's GPIO.
- Connect RES to the MCU's reset pin so that when the MCU resets, the screen resets as well;
- BLK can be connected to 3.3V or left floating, at the cost of not being able to control the backlight brightness.
The pins selected here are shown in Table 5.4.1-2 Software SPI Wiring.
Copy the prepared [LCD] folder into the main folder of your project. Software SPI driver code:
File Download
📌 Materials Download Center (Click to Jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.
Copy the LCD folder under the main folder:
Open your project and import the files we just copied into the .c and .h file paths.
- In VSCode, open the CMakeLists.txt file in the main folder.
- Add these paths.
The software SPI porting is now complete. Please proceed to porting verification.
Hardware SPI Porting
This screen requires 8 interfaces. For specific interface descriptions, see Table 5.4.2-1 Pin Descriptions.
The module is an SPI communication protocol slave. SCL is the SPI signal line (SCK), SDA is the SPI output line (MOSI), and CS is the SPI chip select line (NSS).
If the MCU has insufficient GPIO pins, you can leave two of the screen's pin interfaces unconnected to the MCU's GPIO.
- Connect RES to the MCU's reset pin so that when the MCU resets, the screen resets as well;
- BLK can be connected to 3.3V or left floating, at the cost of not being able to control the backlight brightness.
The pins selected here are shown in Table 5.4.2-2 Hardware SPI Wiring.
Copy the prepared [LCD] folder into the main folder of your project. Hardware SPI driver code:
File Download
📌 Materials Download Center (Click to Jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.
Copy the LCD folder under the main folder:
Open your project and import the files we just copied into the .c and .h file paths.
- In VSCode, open the CMakeLists.txt file in the main folder.
- Add these paths.
The software SPI porting is now complete. Please proceed to porting verification.
Porting Verification
Enter the following code in main.c:
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_timer.h"
#include "LCD/lcd_init.h"
#include "LCD/lcd.h"
#include "LCD/pic.h"
void app_main(void)
{
float t=0;
LCD_Init();// Initialize the LCD
LCD_Fill(0,0,LCD_W,LCD_H,WHITE);
while(1)
{
// LCD_Fill(0,0,LCD_W,LCD_H,WHITE);
// LCD_Fill(0,0,LCD_W,LCD_H,RED);
// LCD_Fill(0,0,LCD_W,LCD_H,GREEN);
// LCD_Fill(0,0,LCD_W,LCD_H,BLUE);
// LCD_Fill(0,0,LCD_W,LCD_H,WHITE);
LCD_ShowChinese(40,0,(uint8_t *)"中电子",RED,WHITE,32,0);
LCD_ShowString(10,33,(uint8_t *)"LCD_W:",RED,WHITE,32,0);
LCD_ShowIntNum(106,33,LCD_W,3,RED,WHITE,32);
LCD_ShowString(10,66,(uint8_t *)"LCD_H:",RED,WHITE,32,0);
LCD_ShowIntNum(106,66,LCD_H,3,RED,WHITE,32);
LCD_ShowFloatNum1(10,99,t,4,RED,WHITE,32);
t+=0.11;
LCD_ShowPicture(160,95,40,40,gImage_1);
delay_ms(1000);
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Power-on effect: