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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
| -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
-
!
-
|
!
-
!
-
!
-
!
-
!
-
|
|
!
-
|
|
!
-
!
-
!
-
!
-
!
-
|
!
-
|
|
|
|
!
-
|
!
-
|
!
-
|
!
-
!
-
!
-
|
|
|
|
|
|
|
|
!
-
|
!
-
!
-
|
!
-
|
|
|
|
!
-
|
|
!
-
|
|
!
-
|
|
|
!
-
!
-
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
|
|
!
-
!
-
|
|
|
!
| import smbus
import time
import traceback
import struct
import threading
import copy
import socket
import sys
class RemoteCommandReader:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = 'localhost'
PORT = 9998
def __init__(self):
print("start RemoteCommandReader.__init__")
self.client_start()
self.ss=Show_String()
self.ss.set_RemoteCommandReader(self)
while True:
try:
time.sleep(0.01)
except:
print("error")
def python2fwbln(self,py2x_message):
msg=py2x_message+'\n'
self.sock.sendall(msg.encode('utf-8'))
def python2fwb(self,py2x_message):
msg=py2x_message
self.sock.sendall(msg.encode('utf-8'))
def rb(self,in_str):
while True:
if in_str.startswith(' '):
in_str=in_str[1:]
else:
break
return in_str
def parse_key(self,key,inx,rest):
keylen=len(key)
inlen=len(inx)
if inx.startswith(key):
rest[0]=inx[keylen:]
return True
rest[0]=inx
return False
def parse_String_Constant(self,inx,strc,rest):
rx=[""]
xstr=""
if self.parse_key('"',inx,rx):
inx=rx[0]
fx=inx[0]
xlen=len(inx)
while fx!='"':
if xlen==0:
return False
if fx=='\\':
inx=inx[1:xlen]
else:
xstr=xstr+fx
xlen=len(inx)
inx=inx[1:xlen]
fx=inx[0]
if self.parse_key('"',inx,rx):
strc[0]=xstr
rest[0]=rx[0]
return True
return False
def parse(self,line):
self.python2fwb(">"+line)
print('parse line='+line)
if line.startswith('show '):
line=line[len('show '):]
print(line)
line=self.rb(line)
text=['']
rest=['']
if self.parse_String_Constant(line,text,rest):
self.ss.set_string(text[0])
elif line.startswith('clear'):
self.ss.set_string('')
elif line.startswith('ls'):
self.returnFileList()
elif line.startswith('address'):
self.show_address()
elif line.startswith('shutdown'):
self.shutdown()
def returnFileList(self):
cpath=os.getcwd()
os.chdir("/home/pi/Pictures")
filenames = [f.name for f in os.scandir()]
filenames.sort()
for fn in filenames:
self.python2fwbln(fn)
os.chdir(cpath)
def shutdown(self):
os.system("sudo shutdown -h now")
def address(self):
os.system("sudo shutdown -h now")
def client_start(self):
"""クライアントのスタート"""
self.sock.connect((self.HOST, self.PORT))
handle_thread = threading.Thread(target=self.handler, args=(self.sock,), daemon=True)
handle_thread.start()
def handler(self,sock):
"""サーバからメッセージを受信し、表示する"""
fx=sock.makefile('r')
while True:
try:
l=fx.readline()
except socket.error: print("socket error. exit")
sock.close() except:
import traceback
traceback.print_exc()
print("server_handler receive error.")
self.parse(l)
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+chunk
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<0xa1):
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))
class Font_accessor:
font_array=[]
base=0
one_font_size=16
font_width_byte=2
asciicode=[
0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x2121,0x2121,0x2121, 0x2121, 0x212A,0x2148,0x2174, 0x2170, 0x2173,0x2175,0x212D, 0x214A, 0x214B,0x2176,0x215C, 0x2124, 0x215D,0x2125,0x213F, 0x2330, 0x2331,0x2332,0x2333, 0x2334, 0x2335,0x2336,0x2337, 0x2338, 0x2339,0x2127,0x2128, 0x2163, 0x2161,0x2164,0x2129, 0x2177, 0x2341,0x2342,0x2343, 0x2344, 0x2345,0x2346,0x2347, 0x2348, 0x2349,0x234A,0x234B, 0x234C, 0x234D,0x234E,0x234F, 0x2350, 0x2351,0x2352,0x2353, 0x2354, 0x2355,0x2356,0x2357, 0x2358, 0x2359,0x235A,0x214E, 0x2140, 0x214F,0x2130,0x2132, 0x212D, 0x2361,0x2362,0x2363, 0x2364, 0x2365,0x2366,0x2367, 0x2368, 0x2369,0x236A,0x236B, 0x236C, 0x236D,0x236E,0x236F, 0x2370, 0x2371,0x2372,0x2373, 0x2374, 0x2375,0x2376,0x2377, 0x2378, 0x2379,0x237A,0x2150, 0x2143, 0x2151,0x2141,0x2121 ]
ascii_font=[0 for x in range(256*8)]
ascii_font_data=[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00,
0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x92, 0x10, 0x7c,
0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c,
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff,
0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18,
0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0,
0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0,
0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99,
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18,
0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00,
0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0x86, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00,
0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff,
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00,
0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00,
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00,
0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00,
0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00,
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00,
0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
0x18, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x18, 0x00,
0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00,
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00,
0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00,
0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00,
0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30,
0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00,
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0x7c, 0x00, 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00, 0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00, 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30,
0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00,
0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00,
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00,
0x3c, 0x66, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00,
0x7c, 0xc6, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3a, 0x00, 0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00, 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0x7c, 0x0e, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, 0x7c, 0xc6, 0xe0, 0x78, 0x0e, 0xc6, 0x7c, 0x00, 0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00, 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00,
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00, 0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x38, 0x6c, 0x64, 0xf0, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x0c, 0x00, 0x1c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00, 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xd6, 0x00, 0x00, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e, 0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0x70, 0x1c, 0xf8, 0x00, 0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00,
0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00,
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00,
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0c, 0x06, 0x7c,
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x7e, 0x81, 0x3c, 0x06, 0x3e, 0x66, 0x3b, 0x00,
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc0, 0x78, 0x0c, 0x38,
0x7e, 0x81, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0xc6, 0x10, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00,
0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00,
0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00,
0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, 0x78, 0x84, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00,
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00,
0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18,
0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00,
0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x30, 0xfc, 0x30,
0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc3,
0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70,
0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
0x00, 0xf8, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0x00,
0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00,
0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00,
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3c, 0x00,
0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00,
0xc6, 0xcc, 0xd8, 0x36, 0x6b, 0xc2, 0x84, 0x0f,
0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6d, 0xcf, 0x03,
0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00,
0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00,
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
0xdb, 0xf6, 0xdb, 0x6f, 0xdb, 0x7e, 0xd7, 0xed, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18,
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36,
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18,
0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36,
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00,
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36,
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36,
0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36,
0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00,
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00,
0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0,
0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x00,
0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00,
0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00,
0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0,
0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00,
0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc,
0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00,
0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00,
0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00,
0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0,
0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00,
0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00,
0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00,
0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00,
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00,
0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00,
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c,
0x58, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00,
0x70, 0x98, 0x30, 0x60, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
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):
rtn=[]
lx=len(x)
for i in range(lx):
c=x[i]
j=self.utf_8_to_jis_char(c)
rtn.append(j)
return rtn
def utf_8_to_jis_char(self,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):
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]
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
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):
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_width_byte)
return self.get_font_raw(pos)
def get_ascii_font(self,c):
rtn=[0 for i in range(16)]
offset=6
for i in range(8):
rtn[offset+i]=self.ascii_font[8*c+i]
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.font_width_byte)]
if pos+self.one_font_size*self.font_width_byte > len(self.font_array):
print("exceeded the max font range.")
return None
for i in range(self.one_font_size*self.font_width_byte):
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:
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':0xff, 'w':0xff}
g_comp={' ':0x00, 'r':0x00, 'g':0xff, 'b':0x00, 'y':0xff, 'w':0xff}
b_comp={' ':0x00, 'r':0x00, 'g':0x00, 'b':0xff, 'y':0x00, 'w':0xff}
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, 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 range(16)]
self.current_r=0xff
self.current_g=0x00
self.current_b=0x00
self.font_accessor=fa
self.update_display=True
def init_v_bitmap(self):
self.v_bitmap=[[] for i in range(16)]
self.v_lp=0
self.v_rp=0
def start_display_thread(self):
self.thread=threading.Thread(target=self.display_thread)
self.thread.start()
def display_thread(self):
while True:
if self.update_display:
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
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,16,32, self.d_bitmap,0,0)
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_rp,
self.d_bitmap,0,len(self.v_bitmap[0])-self.v_lp+1)
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):
if(len(font)>16):
w=16
else:
w=8
f_bitmap=[[[0,0,0] for i in range(w)] for j in range(16)]
self.set_font(self.font_accessor,font,f_bitmap,0,0)
self.append_font(f_bitmap)
def append_font(self,font):
if len(font)!=len(self.v_bitmap):
print('font size unmatch')
return
for i in range(len(self.d_bitmap)):
l=copy.copy(font[i])
(self.v_bitmap[i]).extend(l)
self.v_lp=0
if len(self.v_bitmap[0])<31:
self.v_rp=len(self.v_bitmap[0])
else:
self.v_rp=31
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):
for ip in range(h):
for jp in range(w):
for cp in range(3):
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:
destination[d_i+i][d_j+j*8+k][0]=self.current_r
destination[d_i+i][d_j+j*8+k][1]=self.current_g
destination[d_i+i][d_j+j*8+k][2]=self.current_b
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
mask=mask>>1
def show_bitmap(self, pixels, i,j, h,w ):
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.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
self.i2c.write_i2c_block_data(self.addrs,0x03,self.fourpix)
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_bitmap)
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,0x00F0)
self.b2d=Bitmap_to_Display(self.fa)
self.b2d.start_display_thread()
def set_RemoteCommandReader(self,rcr):
self.rcr=rcr
def clear(self):
self.b2d.update_display=False
self.b2d.i2c.write_byte(self.b2d.addrs,0x00)
self.b2d.i2c.write_byte(self.b2d.addrs,0x01)
time.sleep(0.01)
self.b2d.i2c.write_byte(self.b2d.addrs,0x00)
self.b2d.i2c.write_byte(self.b2d.addrs,0x01)
self.b2d.init_v_bitmap()
self.b2d.update_display=True
def set_string(self,s):
self.clear()
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
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.put_font(fx)
def main():
RemoteCommandReader()
if __name__ == "__main__":
main()
|