Skip to content

Commit adb17dc

Browse files
authored
Merge pull request #48 from Tinyu-Zhao/master
add some Ex&explain
2 parents fcc5ec6 + 9474006 commit adb17dc

File tree

54 files changed

+81154
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+81154
-442
lines changed

examples/Advanced/Display/Display_Unicode/CUF_24px.h

Lines changed: 76868 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core2 sample source code
5+
* 配套 M5Core2 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/core/core2
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/core2
8+
*
9+
* describe:Display_Unicode. Unicode显示
10+
* date:2021/7/23
11+
*******************************************************************************
12+
*/
13+
14+
/*---PLEASE SEE THE README----
15+
------请在使用前看README文件----*/
16+
#include <M5Core2.h>
17+
#include "CUF_24px.h"
18+
19+
void setup()
20+
{
21+
M5.begin(); //Init M5Stack. 初始化M5Core2
22+
M5.Lcd.setFreeFont(&unicode_24px); //Set the GFX font to use. 设置要使用的GFX字体
23+
M5.Lcd.setTextDatum(TC_DATUM); //Set text alignment to center-up alignment. 设置文本对齐方式为居中向上对齐
24+
}
25+
26+
void loop()
27+
{
28+
M5.Lcd.fillScreen(0);
29+
M5.Lcd.drawString("Hello world", 160, 60, 1); //Hello world is displayed in font 1 on (1600.60).
30+
M5.Lcd.drawString("你好 世界", 160, 90, 1); //在(160,60)处以字体1显示hello world
31+
M5.Lcd.drawString("Здравствуй мир", 160, 120, 1);
32+
M5.Lcd.drawString("こんにちは せかい", 160, 150, 1);
33+
delay(3000);
34+
35+
M5.Lcd.fillScreen(0); //Fill the screen with black (used to clear the screen) is equivalent to clear (). 使屏幕充满黑色(用来清屏)等同于clear()
36+
M5.Lcd.setCursor(0, 30); // Set the text cursor 0,30 position. 设置文本光标在(0,30)处
37+
M5.Lcd.printf("☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☔☕☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♈♉♊♋♌♍♎♏♐♑♒♓♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚇⚈⚉⚊⚋⚌⚍⚎⚏⚐⚑⚒⚓⚔⚕⚖⚗⚘⚙⚚⚛⚜⚝⚞⚟A⚠⚡⚢⚣⚤⚥⚦⚧⚨⚩⚪⚫⚬⚭⚮⚯B⚰⚱⚲⚳⚴⚵⚶⚷⚸⚹⚺⚻⚼⚽⚾⚿C⛀⛁⛂⛃⛄⛅⛆⛇⛈⛉⛊⛋⛌⛍⛎⛏D⛐⛑⛒⛓⛔⛕⛖⛗⛘⛙⛚⛛⛜⛝⛞⛟E⛠⛡⛢");
38+
delay(3000);
39+
40+
M5.Lcd.fillScreen(0);
41+
M5.Lcd.setCursor(0, 30);
42+
M5.Lcd.printf("⛣⛤⛥⛦⛧⛨⛩⛪⛫⛬⛭⛮⛯F⛰⛱⛲⛳⛴⛵⛶⛷⛸⛹⛺⛻⛼⛽⛾⛿✀✁✂✃✄✅✆✇✈✉✊✋✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟✠✡✢✣✤✥✦✧✨✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞❟❠❡❢❣❤❥❦❧❨❩❪❫❬❭❮❯❰❱❲❳❴❵❶❷❸❹❺❻❼❽❾❿➀➁➂➃➄➅➆➇➈➉➊➋➌➍➎➏➐➑➒➓➔➕➖➗➘➙➚➛➜➝➞➟A➠➡➢➣➤➥➦➧➨➩➪➫➬➭➮➯B➰➱➲➳➴➵➶➷➸➹➺➻➼➽➾➿");
43+
delay(3000);
44+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Please modify <m5stack path>/src/utility/In_eSPI_Setup.h, At the end of the file add "#define USE_M5_FONT_CREATOR"
2+
3+
if use PlatformIO, need add "board_build.partitions = no_ota.csv" in platformio.ini
4+
5+
if want get customize unicode, try use https://github.com/m5stack/FontCreator, create font file
6+
7+
if add "#define USE_M5_FONT_CREATOR" and want to use standard gfx font, need modify font file
8+
#ifdef USE_M5_FONT_CREATOR
9+
0, 0,
10+
#endif
11+
like:
12+
13+
``` cpp
14+
const GFXfont FreeMono12pt7b PROGMEM = {
15+
(uint8_t *)FreeMono12pt7bBitmaps,
16+
(GFXglyph *)FreeMono12pt7bGlyphs,
17+
0x20, 0x7E, 24,
18+
#ifdef USE_M5_FONT_CREATOR
19+
0, 0,
20+
#endif
21+
}
22+
```
23+
24+
25+
26+
27+
28+
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
29+
zh:
30+
如果编译过程中出现错误,请在<m5stack path>/src/utility/In_eSPI_Setup.h 中最后一行添加#define USE_M5_FONT_CREATOR
31+
32+
如果你使用platformIO,需要在platformio.ini中添加board_build.partitions = no_ota.csv
33+
34+
如果你想自定义unicode,请尝试使用https://github.com/m5stack/FontCreator 去创建相关字体文件
35+
36+
如果添加了“#define USE_M5_FONT_CREATOR”,并且想使用标准的gfx字体,需要修改CUF_24px.h文件
37+
38+
39+
```cpp
40+
#ifdef USE_M5_FONT_CREATOR
41+
#define _unicode_24px_H_
42+
const GFXfont FreeMono12pt7b PROGMEM = {
43+
(uint8_t *)FreeMono12pt7bBitmaps,
44+
(GFXglyph *)FreeMono12pt7bGlyphs,
45+
0x20, 0x7E, 24,
46+
};
47+
48+
#endif
49+
```
50+
51+
52+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core2 sample source code
5+
* 配套 M5Core2 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/core/core2
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/core2
8+
*
9+
* describe:Character library. 字库
10+
* date:2021/7/28
11+
*******************************************************************************
12+
13+
-----PLEASE SEE THE README----
14+
------请在使用前看README文件----*/
15+
16+
#include <M5Core2.h>
17+
#include "display_ch.h"
18+
#include "str.h"
19+
20+
DisplayCh displaych;
21+
void setup() {
22+
M5.begin(); // Init M5Stack. 初始化M5Stack
23+
displaych.loadHzk16(); //Load the Chinese character library (be sure to load before using the Chinese character library). 加载汉字库(务必在使用汉字库前加载)
24+
displaych.setTextColor(WHITE, BLACK); //Set the text color to white and the text background color to black (mandatory). 设置文字颜色为白色,文字背景颜色为黑色(必加)
25+
// Set text with red highlight color
26+
displaych.setHighlightColor(RED); //Set the text highlight color to red. 设置文字高亮颜色为红色
27+
displaych.setTextSize(1); //Set text size to 1. 设置字号大小为1 Set text size to 1(必加)
28+
}
29+
30+
void loop() {
31+
displaych.setCursor(0,0,1); //Set the cursor at (0,0) and the size to 1(mandatory). 将光标设置在(0,0)处,并设置字号为1(必加)
32+
displaych.writeHzk(AscStr); //Display the contents of AscStr here (which can be changed in str.h). 在此处显示AscStr中的内容(可在str.h中更改)
33+
delay(1000); //delay 1000ms. 延迟1000ms
34+
displaych.setCursor(0,45);
35+
displaych.writeHzk(GbkStr); //Display the contents of GbkStr here (which can be changed in str.h). 在此处显示GbkStr中的内容(可在str.h中更改)
36+
delay(1000);
37+
//Highlight the text. 高亮显示文本
38+
displaych.highlight(true); //Turn on highlight. 开启高亮显示
39+
displaych.setCursor(0,65);
40+
displaych.writeHzk(GbkStr);
41+
delay(1000);
42+
displaych.fillScreen(BLACK); //Fill the screen with black color, equivalent to empty the screen. 填充屏幕颜色为黑色,等效于清空屏幕
43+
displaych.highlight(false); //Turn off highlight. 关闭高亮显示
44+
delay(500);
45+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
HZK16 is the GB2312 Chinese encoding format font, so it is normal that GbkStr is displayed as garbled in the src.h file
2+
To display Chinese normally, notepad++ or other software (UTF-8 for Arduino IDE) should be used to open str.h with encoding GB2312
3+
Modify the content in GbkStr to replace it with the character you want to display
4+
5+
HZK16为GB2312中文编码格式字库, 故在 src.h 文件中 GbkStr 显示为乱码为正常现象
6+
若要正常显示中文应使用notepad++或其它软件(Arduino IDE 为UTF-8)使用编码GB2312打开str.h
7+
修改GbkStr里的内容即可更换为想要显示的字符

0 commit comments

Comments
 (0)