1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| import binascii import os import time
KEYS = [0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01]
def printPlay(textStr,line,background): rect_list = [] * 16 for i in range(16): rect_list.append([] * 16)
for text in textStr: gb2312 = text.encode('gb2312') hex_str = binascii.b2a_hex(gb2312) result = str(hex_str, encoding='utf-8')
area = eval('0x' + result[:2]) - 0xA0 index = eval('0x' + result[2:]) - 0xA0 offset = (94 * (area-1) + (index-1)) * 32
font_rect = None
with open("HZK16", "rb") as f: f.seek(offset) font_rect = f.read(32)
for k in range(len(font_rect) // 2): row_list = rect_list[k] for j in range(2): for i in range(8): asc = font_rect[k * 2 + j] flag = asc & KEYS[i] row_list.append(flag)
for row in rect_list: for i in row: if i: print(line, end=' ') else:
print(background, end=' ') print()
os.system('clear')
with open('display.txt', 'r') as file: li = [] for f in file.readlines(): f = f.rstrip('\n') if f == "": time.sleep(5) li.append(f) lineSign = '●'
backgroundSign = ' '
printPlay(f,lineSign,backgroundSign) time.sleep(0.01)
|