Skip to content

Commit 57765e7

Browse files
authored
Merge pull request #256 from Tinyu-Zhao/master
add some Example&explain
2 parents 462a4da + d7c0e42 commit 57765e7

61 files changed

Lines changed: 2555 additions & 2048 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ https://docs.m5stack.com/#/en/api
2929

3030
## 4. H/W Reference
3131

32-
#### Pinout
33-
34-
*We have several kinds of M5Cores, There is [their difference in schematic](https://github.com/m5stack/M5-Schematic/blob/master/Core/hardware_difference_between_cores.md).*
35-
3632
**LCD & TF Card**
3733

3834
*LCD Resolution: 320x240*
@@ -41,7 +37,6 @@ https://docs.m5stack.com/#/en/api
4137
<tr><td>ESP32 Chip</td><td>GPIO23</td><td>GPIO19</td><td>GPIO18</td><td>GPIO14</td><td>GPIO27</td><td>GPIO33</td><td>GPIO32</td><td>GPIO4</td></tr>
4238
<tr><td>ILI9341</td><td>MOSI/MISO</td><td>/</td><td>CLK</td><td>CS</td><td>DC</td><td>RST</td><td>BL</td><td> </td></tr>
4339
<tr><td>TF Card</td><td>MOSI</td><td>MISO</td><td>CLK</td><td> </td><td> </td><td> </td><td> </td><td>CS</td></tr>
44-
4540
</table>
4641

4742
**Button & Speaker**
@@ -71,8 +66,6 @@ https://docs.m5stack.com/#/en/api
7166
* [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) - TFT library for the ESP8266 and ESP32 that supports different driver chips
7267

7368

74-
* [M5Widgets](https://github.com/Kongduino/M5Widgets) - Widgets for the M5Stack
75-
7669
* [M5StackSAM](https://github.com/tomsuch/M5StackSAM) - Simple Applications Menu Arduino Library for M5Stack
7770

7871
* [cfGUI](https://github.com/JF002/cfGUI) - A simple GUI library for M5Stack (ESP32)
@@ -123,18 +116,6 @@ https://docs.m5stack.com/#/en/api
123116

124117
* [M5Stack-Thermal-Camera](https://github.com/hkoffer/M5Stack-Thermal-Camera-) - M5Stack Thermal Camera with AMG8833 thermal sensor
125118

126-
* [M5Stack-3DPrintFiles](https://github.com/PartsandCircuits/M5Stack-3DPrintFiles) - Links to files for 3D printing custom case parts for the M5Stack
127-
128119
* [truetype2gfx](https://github.com/ropg/truetype2gfx) - Converting fonts from TrueType to Adafruit GFX
129120

130121
* [m5stack-onscreen-keyboard](https://github.com/yellowelise/m5stack-onscreen-keyboard) - Full size qwerty keyboard for M5Stack
131-
132-
#### Note:
133-
134-
* How to install USB driver for establishing serial port
135-
136-
https://docs.m5stack.com/#/en/related_documents/establish_serial_connection
137-
138-
* How to upgrade M5Stack Libary
139-
140-
https://docs.m5stack.com/#/en/related_documents/upgrade_m5stack_lib

examples/Advanced/Audio/PlayMP3FromSDToDAC/PlayMP3FromSDToDAC.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma mark - Depend ESP8266Audio and ESP8266_Spiram libraries
2-
/*
2+
/*
33
cd ~/Arduino/libraries
44
git clone https://github.com/earlephilhower/ESP8266Audio
55
git clone https://github.com/Gianbacchio/ESP8266_Spiram
@@ -23,9 +23,9 @@ void setup()
2323
{
2424
M5.begin();
2525
M5.Power.begin();
26-
WiFi.mode(WIFI_OFF);
26+
WiFi.mode(WIFI_OFF);
2727
delay(500);
28-
28+
2929
M5.Lcd.setTextFont(2);
3030
M5.Lcd.printf("Sample MP3 playback begins...\n");
3131
Serial.printf("Sample MP3 playback begins...\n");
File renamed without changes.
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 M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/core/gray
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
8+
*
9+
* describe:Display_Unicode. Unicode显示
10+
* date:2021/7/23
11+
*******************************************************************************
12+
13+
-----PLEASE SEE THE README----
14+
------请在使用前看README文件----*/
15+
#include <M5Stack.h>
16+
#include "CUF_24px.h"
17+
18+
void setup()
19+
{
20+
M5.begin(); //Init M5Stack. 初始化M5Stack
21+
M5.Power.begin(); //Init power 初始化电源模块
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: 35 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,46 @@
1-
/*
2-
在 src.h 文件中 GbkStr 显示为乱码为正常现象
3-
HZK16为GB2312中文编码格式字库, 需要显示中文建议使用notepad++或其它软件(Arduino IDE 为UTF-8)通过编码GB2312打开str.h
4-
即可修改为个人想要输出中文字符
5-
*/
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/core/gray
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
8+
*
9+
* describe:Character library. 字库
10+
* date:2021/7/28
11+
*******************************************************************************
12+
13+
-----PLEASE SEE THE README----
14+
------请在使用前看README文件----*/
615

716
#include <M5Stack.h>
817
#include "display_ch.h"
918
#include "str.h"
1019

1120
DisplayCh displaych;
1221
void setup() {
13-
14-
M5.begin();
15-
M5.Power.begin();
16-
displaych.loadHzk16();
17-
18-
displaych.setTextColor(WHITE, BLACK);
19-
22+
M5.begin(); //Init M5Stack. 初始化M5Stack
23+
M5.Power.begin(); //Init power 初始化电源模块
24+
displaych.loadHzk16(); //Load the Chinese character library (be sure to load before using the Chinese character library). 加载汉字库(务必在使用汉字库前加载)
25+
displaych.setTextColor(WHITE, BLACK); //Set the text color to white and the text background color to black (mandatory). 设置文字颜色为白色,文字背景颜色为黑色(必加)
2026
// Set text with red highlight color
21-
displaych.setHighlightColor(RED);
22-
23-
// Set text size to 1
24-
displaych.setTextSize(1);
25-
displaych.setCursor(0,0,1);
26-
displaych.writeHzk(AscStr);
27-
// Print some ASCII text on the screen
28-
delay(1000);
29-
// Highlight the text
30-
displaych.highlight(true);
31-
displaych.setCursor(0,32);
32-
displaych.writeHzk(AscStr);
33-
delay(1000);
34-
// Clear screen
35-
//M5.Lcd.clear();
36-
// Turn highlight off
37-
displaych.highlight(false);
38-
displaych.setCursor(0,70);
39-
// print some GBK text on the screen
40-
displaych.writeHzk(GbkStr);
41-
42-
delay(1000);
43-
displaych.highlight(true);
44-
displaych.setCursor(0,90);
45-
displaych.writeHzk(GbkStr);
46-
47-
delay(1000);
48-
displaych.fillScreen(BLACK);
49-
50-
// Set text size to 2
51-
displaych.setTextSize(2);
52-
displaych.setCursor(0,0);
53-
displaych.highlight(false);
54-
displaych.writeHzk(AscStr);
55-
delay(1000);
56-
displaych.highlight(true);
57-
displaych.setCursor(0,70);
58-
displaych.writeHzk(AscStr);
59-
delay(1000);
60-
61-
//displaych.clear();
62-
displaych.highlight(false);
63-
displaych.setCursor(0,145);
64-
displaych.writeHzk(GbkStr);
65-
delay(1000);
66-
displaych.highlight(true);
67-
displaych.setCursor(0,195);
68-
displaych.writeHzk(GbkStr);
69-
70-
27+
displaych.setHighlightColor(RED); //Set the text highlight color to red. 设置文字高亮颜色为红色
28+
displaych.setTextSize(1); //Set text size to 1. 设置字号大小为1 Set text size to 1(必加)
7129
}
7230

7331
void loop() {
74-
// put your main code here, to run repeatedly:
75-
76-
}
32+
displaych.setCursor(0,0,1); //Set the cursor at (0,0) and the size to 1(mandatory). 将光标设置在(0,0)处,并设置字号为1(必加)
33+
displaych.writeHzk(AscStr); //Display the contents of AscStr here (which can be changed in str.h). 在此处显示AscStr中的内容(可在str.h中更改)
34+
delay(1000); //delay 1000ms. 延迟1000ms
35+
displaych.setCursor(0,45);
36+
displaych.writeHzk(GbkStr); //Display the contents of GbkStr here (which can be changed in str.h). 在此处显示GbkStr中的内容(可在str.h中更改)
37+
delay(1000);
38+
//Highlight the text. 高亮显示文本
39+
displaych.highlight(true); //Turn on highlight. 开启高亮显示
40+
displaych.setCursor(0,65);
41+
displaych.writeHzk(GbkStr);
42+
delay(1000);
43+
displaych.fillScreen(BLACK); //Fill the screen with black color, equivalent to empty the screen. 填充屏幕颜色为黑色,等效于清空屏幕
44+
displaych.highlight(false); //Turn off highlight. 关闭高亮显示
45+
delay(500);
46+
}
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里的内容即可更换为想要显示的字符
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _STR_H_
22
#define _STR_H_
33

4-
char* AscStr="ASCII: \nABCDEFG1234567";
5-
char* GbkStr="²É¾Õ¶«ÀéÏÂ";
4+
char* AscStr="ASCII: ABCDEFG1234567";
5+
char* GbkStr="Tao yuanming:²É¾Õ¶«ÀéÏ ¤³¤ó¤Ë¤Á¤Ï";
66

77
#endif

examples/Advanced/Display/TFT_Ellipse/TFT_Ellipse.ino

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
/*
2-
Ellipse drawing example
3-
4-
This sketch does not use any fonts.
5-
*/
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/core/gray
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
8+
*
9+
* describe:Ellipse drawing. 椭圆绘制
10+
* date:2021/7/26
11+
*******************************************************************************/
612

713
#include <M5Stack.h>
814

915
void setup(void) {
10-
M5.begin();
11-
M5.Power.begin();
12-
// M5.Lcd.setRotation(1);
16+
M5.begin(); //Init M5Stack. 初始化M5Stack
17+
M5.Power.begin(); //Init power 初始化电源模块
1318
}
1419

1520
void loop() {
16-
17-
M5.Lcd.fillScreen(TFT_BLACK);
18-
19-
// Draw some random ellipses
21+
// Draw some random ellipses. 绘制一些随机形状的椭圆
2022
for (int i = 0; i < 40; i++)
2123
{
2224
int rx = random(60);
2325
int ry = random(60);
2426
int x = rx + random(320 - rx - rx);
2527
int y = ry + random(240 - ry - ry);
26-
M5.Lcd.fillEllipse(x, y, rx, ry, random(0xFFFF));
28+
M5.Lcd.fillEllipse(x, y, rx, ry, random(0xFFFF)); //At (x, y), draw a filled ellipse with random width and height of rx, ry with random color random (0xFFFF). 在(x,y)处以随机颜色random(0xFFFF),绘制一个随机宽高为rx,ry的填充椭圆
2729
}
2830

2931
delay(2000);
30-
M5.Lcd.fillScreen(TFT_BLACK);
32+
M5.Lcd.clear(); //清空屏幕
3133

3234
for (int i = 0; i < 40; i++)
3335
{
3436
int rx = random(60);
3537
int ry = random(60);
3638
int x = rx + random(320 - rx - rx);
3739
int y = ry + random(240 - ry - ry);
38-
M5.Lcd.drawEllipse(x, y, rx, ry, random(0xFFFF));
40+
M5.Lcd.drawEllipse(x, y, rx, ry, random(0xFFFF));//At (x, y), draw an elliptical wire frame with a random width and height of rx, ry in a random color (0xFFFF). 在(x,y)处以随机颜色random(0xFFFF),绘制一个随机宽高为rx,ry的椭圆线框
3941
}
4042

4143
delay(2000);

0 commit comments

Comments
 (0)