|
1 | | -#define USE_INTERNAL_HZK |
| 1 | +/* |
| 2 | + 在 src.h 文件中 GbkStr 显示为乱码为正常现象 |
| 3 | + HZK16为GB2312中文编码格式字库, 需要显示中文建议使用notepad++或其它软件(Arduino IDE 为UTF-8)通过编码GB2312打开str.h |
| 4 | + 即可修改为个人想要输出中文字符 |
| 5 | +*/ |
2 | 6 |
|
3 | 7 | #include <M5Stack.h> |
| 8 | +#include "display_ch.h" |
4 | 9 | #include "str.h" |
5 | 10 |
|
| 11 | +DisplayCh displaych; |
6 | 12 | void setup() { |
| 13 | + |
7 | 14 | 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 | + |
13 | 20 | // Set text with red highlight color |
14 | | - M5.Lcd.setHighlightColor(RED); |
| 21 | + displaych.setHighlightColor(RED); |
15 | 22 |
|
16 | 23 | // 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); |
19 | 27 | // Print some ASCII text on the screen |
20 | | - M5.Lcd.printf(AscStr); |
21 | 28 | delay(1000); |
22 | 29 | // 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); |
28 | 34 | // Clear screen |
29 | | - M5.Lcd.clear(); |
| 35 | + //M5.Lcd.clear(); |
30 | 36 | // Turn highlight off |
31 | | - M5.Lcd.highlight(false); |
32 | | - M5.Lcd.setCursor(0,10); |
| 37 | + displaych.highlight(false); |
| 38 | + displaych.setCursor(0,70); |
33 | 39 | // 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); |
39 | 41 |
|
40 | 42 | delay(1000); |
41 | | - M5.Lcd.clear(); |
| 43 | + displaych.highlight(true); |
| 44 | + displaych.setCursor(0,90); |
| 45 | + displaych.writeHzk(GbkStr); |
42 | 46 |
|
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); |
48 | 47 | 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); |
52 | 55 | 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); |
58 | 59 | delay(1000); |
59 | | - M5.Lcd.highlight(true); |
60 | | - M5.Lcd.setCursor(0,10); |
61 | | - M5.Lcd.printf(GbkStr); |
62 | 60 |
|
| 61 | + //displaych.clear(); |
| 62 | + displaych.highlight(false); |
| 63 | + displaych.setCursor(0,145); |
| 64 | + displaych.writeHzk(GbkStr); |
63 | 65 | delay(1000); |
| 66 | + displaych.highlight(true); |
| 67 | + displaych.setCursor(0,195); |
| 68 | + displaych.writeHzk(GbkStr); |
| 69 | + |
64 | 70 |
|
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); |
77 | 71 | } |
78 | 72 |
|
79 | 73 | void loop() { |
|
0 commit comments