0.96-inch SPI Monochrome Display
Module Source
Purchase link: https://item.taobao.com/item.htm?id=37849023766&_u=n1q56pn343e4
Materials download link:
https://pan.baidu.com/s/1U9r32qeS2jOANB0SNwtwnw
Materials extraction code: 8888
Specifications
File 1.6.2.1 Screen Specification Operating voltage: 3.3V Operating current: 15 mA Module size: 27.3 x 27.8 mm Pixel size: 128(H) x 64(V) RGB Driver chip: SSD1306 Communication protocol: SPI Number of pins: 7 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 7 interfaces. For specific interface descriptions, see Table 6.4.1-1 Pin Descriptions.
The module is an SPI communication protocol slave. D0 is the SPI signal line (SCK), D1 is the SPI output line (MOSI), and CS is the SPI chip select line (NSS).
The pins selected here are shown in Table 6.4.1-2 Software SPI Wiring.
Copy the prepared [OLED] 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 OLED 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 6.5 for porting verification.
Hardware SPI Porting
This screen requires 7 interfaces. For specific interface descriptions, see Table 6.4.2-1 Pin Descriptions.
The module is an SPI communication protocol slave. D0 is the SPI signal line (SCK), D1 is the SPI output line (MOSI), and CS is the SPI chip select line (NSS).
The pins selected here are shown in Table 6.4.2-2 Hardware SPI Wiring.
Copy the prepared [OLED] 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 OLED 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 section 6.5 for 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 "oled.h"
void app_main(void)
{
OLED_Init(); // Initialize OLED
OLED_Clear();
while(1)
{
OLED_ShowString(0,0,(uint8_t *)"ABC",8,1);//6*8 "ABC"
OLED_ShowString(0,8,(uint8_t *)"ABC",12,1);//6*12 "ABC"
OLED_ShowString(0,20,(uint8_t *)"ABC",16,1);//8*16 "ABC"
OLED_ShowString(0,36,(uint8_t *)"ABC",24,1);//12*24 "ABC"
OLED_Refresh();
delay_ms(500);
}
}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
Power-on effect: