Skip to content

Commit c7a68b3

Browse files
committed
add mkfont.py to LCD1602_BIG_DIGITS.
use mkfont.py to convert FONT from "small_16x2_display_big_digits__upir.ino".
1 parent 806837c commit c7a68b3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

‎lcd/LCD1602_BIG_DIGITS/mkfont.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'''
2+
3+
make big digit font from "small_16x2_display_big_digits__upir.ino".
4+
5+
'''
6+
7+
print('Make fonts from "small_16x2_display_big_digits__upir.ino"')
8+
9+
f = open('small_16x2_display_big_digits__upir.ino', 'rt')
10+
buf = f.readlines()
11+
f.close()
12+
13+
linecnt = len(buf)
14+
15+
fontname = ''
16+
17+
BIGFONT = {}
18+
19+
def mt(n):
20+
return (int(n)+2)%256
21+
22+
for i in range(linecnt):
23+
p = buf[i].find('_00[8] PROGMEM')
24+
if p>10:
25+
fontname = buf[i][11:p]
26+
fontdat = bytearray(64)
27+
fontdig = bytearray(20)
28+
for n in range(8):
29+
x = p
30+
for m in range(8):
31+
x = buf[i+n].find('B' ,x+6)
32+
s = '0'+buf[i+n][x:x+6]
33+
fontdat[n*8+m]=int(s, 2)
34+
35+
p = buf[i].find('_digits[10][4] = ')
36+
if p>4:
37+
if buf[i][5:p] == fontname:
38+
s = buf[i][p+len('_digits[10][4] = '):]
39+
s = s.replace('{','').replace('}','').replace(';','')
40+
d=s.split(',')
41+
for n in range(20):
42+
fontdig[n] = mt(d[n*2])*16+mt(d[n*2+1])
43+
BIGFONT[fontname] = [fontdat, fontdig]
44+
45+
fontname = ''
46+
47+
print('FONT number:', len(BIGFONT))
48+
print('BIGFONTS = {')
49+
x = list(BIGFONT.keys())
50+
for i in range(len(x)):
51+
print(" '{}':[{},{}],".format(x[i],bytes(BIGFONT[x[i]][0]),bytes(BIGFONT[x[i]][1])))
52+
print('}')
53+

0 commit comments

Comments
 (0)