0.96-inch Color Display
Module Source
Purchase link: https://item.taobao.com/item.htm?id=563017284569&_u=n1q56pn38e09 Materials download link: https://pan.baidu.com/s/19DxY8JJEzNt4XYF_CwVbDw Materials extraction code: 8888
Specifications
Operating voltage: 2.8~3.3V Operating current: 30 mA Module size: 24(H) x 30(V) mm Pixel size: 80(H) x 160(V) RGB Driver chip: ST7735 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:
The registers mainly related to the display position and display direction of the screen are:
- 36h Memory Data Access Control — memory data control, used to control the position of the screen's (0,0) origin and the directions of the x-axis and y-axis.
- 2ah Column address set register
- 2bh Row address set register
- 2c Memory write register — the color data displayed for a certain pixel. The register that is the most time-consuming and requires the deepest understanding is the 36h register, which involves the display direction and display position of the screen.
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 2.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 current manufacturer's source code uses the software SPI interface, and the manufacturer has already completed the SPI timing. We only need to configure the pins and delays. Therefore, connect the screen pins according to your needs. The pins selected here are shown in Table 2.4.1-2 Software SPI Wiring.
Copy the prepared [LCD] folder into the main folder of your project.
Software SPI driver code (adapted):
[LCD] Folder 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 section 2.5 for porting verification.
Hardware SPI Porting
This screen requires 8 interfaces. For specific interface descriptions, see Table 2.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 current manufacturer's source code uses the software SPI interface, and the manufacturer has already completed the SPI timing. We only need to configure the pins and delays. Therefore, connect the screen pins according to your needs. The pins selected here are shown in Table 2.4.2-2 Hardware SPI Wiring.
Copy the prepared [LCD] folder into the main folder of your project.
LCD hardware SPI driver code (adapted):
[LCD] Folder 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 hardware 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 screen
LCD_Fill(0,0,LCD_W,LCD_H,BLACK);// Clear the full screen to black
while(1)
{
LCD_ShowString(0,16*0,(uint8_t *)"LCD_W:",WHITE,BLACK,16,0);
LCD_ShowIntNum(48,16*0,LCD_W,3,WHITE,BLACK,16);
LCD_ShowString(80,16*0,(uint8_t *)"LCD_H:",WHITE,BLACK,16,0);
LCD_ShowIntNum(128,16*0,LCD_H,3,WHITE,BLACK,16);
LCD_ShowString(0,16*1,(uint8_t *)"Nun:",WHITE,BLACK,16,0);
LCD_ShowFloatNum1(8*4,16*1,t,4,WHITE,BLACK,16);
LCD_ShowChinese(8*5,16*3,(uint8_t *)"中电子",RED,BLACK,32,0);
t+=0.11;
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
Power-on effect: