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

How to control OLED to display Chinese by MicroPython

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

Share

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

This article mainly explains "MicroPython how to control OLED display Chinese", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "MicroPython how to control OLED display Chinese" bar!

0x01 experimental equipment

TPYBoard v102 development board 1 (can be bought on a treasure, the price is not expensive)

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.2 go back to the main interface, type "I" in the input box and click [generate font].

The font data obtained are as follows:

2.2 add the fetched font data to 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, ],#我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, ],#爱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, ],#你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 ],#祖0xe59bbd: [0x00,0x7F,0x40,0x40,0x5F,0x41,0x41,0x4F,0x41,0x41,0x41,0x5F,0x40,0x40,0x7F,0x40, 0x00,0xFC, 0x04memori0x04recollection 0xF4re0x04junior0x04revising 0x04memorial0x04memorial0x4revisor0x24memori0xF4sparing0x04memori0x04Power0xFCPower0x04], # countries}

1. 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): the height of offset_=0 y_axis=y_axis*8# in one line occupies 8 x-width (x_axis*16) # 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