Last active
August 29, 2015 14:01
-
-
Save AndySze/af0413de45875df1476c to your computer and use it in GitHub Desktop.
这是一个完整的项目,下载两个文件的代码,就可以测试一下在Mini Panel下显示中文了。不过默认的汉字只有与Marlin固件相关的,如果想添加其它个性化汉字,可以参考详细教程: http://learn.makerlab.me/guides/9
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
/* | |
Fontname: -Firefly-Firefly New Sung-Medium-R-Normal--11-110-75-75-P-109-ISO10646-1 | |
Copyright: | |
Capital A Height: 9, '1' Height: 9 | |
Calculated Max Values w=11 h=11 x= 4 y= 6 dx=11 dy= 0 ascent=10 len=22 | |
Font Bounding box w=11 h=11 x= 0 y=-1 | |
Calculated Min Values x= 0 y=-1 dx= 0 dy= 0 | |
Pure Font ascent = 9 descent=-1 | |
X Font ascent = 9 descent=-1 | |
Max Font ascent =10 descent=-1 | |
Added By MakerLab.me for Chinese Support. | |
*/ | |
#include "utility/u8g.h" | |
const u8g_fntpgm_uint8_t chinese[3819] U8G_SECTION(".progmem.chinese") = { | |
0,11,11,0,255,9,1,207,3,158,32,255,255,10,255,9, | |
255,0,0,0,6,0,1,1,9,9,6,2,0,128,128,128, | |
128,128,128,0,0,128,5,3,3,6,0,6,216,72,144,6, | |
9,9,6,0,0,40,40,40,124,40,252,80,80,80,5,9, | |
9,6,0,0,32,112,168,160,112,40,168,112,32,6,10,10, | |
6,0,255,72,168,168,176,80,40,84,84,148,136,5,9,9, | |
6,0,0,32,80,80,80,96,168,144,144,104,2,3,3,6, | |
2,6,192,64,128,3,10,10,6,1,255,32,64,64,128,128, | |
128,128,64,64,32,3,10,10,6,1,255,128,64,64,32,32, | |
32,32,64,64,128,5,7,7,6,0,1,32,168,112,32,112, | |
168,32,5,7,7,6,0,1,32,32,32,248,32,32,32,2, | |
3,3,6,2,0,192,64,128,5,1,1,6,0,4,248,1, | |
2,2,6,2,0,128,128,5,10,10,6,0,255,8,8,16, | |
16,32,32,64,64,128,128,5,9,9,6,0,0,32,80,136, | |
136,136,136,136,80,32,3,9,9,6,1,0,64,192,64,64, | |
64,64,64,64,224,5,9,9,6,0,0,112,136,136,8,16, | |
32,64,136,248,5,9,9,6,0,0,112,136,8,8,48,8, | |
8,136,112,5,9,9,6,0,0,16,48,48,80,80,144,248, | |
16,56,5,9,9,6,0,0,120,64,64,64,112,8,8,136, | |
112,5,9,9,6,0,0,112,136,128,128,240,136,136,136,112, | |
5,9,9,6,0,0,248,136,8,16,16,32,32,32,32,5, | |
9,9,6,0,0,112,136,136,136,112,136,136,136,112,5,9, | |
9,6,0,0,112,136,136,136,120,8,8,136,112,1,7,7, | |
6,2,1,128,128,0,0,0,128,128,2,7,7,6,2,0, | |
192,192,0,0,192,64,128,5,10,10,6,0,255,8,16,32, | |
64,128,128,64,32,16,8,5,3,3,6,0,2,248,0,248, | |
5,10,10,6,0,255,128,64,32,16,8,8,16,32,64,128, | |
5,9,9,6,0,0,112,136,136,16,32,32,32,0,32,6, | |
10,10,6,0,255,48,72,180,212,212,212,212,168,128,120,5, | |
9,9,6,0,0,32,32,32,80,80,112,136,136,136,5,9, | |
9,6,0,0,240,136,136,136,240,136,136,136,240,5,9,9, | |
6,0,0,48,72,136,128,128,128,128,72,48,5,9,9,6, | |
0,0,224,144,136,136,136,136,136,144,224,5,9,9,6,0, | |
0,248,128,128,128,240,128,128,128,248,5,9,9,6,0,0, | |
248,128,128,128,240,128,128,128,128,5,9,9,6,0,0,48, | |
72,128,128,128,152,136,72,48,5,9,9,6,0,0,136,136, | |
136,136,248,136,136,136,136,3,9,9,6,1,0,224,64,64, | |
64,64,64,64,64,224,5,9,9,6,0,0,56,16,16,16, | |
16,16,16,144,96,5,9,9,6,0,0,136,136,144,160,224, | |
144,144,136,136,5,9,9,6,0,0,224,64,64,64,64,64, | |
64,72,248,5,9,9,6,0,0,136,136,216,216,168,168,168, | |
136,136,5,9,9,6,0,0,136,200,200,168,168,168,152,152, | |
136,5,9,9,6,0,0,112,136,136,136,136,136,136,136,112, | |
5,9,9,6,0,0,240,72,72,72,112,64,64,64,224,5, | |
9,9,6,0,0,112,136,136,136,136,232,152,112,8,5,9, | |
9,6,0,0,240,136,136,136,240,160,144,136,136,5,9,9, | |
6,0,0,112,136,136,128,112,8,136,136,112,5,9,9,6, | |
0,0,248,168,32,32,32,32,32,32,112,5,9,9,6,0, | |
0,136,136,136,136,136,136,136,136,112,5,9,9,6,0,0, | |
136,136,136,80,80,80,32,32,32,5,9,9,6,0,0,168, | |
168,168,168,248,80,80,80,80,5,9,9,6,0,0,136,136, | |
80,80,32,80,80,136,136,5,9,9,6,0,0,136,136,80, | |
80,32,32,32,32,32,5,9,9,6,0,0,248,136,16,16, | |
32,32,64,136,248,3,10,10,6,2,255,224,128,128,128,128, | |
128,128,128,128,224,5,10,10,6,0,255,128,128,64,64,32, | |
32,16,16,8,8,3,10,10,6,1,255,224,32,32,32,32, | |
32,32,32,32,224,5,3,3,6,0,6,32,80,136,5,1, | |
1,6,0,255,248,3,3,3,6,1,6,192,64,32,5,6, | |
6,6,0,0,224,16,112,144,144,104,5,9,9,6,0,0, | |
128,128,128,240,136,136,136,200,176,5,6,6,6,0,0,112, | |
136,128,128,136,112,5,9,9,6,0,0,8,8,8,120,136, | |
136,136,152,104,5,6,6,6,0,0,112,136,248,128,136,112, | |
5,9,9,6,0,0,48,72,64,240,64,64,64,64,224,5, | |
7,7,6,0,255,104,144,144,96,144,136,112,5,9,9,6, | |
0,0,128,128,128,176,200,136,136,136,136,3,9,9,6,1, | |
0,64,0,0,192,64,64,64,64,224,4,10,10,6,0,255, | |
16,0,0,48,16,16,16,16,144,96,5,9,9,6,0,0, | |
128,128,136,144,160,192,160,144,136,3,9,9,6,1,0,192, | |
64,64,64,64,64,64,64,224,5,6,6,6,0,0,208,168, | |
168,168,168,168,5,6,6,6,0,0,176,72,72,72,72,72, | |
5,6,6,6,0,0,112,136,136,136,136,112,5,7,7,6, | |
0,255,240,136,136,240,128,128,128,5,7,7,6,0,255,120, | |
136,136,136,120,8,8,5,6,6,6,0,0,208,104,64,64, | |
64,224,5,6,6,6,0,0,112,136,96,16,136,112,5,8, | |
8,6,0,0,64,64,240,64,64,64,72,48,5,6,6,6, | |
0,0,136,136,136,136,152,104,5,6,6,6,0,0,136,136, | |
80,80,32,32,5,6,6,6,0,0,168,168,168,80,80,80, | |
5,6,6,6,0,0,136,80,32,32,80,136,4,7,7,6, | |
1,255,144,144,80,80,32,32,192,5,6,6,6,0,0,248, | |
136,16,32,72,248,3,10,10,6,1,255,32,64,64,64,64, | |
128,64,64,64,32,1,11,11,6,2,255,128,128,128,128,128, | |
128,128,128,128,128,128,3,10,10,6,1,255,128,64,64,64, | |
64,32,64,64,64,128,4,2,2,6,1,4,80,160,10,10, | |
20,11,0,255,48,64,72,64,133,64,121,64,73,64,73,64, | |
89,64,64,64,68,64,61,192,10,10,20,11,0,255,4,0, | |
255,192,144,64,31,0,49,0,78,0,17,0,255,192,33,0, | |
63,0,9,10,20,11,1,255,8,0,255,128,160,128,24,0, | |
72,0,40,0,255,128,8,0,54,0,193,128,11,10,20,11, | |
0,255,113,0,99,0,164,192,175,128,240,0,18,64,89,128, | |
148,128,17,0,47,224,9,10,20,11,1,255,8,0,255,128, | |
128,128,127,0,34,0,125,0,8,0,127,0,8,0,255,128, | |
9,10,20,11,1,255,8,0,8,0,255,128,136,128,136,128, | |
255,128,136,128,8,0,8,0,8,0,10,10,20,11,0,255, | |
8,0,4,0,255,192,17,0,17,0,10,0,4,0,10,0, | |
49,192,192,128,9,10,20,11,1,255,8,0,255,128,8,0, | |
8,0,127,0,34,0,20,0,8,0,54,0,193,128,10,10, | |
20,11,0,255,33,0,39,192,241,0,47,192,48,128,111,192, | |
168,128,36,128,32,128,99,128,10,10,20,11,0,255,69,0, | |
47,192,9,0,25,0,47,192,41,0,207,192,73,0,73,0, | |
79,192,9,10,20,11,1,255,63,0,82,0,140,0,50,0, | |
193,128,127,0,73,0,127,0,73,0,127,0,10,10,20,11, | |
0,255,39,192,33,0,249,0,33,0,57,0,225,0,33,0, | |
41,0,231,0,66,0,10,10,20,11,0,255,123,192,66,64, | |
66,64,122,64,66,64,74,64,82,64,226,192,66,0,2,0, | |
9,10,20,11,1,255,16,0,255,128,16,0,47,128,97,0, | |
162,0,63,128,34,0,34,0,46,0,10,10,20,11,0,255, | |
97,0,87,192,65,64,247,192,81,0,83,192,86,64,91,192, | |
82,64,67,192,9,10,20,11,1,255,8,0,8,0,15,0, | |
8,0,255,128,8,0,12,0,10,0,9,0,8,0,9,10, | |
20,11,1,255,255,0,1,0,1,0,65,0,127,0,64,0, | |
64,0,64,128,64,128,63,128,10,10,20,11,0,255,33,192, | |
38,0,127,192,34,0,46,192,234,64,46,192,42,64,47,192, | |
104,64,9,10,20,11,1,255,48,0,8,0,8,0,8,0, | |
8,0,8,0,20,0,34,0,65,0,128,128,10,10,20,11, | |
1,255,69,0,68,0,255,128,72,0,105,0,205,0,86,0, | |
82,0,69,0,200,192,9,10,20,11,1,255,8,0,73,0, | |
73,0,73,0,127,0,8,0,136,128,136,128,136,128,255,128, | |
9,10,20,11,1,255,16,0,9,0,255,128,8,0,8,0, | |
127,0,8,0,8,0,9,0,255,128,10,10,20,11,0,255, | |
255,192,18,0,3,128,124,0,37,0,36,64,127,192,22,0, | |
37,128,68,64,9,10,20,11,1,255,34,0,20,0,127,0, | |
73,0,127,0,73,0,127,0,8,0,255,128,8,0,7,10, | |
10,11,2,255,48,32,254,130,254,130,254,130,254,130,10,10, | |
20,11,0,255,114,0,2,0,7,192,250,64,34,64,34,64, | |
66,64,74,64,252,64,9,128,9,10,20,11,1,255,255,128, | |
34,0,34,0,34,0,255,128,34,0,34,0,34,0,66,0, | |
130,0,10,10,20,11,0,255,33,0,34,0,252,64,87,192, | |
80,0,87,192,84,64,36,64,87,192,148,64,9,10,20,11, | |
1,255,34,0,20,0,127,0,8,0,8,0,255,128,8,0, | |
20,0,34,0,193,128,9,9,18,11,1,0,79,128,160,128, | |
132,128,190,128,140,128,148,128,164,128,196,128,129,128,10,10, | |
20,11,0,255,4,0,39,128,36,0,255,192,4,0,20,0, | |
36,128,65,0,6,0,120,0,10,10,20,11,0,255,68,128, | |
36,128,15,192,4,128,228,128,47,192,36,128,40,128,80,0, | |
143,192,11,10,20,11,0,255,119,192,84,0,86,0,165,128, | |
116,128,21,128,53,64,212,64,20,0,23,224,9,10,20,11, | |
1,255,255,128,128,128,190,128,162,128,162,128,190,128,162,128, | |
128,128,255,128,128,128,10,10,20,11,0,255,127,192,68,0, | |
95,128,80,128,95,128,80,128,95,128,85,0,164,128,204,64, | |
9,10,20,11,1,255,8,0,15,128,8,0,127,0,66,0, | |
66,0,126,0,0,0,144,128,18,0,10,10,20,11,1,255, | |
143,0,73,0,9,0,193,192,95,0,73,0,70,0,66,0, | |
77,0,16,192,10,10,20,11,0,255,4,0,127,192,64,64, | |
63,128,4,0,36,0,39,128,36,0,84,0,143,192,10,10, | |
20,11,0,255,119,192,18,0,39,192,157,64,117,64,37,64, | |
37,64,38,0,34,64,44,0,10,10,20,11,0,255,34,0, | |
250,0,39,128,50,128,230,128,35,192,100,64,18,128,73,64, | |
137,64,10,10,20,11,0,255,231,192,164,128,171,0,196,192, | |
169,0,175,192,165,0,239,192,129,0,129,0,10,10,20,11, | |
0,255,79,128,40,128,143,128,88,128,47,128,192,0,95,192, | |
85,64,85,64,127,192,10,10,20,11,0,255,8,0,255,128, | |
136,128,255,128,136,128,255,128,136,128,8,0,8,64,7,192, | |
10,10,20,11,0,255,95,192,49,0,151,192,84,64,55,192, | |
52,64,215,192,81,0,85,128,107,64,10,10,20,11,1,255, | |
66,0,95,128,234,0,70,0,77,192,217,0,73,0,73,0, | |
73,0,17,0,10,10,20,11,0,255,20,0,84,0,87,192, | |
84,128,92,128,82,128,114,128,209,0,18,128,20,64,10,10, | |
20,11,0,255,26,0,227,192,36,64,250,128,39,0,49,192, | |
110,64,162,128,33,0,46,0,10,10,20,11,0,255,1,0, | |
241,0,71,192,165,64,253,64,39,192,53,64,229,64,39,192, | |
36,64,10,10,20,11,0,255,130,0,95,192,2,0,15,128, | |
234,128,47,128,38,0,42,128,82,64,143,192,10,10,20,11, | |
0,255,4,0,127,192,73,0,127,192,73,0,95,128,73,0, | |
70,0,137,0,176,192,9,10,20,11,1,255,36,0,20,0, | |
68,0,36,0,4,0,255,128,8,0,20,0,34,0,193,128, | |
10,10,20,11,0,255,4,0,127,192,66,0,127,192,66,0, | |
75,0,82,128,82,128,162,64,162,64,10,10,20,11,0,255, | |
127,128,64,128,82,128,74,128,68,128,68,128,74,128,82,128, | |
64,128,128,64,9,9,18,11,1,255,127,128,127,128,64,0, | |
123,128,106,128,72,128,138,128,236,128,25,128,10,10,20,11, | |
0,255,34,0,47,192,248,64,37,0,40,128,112,64,175,128, | |
34,0,162,0,95,192,10,10,20,11,0,255,80,64,125,64, | |
145,64,127,64,17,64,125,64,85,64,84,64,92,64,17,192, | |
10,10,20,11,0,255,63,128,32,128,63,128,32,128,255,192, | |
72,0,123,192,74,64,253,128,10,64,9,10,20,11,1,255, | |
8,0,8,0,255,128,8,0,8,0,8,0,20,0,34,0, | |
65,0,128,128,10,10,20,11,0,255,4,0,4,0,4,0, | |
21,0,36,128,68,64,132,64,36,0,28,0,8,0,9,10, | |
20,11,1,255,255,128,136,128,136,128,255,128,136,128,136,128, | |
148,128,162,128,255,128,128,128,10,10,20,11,1,255,162,0, | |
52,0,251,192,180,128,4,128,243,0,83,0,113,0,34,128, | |
204,0,10,10,20,11,0,255,34,0,63,192,32,0,111,128, | |
160,0,47,128,32,0,47,128,40,128,47,128,10,10,20,11, | |
0,255,8,0,63,128,32,128,63,128,32,128,63,128,32,128, | |
63,128,84,128,159,64,9,10,20,11,1,255,127,0,73,0, | |
127,0,73,0,127,0,34,0,83,0,146,128,34,0,66,0, | |
10,10,20,11,0,255,255,192,8,0,127,128,82,128,94,128, | |
82,128,94,128,82,128,127,128,64,128,9,10,20,11,1,255, | |
127,0,8,0,8,0,255,128,20,0,20,0,20,0,36,128, | |
68,128,131,128,10,10,20,11,0,255,32,0,35,192,250,64, | |
42,64,42,64,42,64,42,64,42,64,75,192,146,64,10,11, | |
22,11,0,255,32,0,63,192,32,0,95,128,148,128,18,128, | |
255,192,36,128,63,192,0,128,3,0,10,10,20,11,0,255, | |
79,128,32,0,0,0,31,192,226,0,36,128,41,192,62,64, | |
80,0,143,192,10,10,20,11,0,255,47,128,40,128,40,128, | |
111,128,162,0,63,192,34,0,39,0,42,128,50,64,9,10, | |
20,11,1,255,34,0,127,0,17,0,255,128,42,0,209,128, | |
36,0,25,0,2,0,124,0,9,10,20,11,1,255,35,0, | |
250,128,255,128,66,0,250,128,171,0,249,0,41,0,243,128, | |
36,0,10,10,20,11,0,255,34,0,47,192,178,0,165,0, | |
169,64,53,128,37,0,35,0,36,128,40,64,9,10,20,11, | |
1,255,63,128,97,0,191,0,33,0,63,0,16,0,63,0, | |
82,0,140,0,115,128,10,10,20,11,0,255,127,192,64,0, | |
64,0,64,0,64,0,64,0,64,0,64,0,128,0,128,0, | |
10,10,20,11,0,255,124,64,69,64,125,64,81,64,125,64, | |
85,64,85,64,84,64,156,64,144,192,10,10,20,11,0,255, | |
35,192,250,0,82,0,251,192,34,128,250,128,34,128,114,128, | |
172,128,96,128,9,10,20,11,1,255,95,128,18,128,31,128, | |
210,128,87,128,87,128,117,128,87,128,32,128,1,128,10,10, | |
20,11,0,255,255,0,85,192,125,64,88,128,149,64,127,192, | |
4,0,39,128,36,0,255,192,11,10,20,11,0,255,251,192, | |
82,0,123,224,36,128,244,128,63,0,32,128,63,128,32,128, | |
63,128,10,10,20,11,0,255,34,0,47,192,32,0,103,128, | |
164,128,47,192,48,64,47,128,33,0,35,0,9,10,20,11, | |
1,255,82,0,186,128,182,0,223,128,146,0,211,0,30,128, | |
90,0,146,0,31,128,10,11,22,11,1,255,66,0,143,128, | |
162,0,191,192,200,128,134,0,170,0,223,192,20,0,231,128, | |
24,0,10,10,20,11,0,255,4,0,4,0,4,0,36,0, | |
39,128,36,0,36,0,36,0,36,128,255,192,9,10,20,11, | |
1,255,8,0,8,0,255,128,136,128,136,128,255,128,136,128, | |
136,128,255,128,128,128,10,10,20,11,0,255,18,0,18,0, | |
47,192,98,0,162,0,39,0,42,128,50,64,34,0,34,0, | |
10,10,20,11,1,255,239,128,168,128,175,128,234,128,170,0, | |
239,192,170,0,233,0,168,192,0,64,255,255,255,255,255,255, | |
255,255,255,255,6,10,10,11,3,0,32,16,0,0,120,136, | |
136,136,136,124,6,9,9,11,2,1,32,0,0,112,136,136, | |
136,136,124,255,255,255,255,255,255,5,10,10,11,3,0,64, | |
48,0,0,112,136,248,128,136,112,5,10,10,11,3,0,16, | |
32,0,0,112,136,248,128,136,112,5,9,9,11,3,1,112, | |
8,0,112,136,248,128,136,112,255,3,10,10,11,4,0,128, | |
64,0,0,192,64,64,64,64,224,3,10,10,11,4,0,64, | |
128,0,0,192,64,64,64,64,224,255,255,255,255,5,9,9, | |
11,3,0,64,32,0,112,136,136,136,136,112,5,10,10,11, | |
3,0,16,32,0,0,112,136,136,136,136,112,255,255,255,8, | |
7,7,11,1,1,24,24,0,255,0,24,24,255,6,9,9, | |
11,2,0,32,16,0,204,68,68,68,76,52,11,3,6,11, | |
0,3,0,128,255,224,0,192,3,11,11,11,4,255,64,64, | |
224,64,64,64,64,64,64,64,64,6,9,9,11,2,0,68, | |
0,0,204,68,68,68,76,52,255,255,255}; |
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
/* | |
HelloWorld.pde | |
"Hello World!" example code. | |
>>> Before compiling: Please remove comment from the constructor of the | |
>>> connected graphics display (see below). | |
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ | |
*/ | |
#include "U8glib.h" | |
#include "font.h" | |
// setup u8g object, please remove comment from one of the following constructor calls | |
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device | |
U8GLIB_MINI12864 u8g(45,47);//这是Mega Controller与Mini Panel的连接接口,使用的硬件SPI,45为LCD上的CS,47为LCD的A0 | |
void draw(void) { | |
// graphic commands to redraw the complete screen should be placed here | |
u8g.setFont(chinese); | |
u8g.drawStr( 0, 12, "MakerLab.me"); | |
u8g.drawStr( 0, 28, "\x7f\x80\x81\x82\x83 So Cool!");//创客实验室 So Cool! | |
} | |
void setup(void) { | |
// flip screen, if required | |
// u8g.setRot180(); | |
// set SPI backup if required | |
//u8g.setHardwareBackup(u8g_backup_avr_spi); | |
pinMode(44,OUTPUT); | |
digitalWrite(44,HIGH);//这是Mini Panel的背光IO口,打开背光 | |
//delay(1000); | |
// assign default color value | |
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) | |
u8g.setColorIndex(255); // white | |
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) | |
u8g.setColorIndex(3); // max intensity | |
else if ( u8g.getMode() == U8G_MODE_BW ) | |
u8g.setColorIndex(1); // pixel on | |
//u8g.setContrast(190); | |
} | |
void loop(void) { | |
// picture loop | |
u8g.firstPage(); | |
do { | |
draw(); | |
} while( u8g.nextPage() ); | |
// rebuild the picture after some delay | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment