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