Skip to content

Commit 86dc023

Browse files
committed
Add unit example, fix dispaly hzk16 bug
Add Env Add NCIR Add RFID Add USB Fix EXT_IO bug Fix Face bug
1 parent 682f3dd commit 86dc023

File tree

25 files changed

+3478
-62
lines changed

25 files changed

+3478
-62
lines changed

examples/Advanced/Display/HZK16/HZK16.ino

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,73 @@
1-
#define USE_INTERNAL_HZK
1+
/*
2+
在 src.h 文件中 GbkStr 显示为乱码为正常现象
3+
HZK16为GB2312中文编码格式字库, 需要显示中文建议使用notepad++或其它软件(Arduino IDE 为UTF-8)通过编码GB2312打开str.h
4+
即可修改为个人想要输出中文字符
5+
*/
26

37
#include <M5Stack.h>
8+
#include "display_ch.h"
49
#include "str.h"
510

11+
DisplayCh displaych;
612
void setup() {
13+
714
M5.begin();
8-
// Use HZK16 and ASC16 font set
9-
// NOTE: font file should be copied to your TF card.
10-
M5.Lcd.loadHzk16("/Fonts/HZK16","/Fonts/ASC16");
11-
// Set text with white foreground color and black background color
12-
M5.Lcd.setTextColor(WHITE, BLACK);
15+
16+
displaych.loadHzk16();
17+
18+
displaych.setTextColor(WHITE, BLACK);
19+
1320
// Set text with red highlight color
14-
M5.Lcd.setHighlightColor(RED);
21+
displaych.setHighlightColor(RED);
1522

1623
// Set text size to 1
17-
M5.Lcd.setTextSize(1);
18-
M5.Lcd.setCursor(0,10);
24+
displaych.setTextSize(1);
25+
displaych.setCursor(0,0,1);
26+
displaych.writeHzk(AscStr);
1927
// Print some ASCII text on the screen
20-
M5.Lcd.printf(AscStr);
2128
delay(1000);
2229
// Highlight the text
23-
M5.Lcd.highlight(true);
24-
M5.Lcd.setCursor(0,10);
25-
M5.Lcd.printf(AscStr);
26-
27-
delay(1000);
30+
displaych.highlight(true);
31+
displaych.setCursor(0,32);
32+
displaych.writeHzk(AscStr);
33+
delay(1000);
2834
// Clear screen
29-
M5.Lcd.clear();
35+
//M5.Lcd.clear();
3036
// Turn highlight off
31-
M5.Lcd.highlight(false);
32-
M5.Lcd.setCursor(0,10);
37+
displaych.highlight(false);
38+
displaych.setCursor(0,70);
3339
// print some GBK text on the screen
34-
M5.Lcd.printf(GbkStr);
35-
delay(1000);
36-
M5.Lcd.highlight(true);
37-
M5.Lcd.setCursor(0,10);
38-
M5.Lcd.printf(GbkStr);
40+
displaych.writeHzk(GbkStr);
3941

4042
delay(1000);
41-
M5.Lcd.clear();
43+
displaych.highlight(true);
44+
displaych.setCursor(0,90);
45+
displaych.writeHzk(GbkStr);
4246

43-
// Set text size to 2
44-
M5.Lcd.setTextSize(2);
45-
M5.Lcd.setCursor(0,10);
46-
M5.Lcd.highlight(false);
47-
M5.Lcd.printf(AscStr);
4847
delay(1000);
49-
M5.Lcd.highlight(true);
50-
M5.Lcd.setCursor(0,10);
51-
M5.Lcd.printf(AscStr);
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);
5255
delay(1000);
53-
54-
M5.Lcd.clear();
55-
M5.Lcd.highlight(false);
56-
M5.Lcd.setCursor(0,10);
57-
M5.Lcd.printf(GbkStr);
56+
displaych.highlight(true);
57+
displaych.setCursor(0,70);
58+
displaych.writeHzk(AscStr);
5859
delay(1000);
59-
M5.Lcd.highlight(true);
60-
M5.Lcd.setCursor(0,10);
61-
M5.Lcd.printf(GbkStr);
6260

61+
//displaych.clear();
62+
displaych.highlight(false);
63+
displaych.setCursor(0,145);
64+
displaych.writeHzk(GbkStr);
6365
delay(1000);
66+
displaych.highlight(true);
67+
displaych.setCursor(0,195);
68+
displaych.writeHzk(GbkStr);
69+
6470

65-
M5.Lcd.clear();
66-
M5.Lcd.highlight(false);
67-
68-
// Set text with non-transparent back color, BLACK as set at the beginning.
69-
M5.Lcd.setTransparentBgColor(false);
70-
M5.Lcd.setCursor(0,10);
71-
M5.Lcd.printf(GbkStr);
72-
73-
// Set text with transparent back color
74-
M5.Lcd.setTransparentBgColor(true);
75-
M5.Lcd.setCursor(0,130);
76-
M5.Lcd.printf(GbkStr);
7771
}
7872

7973
void loop() {

0 commit comments

Comments
 (0)