Skip to content

Commit

Permalink
Merge pull request #48 from Tinyu-Zhao/master
Browse files Browse the repository at this point in the history
add some Ex&explain
  • Loading branch information
Gitshaoxiang authored Aug 13, 2021
2 parents fcc5ec6 + 9474006 commit adb17dc
Show file tree
Hide file tree
Showing 54 changed files with 81,154 additions and 442 deletions.
76,868 changes: 76,868 additions & 0 deletions examples/Advanced/Display/Display_Unicode/CUF_24px.h

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions examples/Advanced/Display/Display_Unicode/Display_Unicode.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Core2 sample source code
* 配套 M5Core2 示例源代码
* Visit the website for more information:https://docs.m5stack.com/en/core/core2
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/core2
*
* describe:Display_Unicode. Unicode显示
* date:2021/7/23
*******************************************************************************
*/

/*---PLEASE SEE THE README----
------请在使用前看README文件----*/
#include <M5Core2.h>
#include "CUF_24px.h"

void setup()
{
M5.begin(); //Init M5Stack. 初始化M5Core2
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);
}
52 changes: 52 additions & 0 deletions examples/Advanced/Display/Display_Unicode/README.md
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
```



45 changes: 45 additions & 0 deletions examples/Advanced/Display/HZK16/HZK16.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Core2 sample source code
* 配套 M5Core2 示例源代码
* Visit the website for more information:https://docs.m5stack.com/en/core/core2
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/core2
*
* describe:Character library. 字库
* date:2021/7/28
*******************************************************************************
-----PLEASE SEE THE README----
------请在使用前看README文件----*/

#include <M5Core2.h>
#include "display_ch.h"
#include "str.h"

DisplayCh displaych;
void setup() {
M5.begin(); // Init M5Stack. 初始化M5Stack
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 the text highlight color to red. 设置文字高亮颜色为红色
displaych.setTextSize(1); //Set text size to 1. 设置字号大小为1 Set text size to 1(必加)
}

void loop() {
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);
}
7 changes: 7 additions & 0 deletions examples/Advanced/Display/HZK16/README.md
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里的内容即可更换为想要显示的字符
Loading

0 comments on commit adb17dc

Please sign in to comment.