wearable_sign_05.py
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
[[Required-Software-and-Data]]
#code(Python){{
# coding: utf-8
import smbus
import time
import traceback
import struct
import threading
import copy
class Binary_file_reader:
binary_data=None
def read_file(self,path):
self.binary_data=None
try:
with open(path,'rb') as file:
while True:
chunk = file.read(1024)
if not chunk:
break
if not self.binary_data:
self.binary_data=chunk
else:
self.binary_data=self.binary_data...
file.close()
except Exception as e:
print(traceback.format_exc())
def get_binary(self):
return self.binary_data
def dump_binary(self,frm, length):
if not self.binary_data:
print("no binary.")
adr=frm
s=""
c=""
size=len(self.binary_data)
cs=[' ']
if size<length:
length=size
eadr=adr+length
while adr<eadr:
a=adr
if a<size:
s='{:08x}'.format(a)
else:
s=' '
print(s,end='')
sline=''
cline=''
for i in range(16):
if a<size:
d=self.binary_data[a] & 0xff
sline=sline+'{:02x}'.format(d)+' '
if d<0x20 or d>0xde or (d>0x73 and d<...
d=0x2e
cs=chr(d);
cline=cline+cs+' '
else:
s=' '
c=' '
a=a+1
print(' '+sline+' '+cline)
adr=a
def dump_binary_all(self):
self.dump_binary(0,len(self.binary_data))
#b_reader=Binary_file_reader()
#b_reader.read_file('ShinonomeMin_16.pdb')
#b_reader.dump_binary(0,1024)
class Font_accessor:
font_array=[]
base=0
one_font_size=16
font_width_byte=2
asciicode=[
0x2121, 0x2121,0x2121,0x2121, #//0x00, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x04, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x08, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x0C, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x10, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x14, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x18, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x1C, 0x...
0x2121, 0x212A,0x2148,0x2174, #//0x20, 0x...
0x2170, 0x2173,0x2175,0x212D, #//0x24, 0x...
0x214A, 0x214B,0x2176,0x215C, #//0x28, 0x...
0x2124, 0x215D,0x2125,0x213F, #//0x2C, 0x...
0x2330, 0x2331,0x2332,0x2333, #//0x30, 0x...
0x2334, 0x2335,0x2336,0x2337, #//0x34, 0x...
0x2338, 0x2339,0x2127,0x2128, #//0x38, 0x...
0x2163, 0x2161,0x2164,0x2129, #//0x3C, 0x...
0x2177, 0x2341,0x2342,0x2343, #//0x40, 0x...
0x2344, 0x2345,0x2346,0x2347, #//0x44, 0x...
0x2348, 0x2349,0x234A,0x234B, #//0x48, 0x...
0x234C, 0x234D,0x234E,0x234F, #//0x4C, 0x...
0x2350, 0x2351,0x2352,0x2353, #//0x50, 0x...
0x2354, 0x2355,0x2356,0x2357, #//0x54, 0x...
0x2358, 0x2359,0x235A,0x214E, #//0x58, 0x...
0x2140, 0x214F,0x2130,0x2132, #//0x5C, 0x...
0x212D, 0x2361,0x2362,0x2363, #//0x60, 0x...
0x2364, 0x2365,0x2366,0x2367, #//0x64, 0x...
0x2368, 0x2369,0x236A,0x236B, #//0x68, 0x...
0x236C, 0x236D,0x236E,0x236F, #//0x6C, 0x...
0x2370, 0x2371,0x2372,0x2373, #//0x70, 0x...
0x2374, 0x2375,0x2376,0x2377, #//0x74, 0x...
0x2378, 0x2379,0x237A,0x2150, #//0x78, 0x...
0x2143, 0x2151,0x2141,0x2121 # //0x7C, 0x6...
]
ascii_font=[0 for x in range(256*8)]
ascii_font_data=[
#//
#// use https://github.com/alexmac/alc...
#//
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0...
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0...
0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0...
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0...
0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x92, 0...
0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0...
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0...
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0...
0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0...
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0...
0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0...
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0...
0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0...
0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0...
0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0...
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0...
0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0...
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0...
0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0...
0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0...
0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0...
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0...
0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0...
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0...
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0...
0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0...
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0...
0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0...
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0...
0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0...
0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0...
0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0...
0x18, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0...
0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0...
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0...
0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0...
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0...
0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0...
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0...
0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0...
0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0...
0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0...
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0...
0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0...
0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0...
0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0...
0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0...
0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0...
0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0...
0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0...
0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0...
0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0...
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0...
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0...
0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0...
0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0...
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0...
0x3c, 0x66, 0x0c, 0x18, 0x18, 0x00, 0...
0x7c, 0xc6, 0xde, 0xde, 0xdc, 0xc0, 0...
0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0...
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0...
0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0...
0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0...
0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0...
0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0...
0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0...
0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0...
0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0...
0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0...
0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0...
0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0...
0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0...
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0...
0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0...
0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0...
0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0x7c, 0...
0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0...
0x7c, 0xc6, 0xe0, 0x78, 0x0e, 0xc6, 0...
0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0...
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0...
0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0...
0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0...
0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0...
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0...
0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0...
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0...
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0...
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0...
0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0...
0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0...
0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0...
0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0x38, 0x6c, 0x64, 0xf0, 0x60, 0x60, 0...
0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0...
0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0...
0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x0c, 0x00, 0x1c, 0x0c, 0x0c, 0xcc, 0...
0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0...
0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0...
0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0...
0x00, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0...
0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0...
0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0...
0x00, 0x00, 0x7c, 0xc0, 0x70, 0x1c, 0...
0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0...
0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0...
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0...
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0...
0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0...
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0...
0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0...
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0...
0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0...
0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0c, 0...
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0x7e, 0x81, 0x3c, 0x06, 0x3e, 0x66, 0...
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x00, 0x00, 0x7c, 0xc6, 0xc0, 0x78, 0...
0x7e, 0x81, 0x3c, 0x66, 0x7e, 0x60, 0...
0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0...
0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0xc6, 0x10, 0x7c, 0xc6, 0xfe, 0xc6, 0...
0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0...
0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0...
0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0...
0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0...
0x78, 0x84, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0...
0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0...
0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0...
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0...
0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0...
0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x30, 0...
0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0...
0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0...
0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xf8, 0x00, 0xb8, 0xcc, 0xcc, 0...
0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0...
0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0...
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0...
0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0...
0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0...
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0...
0xc6, 0xcc, 0xd8, 0x36, 0x6b, 0xc2, 0...
0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6d, 0...
0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0...
0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0...
0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0...
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0...
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0...
0xdb, 0xf6, 0xdb, 0x6f, 0xdb, 0x7e, 0...
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0...
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0...
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0...
0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0...
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0...
0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0...
0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0...
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0...
0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0...
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0...
0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0...
0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0...
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0...
0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0...
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0...
0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0...
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0...
0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0...
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0...
0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0...
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0...
0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0...
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0...
0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0...
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0...
0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0...
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0...
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0...
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0...
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0...
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0...
0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0...
0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0...
0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0...
0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0...
0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0...
0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0...
0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0...
0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0...
0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0...
0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0...
0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0...
0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0...
0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0...
0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0...
0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0...
0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0...
0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0...
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0...
0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0...
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0...
0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0...
0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0...
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0...
0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0...
0x58, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0...
0x70, 0x98, 0x30, 0x60, 0xf8, 0x00, 0...
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
]
def __init__(self,font_data, font_size, base):
self.font_array=font_data
self.one_font_size=font_size
self.base=base
self.font_width_byte=int((self.one_font_size+7)/8)
for i in range(len(self.ascii_font)):
self.ascii_font[i]=self.ascii_font_data[i]
def utf_8_str_to_jis_barray(self,x):
#print('utf_8_str_to_jis_barray x='+x)
rtn=[]
lx=len(x)
for i in range(lx):
c=x[i]
#print('c='+c)
j=self.utf_8_to_jis_char(c)
#print('j={:x}'.format(j))
rtn.append(j)
return rtn
def utf_8_to_jis_char(self,x):
#print('utf_8_to_jis_char x='+x)
w=x.encode('shift_jis')
jw=self.sjis_to_jis(w)
return jw
def sjis_to_jis_string(self,x):
xlen=len(x)
rtn=''
for i in range(xlen):
w=self.sjis_to_jis(x[i])
rtn=rtn+w
return rtn
def sjis_to_jis(self, x):
#print('sjis_to_jis x=',end='')
#print(x)
if len(x)==2:
wx=struct.unpack('BB',x)
c1=wx[0]
c2=wx[1]
else:
wx=struct.unpack('B',x)
c1=0
c2=wx[0]
#print(wx)
##c1=(x >> 8) &0x00ff
##c2=x & 0x00ff
#print('c1={:x}'.format(c1))
#print('c2={:x}'.format(c2))
if c1==0:
c2=c2
else:
if c1 >=0xe0:
c1=c1-0x40
if c2 >=0x80:
c2=c2-1
if c2 >=0x9e:
c1=(c1-0x70)*2
c2=c2-0x7d
else:
c1=((c1-0x70)*2)-1
c2=c2-0x1f
rtn=(c1<<8)|c2
#print('rtn=',end='')
#print(rtn)
return rtn
def get_JIS_string(self,x):
tmp=self.get_SJIS_string(x)
if tmp==None:
return None
rtn=[' ' for i in range(len(tmp))]
bl=len(tmp)
for i in range(bl):
#print('tmp[i]='+tmp[i])
#print('tmp[i]={:0x}'.format(ord(tmp[i])))
cx=ord(tmp[i]) & 0x0000ffff
if cx>0x2100:
rtn[i]=self.sjis_to_jis(tmp[i])
else:
rtn[i]=tmp[i]
return rtn
def get_font_jis(self,code):
hb=(0xff00 & code)>>8
lb=0x00ff & code
if code <0x2100:
return self.get_ascii_font(code)
fn=((hb-0x21)*(0x7f-0x21))+lb-0x21
pos=self.base+(fn*self.one_font_size*self.font_wi...
return self.get_font_raw(pos)
def get_ascii_font(self,c):
# Standard ASCII 5x7 font
# Draw a character
rtn=[0 for i in range(16)]
offset=6
#print('get_ascii_font c={:x}'.format(c))
for i in range(8):
rtn[offset+i]=self.ascii_font[8*c+i]
#print(rtn)
return rtn
def get_font_raw(self,pos):
if self.font_array==None:
return None
rtn=[0 for i in range(self.one_font_size*self.fon...
if pos+self.one_font_size*self.font_width_byte > ...
print("exceeded the max font range.")
return None
for i in range(self.one_font_size*self.font_width...
rtn[i]=self.font_array[pos+i]
return rtn
def print_font(self,f):
if f==None:
return
w=int(self.one_font_size/8)
fsize=len(f)
if fsize<=16:
w=1
for i in range(self.one_font_size):
for j in range(w):
l=f[i*w+j]
mask=0x0080
for k in range(8):
if (mask & l)!=0:
print('*',end='')
else:
print(' ',end='')
mask=mask>>1
print('')
print('')
class Bitmap_to_Display:
#
# command:
# clear... 0x00
# show ... 0x01
# set1 ix,iy,r,g,b
# ... 0x02 *,*, *,*,*
# setn ix,iy,n, r0,g0,b0, ..r(n-1),g(n-1),b(n-1) n<=8
# ... 0x03 *,*, *, *,*,*, ..., *,*,*
#
pixels_ex01= [ \
[ ' ',' ',' ',' ',' ',' ',' ',' '],\
[ ' ','r','r',' ',' ','r','r',' '],\
[ 'r',' ',' ','r','r',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ ' ','r',' ',' ',' ',' ','r',' '],\
[ ' ','r',' ',' ',' ',' ','r',' '],\
[ ' ',' ','r',' ',' ','r',' ',' '],\
[ ' ',' ',' ','r','r',' ',' ',' '],\
[ ' ',' ',' ',' ',' ',' ',' ',' '],\
[ ' ','g','g','g','g','g','g','g'],\
[ ' ',' ','g','y','y','y','g',' '],\
[ ' ',' ',' ','g','y','g',' ',' '],\
[ ' ',' ',' ','g','y','g',' ',' '],\
[ ' ',' ',' ',' ','g',' ',' ',' '] ]
r_comp={' ':0x00, 'r':0xff, 'g':0x00, 'b':0x00, 'y':0xf...
g_comp={' ':0x00, 'r':0x00, 'g':0xff, 'b':0x00, 'y':0xf...
b_comp={' ':0x00, 'r':0x00, 'g':0x00, 'b':0xff, 'y':0x0...
def __init__(self,fa):
self.i2c = smbus.SMBus(1)
self.addrs = 0x3f
self.fourpix=[0x00, 0x00, 0x04, 0,0,0, 0,0,0, 0,0,0, ...
self.v_bitmap=[[] for i in range(16)]
self.v_lp=0
self.v_rp=0
self.d_bitmap=[[[0]*3 for i in range(32)] for j in ra...
self.current_r=0xff
self.current_g=0x00
self.current_b=0x00
self.font_accessor=fa
def start_display_thread(self):
self.thread=threading.Thread(target=self.display_th...
self.thread.start()
def display_thread(self):
while True:
if self.v_rp>=(len(self.v_bitmap[0])):
self.v_rp=0
if self.v_lp>=(len(self.v_bitmap[0])):
self.v_lp=0
#print('len(v_bitmap[0]={:d})'.format(len(self....
#print('v_lp='+str(self.v_lp)+' v_rp='+str(self...
if self.v_lp==self.v_rp:
self.clear_bitmap(self.d_bitmap)
elif self.v_lp<self.v_rp:
self.set_bitmap(self.v_bitmap,0,self.v_lp,1...
else:
self.set_bitmap(self.v_bitmap,0,self.v_lp,16,
len(self.v_bitmap[0])-self.v_lp,
self.d_bitmap,0,0)
self.set_bitmap(self.v_bitmap,0,0,16,self.v...
self.d_bitmap,0,len(self.v_bitmap...
self.v_lp=self.v_lp+1
self.v_rp=self.v_rp+1
self.show_bitmap(self.d_bitmap,0,0,16,32)
time.sleep(0.01)
def put_font(self,font):
#print(font)
if(len(font)>16):
w=16
else:
w=8
f_bitmap=[[[0,0,0] for i in range(w)] for j in rang...
self.set_font(self.font_accessor,font,f_bitmap,0,0)
self.append_font(f_bitmap)
def append_font(self,font):
#print('append_font w={:d}'.format(len(font[0])))
#self.print_bitmap(font)
if len(font)!=len(self.v_bitmap):
print('font size unpatch')
return
for i in range(len(self.d_bitmap)):
l=copy.copy(font[i])
#print('l=',end='')
#print(l)
#print('l len={:d}'.format(len(l)))
#print('b v_bitmap[{:d}'.format(i)+']=',end='')
#print(self.v_bitmap[i])
(self.v_bitmap[i]).extend(l)
#print('a v_bitmap[{:d}'.format(i)+']=',end='')
#print(self.v_bitmap[i])
#print('len={:d}'.format(len(self.v_bitmap[i])))
self.v_lp=0
if len(self.v_bitmap[0])<31:
self.v_rp=len(self.v_bitmap[0])
else:
self.v_rp=31
#print('-print_bitmap v_lp={:d}'.format(self.v_lp)+...
#for i in range(16):
#print('v_bitmap[{:d}'.format(i)+'] w={:d}'.form...
def set_color(self,r,g,b):
self.current_r=r
self.current_g=g
self.current_b=b
def clear_bitmap(self,bitmap):
h_max=len(bitmap)
w_max=len(bitmap[0])
for i in range(h_max):
for j in range(w_max):
for k in range(3):
bitmap[i][j][k]=0
def set_example_01(self,pixels_ex01,i,j,h,w,destination):
for ip in range(h):
for jp in range(w):
p=pixels_ex01[i+ip][j+jp]
for color in ['r','g','b']:
if color == 'r':
destination[ip][jp][0]=self.r_comp[p]
elif color == 'g':
destination[ip][jp][1]=self.g_comp[p]
elif color == 'b':
destination[ip][jp][2]=self.b_comp[p]
def set_bitmap(self,source,i,j,h,w, destination,k,l):
#print('set_bitmap i={:d}'.format(i)+' j={:d}'.format...
# ' h={:d}'.format(h)+' w={:d}'.format(w)+
# ' k={:d}'.format(k)+' l={:d}'.format(k))
#self.print_bitmap(source)
for ip in range(h):
for jp in range(w):
for cp in range(3):
#print(' i+ip={:d}'.format(i+ip)+' j+jp={:d}'.f...
cx=source[i+ip][j+jp][cp]
destination[k+ip][l+jp][cp]=cx
def set_font(self,fa,f, destination,d_i,d_j):
if f==None:
return
w=int(fa.one_font_size/8)
fsize=len(f)
if fsize<=16:
w=1
for i in range(fa.one_font_size):
for j in range(w):
l=f[i*w+j]
mask=0x0080
for k in range(8):
if (mask & l)!=0:
#print('*',end='')
destination[d_i+i][d_j+j*8+k][0]=se...
destination[d_i+i][d_j+j*8+k][1]=se...
destination[d_i+i][d_j+j*8+k][2]=se...
else:
destination[d_i+i][d_j+j*8+k][0]=0
destination[d_i+i][d_j+j*8+k][1]=0
destination[d_i+i][d_j+j*8+k][2]=0
#print(' ',end='')
mask=mask>>1
#print('')
#print('')
def show_bitmap(self, pixels, #bitmap data
i,j, #i,j: left, top position fro...
h,w #h:hight, w:width of the sho...
):
self.i2c.write_byte(self.addrs,0x00)
four_bitmap=[[0]*3 for i in range(4)]
for ip in range(h):
for jp in range(int(w/4)):
for kp in range(4):
for cp in range(3):
four_bitmap[kp][cp]=pixels[i+ip][j+jp*4+kp][cp]
self.send_4_pixel(i+ip,j+jp*4,four_bitmap)
self.i2c.write_byte(self.addrs,0x01)
def send_4_pixel(self, i,j,four_bitmap):
#self.i2c.write_byte(self.addrs,0x00)
self.fourpix[0]=i
self.fourpix[1]=j
for k in range(4):
for l in range(3):
p=four_bitmap[k][l]
self.fourpix[3+3*k+l]=p
#print('self.fourpix=',end='')
#print(self.fourpix)
self.i2c.write_i2c_block_data(self.addrs,0x03,self.fo...
#i2c.write_byte(addrs,0x01)
def print_bitmap(self,bitmap):
h_max=len(bitmap)
w_max=len(bitmap[0])
for ip in range(h_max):
for jp in range(w_max):
cc=0
for cp in range(3):
cx=bitmap[ip][jp][cp]
cc=cc<<8|cx
print('{:6x}'.format(cc),end='')
print()
def test_01(self):
self.clear_bitmap(self.d_bitmap)
self.print_bitmap(self.d_bitmap)
self.set_example_01(self.pixels_ex01,0,0,16,8,self.d_...
self.print_bitmap(self.d_bitmap)
self.show_bitmap(self.d_bitmap,0,0,16,8)
self.print_bitmap(self.d_bitmap)
class Show_String:
def __init__(self):
b_reader=Binary_file_reader()
b_reader.read_file('ShinonomeMin_16.pdb')
self.fa=Font_accessor(b_reader.get_binary(),16,0x...
self.b2d=Bitmap_to_Display(self.fa)
self.b2d.start_display_thread()
def set_string(self,s):
sx=""
while True:
print('s='+s+' sx='+sx)
if s.startswith('(red)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0x00
self.b2d.current_b=0x00
s=s[len('(red)'):]
if s.startswith('(green)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0xff
self.b2d.current_b=0x00
s=s[len('(green)'):]
if s.startswith('(blue)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0x00
self.b2d.current_b=0xff
s=s[len('(blue)'):]
if s.startswith('(yellow)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0xff
self.b2d.current_b=0x00
s=s[len('(yellow)'):]
if s.startswith('(magenta)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0x00
self.b2d.current_b=0xff
s=s[len('(magenta)'):]
if s.startswith('(cyan)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0xff
self.b2d.current_b=0xff
s=s[len('(cyan)'):]
if s.startswith('(white)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xc0
self.b2d.current_g=0xc0
self.b2d.current_b=0xc0
s=s[len('(white)'):]
if s.startswith('(pink)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xc0
self.b2d.current_g=0x30
self.b2d.current_b=0x30
s=s[len('(pink)'):]
if s.startswith('(orange)'):
self.put_string(sx)
sx=""
self.b2d.current_r=233
self.b2d.current_g=163
self.b2d.current_b=0
s=s[len('(orange)'):]
if s.startswith('(brown)'):
self.put_string(sx)
sx=""
self.b2d.current_r=100
self.b2d.current_g=77
self.b2d.current_b=55
s=s[len('(orange)'):]
if s.startswith('(purple)'):
self.put_string(sx)
sx=""
self.b2d.current_r=128
self.b2d.current_g=0
self.b2d.current_b=128
s=s[len('(purple)'):]
if len(s)>0:
sx=sx+s[0]
s=s[1:]
if len(s)<=0:
self.put_string(sx)
return
def put_string(self,s):
if s=="":
return
print('r={:d}'.format(self.b2d.current_r)+
' g={:d}'.format(self.b2d.current_g)+
' b={:d}'.format(self.b2d.current_b))
print('put_string '+s)
s_jis=self.fa.utf_8_str_to_jis_barray(s)
self.b2d.clear_bitmap(self.b2d.d_bitmap)
for i in range(len(s_jis)):
c=s_jis[i]
fx=self.b2d.font_accessor.get_font_jis(c)
self.b2d.font_accessor.print_font(fx)
self.b2d.put_font(fx)
ss=Show_String()
brightness=[15]
ss.b2d.i2c.write_i2c_block_data(ss.b2d.addrs,0x06,brightn...
ss.set_string("(green)福山(red)薔薇(blue)祭(white)!")
}}
----
#counter
終了行:
[[Required-Software-and-Data]]
#code(Python){{
# coding: utf-8
import smbus
import time
import traceback
import struct
import threading
import copy
class Binary_file_reader:
binary_data=None
def read_file(self,path):
self.binary_data=None
try:
with open(path,'rb') as file:
while True:
chunk = file.read(1024)
if not chunk:
break
if not self.binary_data:
self.binary_data=chunk
else:
self.binary_data=self.binary_data...
file.close()
except Exception as e:
print(traceback.format_exc())
def get_binary(self):
return self.binary_data
def dump_binary(self,frm, length):
if not self.binary_data:
print("no binary.")
adr=frm
s=""
c=""
size=len(self.binary_data)
cs=[' ']
if size<length:
length=size
eadr=adr+length
while adr<eadr:
a=adr
if a<size:
s='{:08x}'.format(a)
else:
s=' '
print(s,end='')
sline=''
cline=''
for i in range(16):
if a<size:
d=self.binary_data[a] & 0xff
sline=sline+'{:02x}'.format(d)+' '
if d<0x20 or d>0xde or (d>0x73 and d<...
d=0x2e
cs=chr(d);
cline=cline+cs+' '
else:
s=' '
c=' '
a=a+1
print(' '+sline+' '+cline)
adr=a
def dump_binary_all(self):
self.dump_binary(0,len(self.binary_data))
#b_reader=Binary_file_reader()
#b_reader.read_file('ShinonomeMin_16.pdb')
#b_reader.dump_binary(0,1024)
class Font_accessor:
font_array=[]
base=0
one_font_size=16
font_width_byte=2
asciicode=[
0x2121, 0x2121,0x2121,0x2121, #//0x00, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x04, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x08, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x0C, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x10, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x14, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x18, 0x...
0x2121, 0x2121,0x2121,0x2121, #//0x1C, 0x...
0x2121, 0x212A,0x2148,0x2174, #//0x20, 0x...
0x2170, 0x2173,0x2175,0x212D, #//0x24, 0x...
0x214A, 0x214B,0x2176,0x215C, #//0x28, 0x...
0x2124, 0x215D,0x2125,0x213F, #//0x2C, 0x...
0x2330, 0x2331,0x2332,0x2333, #//0x30, 0x...
0x2334, 0x2335,0x2336,0x2337, #//0x34, 0x...
0x2338, 0x2339,0x2127,0x2128, #//0x38, 0x...
0x2163, 0x2161,0x2164,0x2129, #//0x3C, 0x...
0x2177, 0x2341,0x2342,0x2343, #//0x40, 0x...
0x2344, 0x2345,0x2346,0x2347, #//0x44, 0x...
0x2348, 0x2349,0x234A,0x234B, #//0x48, 0x...
0x234C, 0x234D,0x234E,0x234F, #//0x4C, 0x...
0x2350, 0x2351,0x2352,0x2353, #//0x50, 0x...
0x2354, 0x2355,0x2356,0x2357, #//0x54, 0x...
0x2358, 0x2359,0x235A,0x214E, #//0x58, 0x...
0x2140, 0x214F,0x2130,0x2132, #//0x5C, 0x...
0x212D, 0x2361,0x2362,0x2363, #//0x60, 0x...
0x2364, 0x2365,0x2366,0x2367, #//0x64, 0x...
0x2368, 0x2369,0x236A,0x236B, #//0x68, 0x...
0x236C, 0x236D,0x236E,0x236F, #//0x6C, 0x...
0x2370, 0x2371,0x2372,0x2373, #//0x70, 0x...
0x2374, 0x2375,0x2376,0x2377, #//0x74, 0x...
0x2378, 0x2379,0x237A,0x2150, #//0x78, 0x...
0x2143, 0x2151,0x2141,0x2121 # //0x7C, 0x6...
]
ascii_font=[0 for x in range(256*8)]
ascii_font_data=[
#//
#// use https://github.com/alexmac/alc...
#//
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0...
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0...
0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0...
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0...
0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x92, 0...
0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0...
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0...
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0...
0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0...
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0...
0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0...
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0...
0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0...
0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0...
0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0...
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0...
0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0...
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0...
0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0...
0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0...
0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0...
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0...
0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0...
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0...
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0...
0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0...
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0...
0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0...
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0...
0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0...
0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0...
0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0...
0x18, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0...
0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0...
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0...
0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0...
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0...
0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0...
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0...
0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0...
0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0...
0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0...
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0...
0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0...
0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0...
0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0...
0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0...
0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0...
0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0...
0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0...
0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0...
0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0...
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0...
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0...
0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0...
0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0...
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0...
0x3c, 0x66, 0x0c, 0x18, 0x18, 0x00, 0...
0x7c, 0xc6, 0xde, 0xde, 0xdc, 0xc0, 0...
0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0...
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0...
0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0...
0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0...
0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0...
0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0...
0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0...
0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0...
0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0...
0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0...
0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0...
0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0...
0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0...
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0...
0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0...
0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0...
0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0x7c, 0...
0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0...
0x7c, 0xc6, 0xe0, 0x78, 0x0e, 0xc6, 0...
0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0...
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0...
0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0...
0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0...
0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0...
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0...
0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0...
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0...
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0...
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0...
0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0...
0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0...
0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0...
0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0x38, 0x6c, 0x64, 0xf0, 0x60, 0x60, 0...
0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0...
0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0...
0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x0c, 0x00, 0x1c, 0x0c, 0x0c, 0xcc, 0...
0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0...
0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0...
0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0...
0x00, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0...
0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0...
0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0...
0x00, 0x00, 0x7c, 0xc0, 0x70, 0x1c, 0...
0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0...
0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0...
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0...
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0...
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0...
0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0...
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0...
0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0...
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0...
0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0...
0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0c, 0...
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0x7e, 0x81, 0x3c, 0x06, 0x3e, 0x66, 0...
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x00, 0x00, 0x7c, 0xc6, 0xc0, 0x78, 0...
0x7e, 0x81, 0x3c, 0x66, 0x7e, 0x60, 0...
0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0...
0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0...
0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0xc6, 0x10, 0x7c, 0xc6, 0xfe, 0xc6, 0...
0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0...
0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0...
0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0...
0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0...
0x78, 0x84, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0...
0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0...
0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0...
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0...
0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0...
0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x30, 0...
0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0...
0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0...
0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0...
0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0...
0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0...
0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0...
0x00, 0xf8, 0x00, 0xb8, 0xcc, 0xcc, 0...
0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0...
0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0...
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0...
0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0...
0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0...
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0...
0xc6, 0xcc, 0xd8, 0x36, 0x6b, 0xc2, 0...
0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6d, 0...
0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0...
0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0...
0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0...
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0...
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0...
0xdb, 0xf6, 0xdb, 0x6f, 0xdb, 0x7e, 0...
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0...
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0...
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0...
0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0...
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0...
0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0...
0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0...
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0...
0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0...
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0...
0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0...
0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0...
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0...
0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0...
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0...
0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0...
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0...
0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0...
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0...
0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0...
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0...
0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0...
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0...
0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0...
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0...
0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0...
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0...
0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0...
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0...
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0...
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0...
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0...
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0...
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0...
0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0...
0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0...
0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0...
0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0...
0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0...
0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0...
0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0...
0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0...
0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0...
0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0...
0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0...
0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0...
0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0...
0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0...
0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0...
0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0...
0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0...
0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0...
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0...
0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0...
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0...
0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0...
0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0...
0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0...
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0...
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0...
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0...
0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0...
0x58, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0...
0x70, 0x98, 0x30, 0x60, 0xf8, 0x00, 0...
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0...
]
def __init__(self,font_data, font_size, base):
self.font_array=font_data
self.one_font_size=font_size
self.base=base
self.font_width_byte=int((self.one_font_size+7)/8)
for i in range(len(self.ascii_font)):
self.ascii_font[i]=self.ascii_font_data[i]
def utf_8_str_to_jis_barray(self,x):
#print('utf_8_str_to_jis_barray x='+x)
rtn=[]
lx=len(x)
for i in range(lx):
c=x[i]
#print('c='+c)
j=self.utf_8_to_jis_char(c)
#print('j={:x}'.format(j))
rtn.append(j)
return rtn
def utf_8_to_jis_char(self,x):
#print('utf_8_to_jis_char x='+x)
w=x.encode('shift_jis')
jw=self.sjis_to_jis(w)
return jw
def sjis_to_jis_string(self,x):
xlen=len(x)
rtn=''
for i in range(xlen):
w=self.sjis_to_jis(x[i])
rtn=rtn+w
return rtn
def sjis_to_jis(self, x):
#print('sjis_to_jis x=',end='')
#print(x)
if len(x)==2:
wx=struct.unpack('BB',x)
c1=wx[0]
c2=wx[1]
else:
wx=struct.unpack('B',x)
c1=0
c2=wx[0]
#print(wx)
##c1=(x >> 8) &0x00ff
##c2=x & 0x00ff
#print('c1={:x}'.format(c1))
#print('c2={:x}'.format(c2))
if c1==0:
c2=c2
else:
if c1 >=0xe0:
c1=c1-0x40
if c2 >=0x80:
c2=c2-1
if c2 >=0x9e:
c1=(c1-0x70)*2
c2=c2-0x7d
else:
c1=((c1-0x70)*2)-1
c2=c2-0x1f
rtn=(c1<<8)|c2
#print('rtn=',end='')
#print(rtn)
return rtn
def get_JIS_string(self,x):
tmp=self.get_SJIS_string(x)
if tmp==None:
return None
rtn=[' ' for i in range(len(tmp))]
bl=len(tmp)
for i in range(bl):
#print('tmp[i]='+tmp[i])
#print('tmp[i]={:0x}'.format(ord(tmp[i])))
cx=ord(tmp[i]) & 0x0000ffff
if cx>0x2100:
rtn[i]=self.sjis_to_jis(tmp[i])
else:
rtn[i]=tmp[i]
return rtn
def get_font_jis(self,code):
hb=(0xff00 & code)>>8
lb=0x00ff & code
if code <0x2100:
return self.get_ascii_font(code)
fn=((hb-0x21)*(0x7f-0x21))+lb-0x21
pos=self.base+(fn*self.one_font_size*self.font_wi...
return self.get_font_raw(pos)
def get_ascii_font(self,c):
# Standard ASCII 5x7 font
# Draw a character
rtn=[0 for i in range(16)]
offset=6
#print('get_ascii_font c={:x}'.format(c))
for i in range(8):
rtn[offset+i]=self.ascii_font[8*c+i]
#print(rtn)
return rtn
def get_font_raw(self,pos):
if self.font_array==None:
return None
rtn=[0 for i in range(self.one_font_size*self.fon...
if pos+self.one_font_size*self.font_width_byte > ...
print("exceeded the max font range.")
return None
for i in range(self.one_font_size*self.font_width...
rtn[i]=self.font_array[pos+i]
return rtn
def print_font(self,f):
if f==None:
return
w=int(self.one_font_size/8)
fsize=len(f)
if fsize<=16:
w=1
for i in range(self.one_font_size):
for j in range(w):
l=f[i*w+j]
mask=0x0080
for k in range(8):
if (mask & l)!=0:
print('*',end='')
else:
print(' ',end='')
mask=mask>>1
print('')
print('')
class Bitmap_to_Display:
#
# command:
# clear... 0x00
# show ... 0x01
# set1 ix,iy,r,g,b
# ... 0x02 *,*, *,*,*
# setn ix,iy,n, r0,g0,b0, ..r(n-1),g(n-1),b(n-1) n<=8
# ... 0x03 *,*, *, *,*,*, ..., *,*,*
#
pixels_ex01= [ \
[ ' ',' ',' ',' ',' ',' ',' ',' '],\
[ ' ','r','r',' ',' ','r','r',' '],\
[ 'r',' ',' ','r','r',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ 'r',' ',' ',' ',' ',' ',' ','r'],\
[ ' ','r',' ',' ',' ',' ','r',' '],\
[ ' ','r',' ',' ',' ',' ','r',' '],\
[ ' ',' ','r',' ',' ','r',' ',' '],\
[ ' ',' ',' ','r','r',' ',' ',' '],\
[ ' ',' ',' ',' ',' ',' ',' ',' '],\
[ ' ','g','g','g','g','g','g','g'],\
[ ' ',' ','g','y','y','y','g',' '],\
[ ' ',' ',' ','g','y','g',' ',' '],\
[ ' ',' ',' ','g','y','g',' ',' '],\
[ ' ',' ',' ',' ','g',' ',' ',' '] ]
r_comp={' ':0x00, 'r':0xff, 'g':0x00, 'b':0x00, 'y':0xf...
g_comp={' ':0x00, 'r':0x00, 'g':0xff, 'b':0x00, 'y':0xf...
b_comp={' ':0x00, 'r':0x00, 'g':0x00, 'b':0xff, 'y':0x0...
def __init__(self,fa):
self.i2c = smbus.SMBus(1)
self.addrs = 0x3f
self.fourpix=[0x00, 0x00, 0x04, 0,0,0, 0,0,0, 0,0,0, ...
self.v_bitmap=[[] for i in range(16)]
self.v_lp=0
self.v_rp=0
self.d_bitmap=[[[0]*3 for i in range(32)] for j in ra...
self.current_r=0xff
self.current_g=0x00
self.current_b=0x00
self.font_accessor=fa
def start_display_thread(self):
self.thread=threading.Thread(target=self.display_th...
self.thread.start()
def display_thread(self):
while True:
if self.v_rp>=(len(self.v_bitmap[0])):
self.v_rp=0
if self.v_lp>=(len(self.v_bitmap[0])):
self.v_lp=0
#print('len(v_bitmap[0]={:d})'.format(len(self....
#print('v_lp='+str(self.v_lp)+' v_rp='+str(self...
if self.v_lp==self.v_rp:
self.clear_bitmap(self.d_bitmap)
elif self.v_lp<self.v_rp:
self.set_bitmap(self.v_bitmap,0,self.v_lp,1...
else:
self.set_bitmap(self.v_bitmap,0,self.v_lp,16,
len(self.v_bitmap[0])-self.v_lp,
self.d_bitmap,0,0)
self.set_bitmap(self.v_bitmap,0,0,16,self.v...
self.d_bitmap,0,len(self.v_bitmap...
self.v_lp=self.v_lp+1
self.v_rp=self.v_rp+1
self.show_bitmap(self.d_bitmap,0,0,16,32)
time.sleep(0.01)
def put_font(self,font):
#print(font)
if(len(font)>16):
w=16
else:
w=8
f_bitmap=[[[0,0,0] for i in range(w)] for j in rang...
self.set_font(self.font_accessor,font,f_bitmap,0,0)
self.append_font(f_bitmap)
def append_font(self,font):
#print('append_font w={:d}'.format(len(font[0])))
#self.print_bitmap(font)
if len(font)!=len(self.v_bitmap):
print('font size unpatch')
return
for i in range(len(self.d_bitmap)):
l=copy.copy(font[i])
#print('l=',end='')
#print(l)
#print('l len={:d}'.format(len(l)))
#print('b v_bitmap[{:d}'.format(i)+']=',end='')
#print(self.v_bitmap[i])
(self.v_bitmap[i]).extend(l)
#print('a v_bitmap[{:d}'.format(i)+']=',end='')
#print(self.v_bitmap[i])
#print('len={:d}'.format(len(self.v_bitmap[i])))
self.v_lp=0
if len(self.v_bitmap[0])<31:
self.v_rp=len(self.v_bitmap[0])
else:
self.v_rp=31
#print('-print_bitmap v_lp={:d}'.format(self.v_lp)+...
#for i in range(16):
#print('v_bitmap[{:d}'.format(i)+'] w={:d}'.form...
def set_color(self,r,g,b):
self.current_r=r
self.current_g=g
self.current_b=b
def clear_bitmap(self,bitmap):
h_max=len(bitmap)
w_max=len(bitmap[0])
for i in range(h_max):
for j in range(w_max):
for k in range(3):
bitmap[i][j][k]=0
def set_example_01(self,pixels_ex01,i,j,h,w,destination):
for ip in range(h):
for jp in range(w):
p=pixels_ex01[i+ip][j+jp]
for color in ['r','g','b']:
if color == 'r':
destination[ip][jp][0]=self.r_comp[p]
elif color == 'g':
destination[ip][jp][1]=self.g_comp[p]
elif color == 'b':
destination[ip][jp][2]=self.b_comp[p]
def set_bitmap(self,source,i,j,h,w, destination,k,l):
#print('set_bitmap i={:d}'.format(i)+' j={:d}'.format...
# ' h={:d}'.format(h)+' w={:d}'.format(w)+
# ' k={:d}'.format(k)+' l={:d}'.format(k))
#self.print_bitmap(source)
for ip in range(h):
for jp in range(w):
for cp in range(3):
#print(' i+ip={:d}'.format(i+ip)+' j+jp={:d}'.f...
cx=source[i+ip][j+jp][cp]
destination[k+ip][l+jp][cp]=cx
def set_font(self,fa,f, destination,d_i,d_j):
if f==None:
return
w=int(fa.one_font_size/8)
fsize=len(f)
if fsize<=16:
w=1
for i in range(fa.one_font_size):
for j in range(w):
l=f[i*w+j]
mask=0x0080
for k in range(8):
if (mask & l)!=0:
#print('*',end='')
destination[d_i+i][d_j+j*8+k][0]=se...
destination[d_i+i][d_j+j*8+k][1]=se...
destination[d_i+i][d_j+j*8+k][2]=se...
else:
destination[d_i+i][d_j+j*8+k][0]=0
destination[d_i+i][d_j+j*8+k][1]=0
destination[d_i+i][d_j+j*8+k][2]=0
#print(' ',end='')
mask=mask>>1
#print('')
#print('')
def show_bitmap(self, pixels, #bitmap data
i,j, #i,j: left, top position fro...
h,w #h:hight, w:width of the sho...
):
self.i2c.write_byte(self.addrs,0x00)
four_bitmap=[[0]*3 for i in range(4)]
for ip in range(h):
for jp in range(int(w/4)):
for kp in range(4):
for cp in range(3):
four_bitmap[kp][cp]=pixels[i+ip][j+jp*4+kp][cp]
self.send_4_pixel(i+ip,j+jp*4,four_bitmap)
self.i2c.write_byte(self.addrs,0x01)
def send_4_pixel(self, i,j,four_bitmap):
#self.i2c.write_byte(self.addrs,0x00)
self.fourpix[0]=i
self.fourpix[1]=j
for k in range(4):
for l in range(3):
p=four_bitmap[k][l]
self.fourpix[3+3*k+l]=p
#print('self.fourpix=',end='')
#print(self.fourpix)
self.i2c.write_i2c_block_data(self.addrs,0x03,self.fo...
#i2c.write_byte(addrs,0x01)
def print_bitmap(self,bitmap):
h_max=len(bitmap)
w_max=len(bitmap[0])
for ip in range(h_max):
for jp in range(w_max):
cc=0
for cp in range(3):
cx=bitmap[ip][jp][cp]
cc=cc<<8|cx
print('{:6x}'.format(cc),end='')
print()
def test_01(self):
self.clear_bitmap(self.d_bitmap)
self.print_bitmap(self.d_bitmap)
self.set_example_01(self.pixels_ex01,0,0,16,8,self.d_...
self.print_bitmap(self.d_bitmap)
self.show_bitmap(self.d_bitmap,0,0,16,8)
self.print_bitmap(self.d_bitmap)
class Show_String:
def __init__(self):
b_reader=Binary_file_reader()
b_reader.read_file('ShinonomeMin_16.pdb')
self.fa=Font_accessor(b_reader.get_binary(),16,0x...
self.b2d=Bitmap_to_Display(self.fa)
self.b2d.start_display_thread()
def set_string(self,s):
sx=""
while True:
print('s='+s+' sx='+sx)
if s.startswith('(red)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0x00
self.b2d.current_b=0x00
s=s[len('(red)'):]
if s.startswith('(green)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0xff
self.b2d.current_b=0x00
s=s[len('(green)'):]
if s.startswith('(blue)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0x00
self.b2d.current_b=0xff
s=s[len('(blue)'):]
if s.startswith('(yellow)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0xff
self.b2d.current_b=0x00
s=s[len('(yellow)'):]
if s.startswith('(magenta)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xff
self.b2d.current_g=0x00
self.b2d.current_b=0xff
s=s[len('(magenta)'):]
if s.startswith('(cyan)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0x00
self.b2d.current_g=0xff
self.b2d.current_b=0xff
s=s[len('(cyan)'):]
if s.startswith('(white)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xc0
self.b2d.current_g=0xc0
self.b2d.current_b=0xc0
s=s[len('(white)'):]
if s.startswith('(pink)'):
self.put_string(sx)
sx=""
self.b2d.current_r=0xc0
self.b2d.current_g=0x30
self.b2d.current_b=0x30
s=s[len('(pink)'):]
if s.startswith('(orange)'):
self.put_string(sx)
sx=""
self.b2d.current_r=233
self.b2d.current_g=163
self.b2d.current_b=0
s=s[len('(orange)'):]
if s.startswith('(brown)'):
self.put_string(sx)
sx=""
self.b2d.current_r=100
self.b2d.current_g=77
self.b2d.current_b=55
s=s[len('(orange)'):]
if s.startswith('(purple)'):
self.put_string(sx)
sx=""
self.b2d.current_r=128
self.b2d.current_g=0
self.b2d.current_b=128
s=s[len('(purple)'):]
if len(s)>0:
sx=sx+s[0]
s=s[1:]
if len(s)<=0:
self.put_string(sx)
return
def put_string(self,s):
if s=="":
return
print('r={:d}'.format(self.b2d.current_r)+
' g={:d}'.format(self.b2d.current_g)+
' b={:d}'.format(self.b2d.current_b))
print('put_string '+s)
s_jis=self.fa.utf_8_str_to_jis_barray(s)
self.b2d.clear_bitmap(self.b2d.d_bitmap)
for i in range(len(s_jis)):
c=s_jis[i]
fx=self.b2d.font_accessor.get_font_jis(c)
self.b2d.font_accessor.print_font(fx)
self.b2d.put_font(fx)
ss=Show_String()
brightness=[15]
ss.b2d.i2c.write_i2c_block_data(ss.b2d.addrs,0x06,brightn...
ss.set_string("(green)福山(red)薔薇(blue)祭(white)!")
}}
----
#counter
ページ名: