Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of MicroPython controlling OLED to display Chinese?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge of what is the method of MicroPython controlling OLED to display Chinese. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

0x01 experimental equipment

1 TPYBoardv102 development board

0.96 inch OLED display screen (ssd1306) 1 piece

Some DuPont lines

Preparation for 0x02

1. The development based on font.py and ssd1306.py.

2. Add Chinese font to font.py.

There are English, numeric and symbolic characters in font.py. We need to add Chinese fonts to font.py.

2.1 first download the font extraction tool.

Extract and double-click to run PCtoLCD2002.exe.

2.2 in the top menu bar, click "options" and click the image below to save the settings. After the settings are finished, click "OK" to save the settings.

2.3 go back to the main interface, type "I" in the input box and click [generate font].

The font data obtained are as follows:

0x04,0x0E,0x78,0x08,0x08,0xFF,0x08,0x08,0x0A,0x0C,0x18,0x68,0x08,0x08,0x2B,0x10

0x40, 0x50, 0x48, 0x48, 0x48, 0x40, 0x40, 0x40, FE40, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x48, 0x30, 0x22, 0x52, 0x8A, 0x8A, 0x06, 0x02, * "I", 020 /

2.4 add the fetched font data to the font.py.

In the green box is the hexadecimal utf-8 code of "I".

Online tool: http://tool.lu/hexstr/

Referring to the above method, I added the font of the five Chinese characters "I love your motherland" in turn.

Byte2 = {

0xe68891:

[

0x04,0x0E,0x78,0x08,0x08,0xFF,0x08,0x08,0x0A,0x0C,0x18,0x68,0x08,0x08,0x2B,0x10

0x40,0x50,0x48,0x48,0x40,0xFE,0x40,0x44,0x44,0x48,0x30,0x22,0x52,0x8A,0x06,0x02

], # I

0xe788b1:

[

0x00,0x01,0x7E,0x22,0x11,0x7F,0x42,0x82,0x7F,0x04,0x07,0x0A,0x11,0x20,0x43,0x1C

0x08,0xFC,0x10,0x10,0x20,0xFE,0x02,0x04,0xF8,0x00,0xF0,0x10,0x20,0xC0,0x30,0x0E

], # Love

0xe4bda0:

[

0x08,0x08,0x08,0x11,0x11,0x32,0x34,0x50,0x91,0x11,0x12,0x12,0x14,0x10,0x10,0x10

0x80,0x80,0x80,0xFE,0x02,0x04,0x20,0x20,0x28,0x24,0x24,0x22,0x22,0x20,0xA0,0x40

], # you

0xe7a596:

[

0x20,0x11,0x11,0xF9,0x09,0x11,0x11,0x39,0x55,0x95,0x11,0x11,0x11,0x11,0x17,0x10

0x00,0xF8,0x08,0x08,0x08,0xF8,0x08,0x08,0x08,0xF8,0x08,0x08,0x08,0x08,0xFE,0x00

], # Zu

0xe59bbd:

[

0x00,0x7F,0x40,0x40,0x5F,0x41,0x41,0x4F,0x41,0x41,0x41,0x5F,0x40,0x40,0x7F,0x40

0x00,0xFC,0x04,0x04,0xF4,0x04,0x04,0xE4,0x04,0x44,0x24,0xF4,0x04,0x04,0xFC,0x04

], # countries

}

3. The method of displaying Chinese by draw_chinese is added to the ssd1306.py file.

Def draw_chinese (self,ch_str,x_axis,y_axis):

Offset_=0

There are 8 Chinese height lines in y_axis=y_axis*8#.

There are 16 widths in Chinese in xroomaxishui 127-(x_axis*16) #

For k in ch_str:

Code = 0x00# converts Chinese to hexadecimal coding

Data_code = k.encode ("utf-8")

Code | = data_code [0]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report