Display various data (text, letters, pictures) on OLED

Let’s talk about OLED today, and record the results at the same time.

Before learning OLED, you need to know the IIC protocol. If you don’t know it, you can read it ( related to the IIC protocol_dxdlnu’s blog-CSDN blog )

What is OLED?  OLED_Baidu Encyclopedia (baidu.com)

 1. OLED write command and data

Because OLED has the operation of writing instructions/data, as for why you can know when you write the program later.

First look at how to write instructions and data?

CO and D/C are described as follows:

According to the protocol diagram, encapsulate a function that writes instructions :

 Wrap a function that writes data:

**********line 87 is wrong, it should be 0x40 to write data

2. The idea and code implementation of OLED displaying a point

First of all, think about it, an OLED screen is so big, how can we display a point in a place we want? This must first solve the problem of the OLED display method.

First of all, we need to understand the composition of the OLED display:

We can see that there are 8 rows in the Page, and there are 8 bits in each Page, that is, a column of a Page represents a byte.

After a general understanding, let's see how OLED is addressed?

There are three addressing methods (the first two are the most common), and the figure is relatively vivid without too much explanation.

How to set the addressing mode you want in Keil?

 

For example, here we want to set the page addressing mode, we can send cmd in the code and write 0x20, and then send 0x02, successfully enter the page addressing mode.

Next, implement a point with code. 

Displaying a point on OLED is mainly these three steps

The following is a line-by-line analysis of the code:

Line 141. The first is to initialize Init, which is included in this manual, and it is good to just cv it directly (our Cmd and Data functions have been written)

 142. Row select a location

Guess you like

Origin blog.csdn.net/weixin_62599865/article/details/130233210