OLED (Organic Electroluminesence Display) is an organic light-emitting display. Unlike traditional displays, which require backlight to display, OLED does not require backlight and can emit light by itself.
The reason why OLED can emit light by itself is mainly driven by electric field: organic semiconductor materials and luminescent materials emit light through overcarrier injection and recombination. In essence, it is to use the ITO glass transparent electrode as the anode of the device and the metal electrode as the cathode. Driven by power, electrons are transferred from the cathode to the electron transport layer, and holes are injected from the anode to the hole transport layer, and then migrate to the light-emitting layer. When the two meet, excitons are generated, which excite the luminescent molecules and generate light sources after radiation. Simply put, an OLED screen is composed of hundreds of millions of "small bulbs".
OLED is not only thinner, lower power consumption, higher brightness, better luminous efficiency, and can display pure black, but it can also be curved, such as today's curved screen TVs and mobile phones. Today's major international manufacturers are scrambling to increase their investment in the research and development of OLED technology, making OLED technology more widely used in today's TVs, computers (monitors ) , mobile phones, tablets and other fields. The following figure shows a physical picture of an OLED display module.
- SPI driving OLED experiment
The SPI used in this section is different from the SPI (Six-axis Sensor Data Acquisition) section of the Flight Control Development Basics. This section uses SPI simulated through GPIO, while the STM32 hardware SPI is used in the Flight Control Development Basics SPI (Six-axis Sensor Data Acquisition). For more information about the SPI protocol, please refer to the Flight Control Development Basics SPI (Six-axis Sensor Data Acquisition).
According to the schematic diagram, the electrical connection relationship of the OLED screen can be known, as shown in the figure below.
It can be seen that the reset pin RES of OLED is connected to PB6 of STM32, the command/data selection pin DC of OLED is connected to PB7 of STM32, the clock line of OLED is connected to PA5 of STM32, and the data input of OLED is connected to PA7 of STM32. The OLED module here does not have a CS chip select pin because the module is grounded by default. The overall code writing idea of OLED display is as follows.
Code ideas
1
|
Pin Configuration
|
1. Define the structure;
2. Enable the clock;
3. Filling structure;
4. Loading structure;
|
2
|
OLED Timing Implementation
|
1. Write data/command function implementation.
|
3
|
OLED configuration and functional function implementation
|
- OLED initialization;
- OLED functional functions are implemented (such as screen refreshing, dot drawing, screen clearing, etc.).
|
4
|
Logical Processing
|
1. Display logic.
|
According to the manual of the OLED driver chip SSD1306, the control timing can be learned, as shown in the figure below.
According to the timing, you can write the corresponding timing code. The following figure shows the code for writing the timing of OLED.
According to the SSD1306 manual, the OLED initialization process can be found as shown in the figure below.
The OLED initialization code implementation is shown in the figure below.
All OLED displays are based on point drawing, from points to lines, and then from lines to surfaces. The code implementation of OLED's point drawing function is shown in the figure below.
The OLED displays a single character code as shown below.
To display characters, you need to take the modulus of the corresponding characters. Two fonts with modulus are provided here. According to the modulus method of "yin code, column by column, forward", the font sizes are 12*6 and 16*8 respectively. They are in oledfont.h, as shown in the figure below.
The module needs to be taken through the module software. Here we use "PCtoLCD2002". This software has two major functions, one is character module and the other is image module. Here we use character module. According to the code-driven point drawing direction, the font options of the generated 12*6 font are set as shown in the figure below.
Here we take the generation of the 12*6 character "1" as an example. After setting the font options according to the above figure, enter "1" and click "Generate Font" to generate the corresponding hexadecimal font code, as shown in the figure below.
This experiment requires displaying "COCOFLY" and "www.fengke.club" through OLED. The specific implementation code is as follows.
Save, compile and download. The implementation phenomenon is as shown in the figure below.