TeleportDresser

٤Ƴ٤Ĥ
  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
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
|
|
|
|
|
|
|
|
|
!
 
 
 
 
 
-
!
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
-
!
 
-
!
-
!
-
!
 
 
-
!
-
!
 
 
-
!
 
-
!
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
-
!
 
 
-
!
 
 
-
!
 
 
-
!
 
 
-
!
 
 
-
!
 
 
 
-
!
 
 
 
 
 
-
!
 
-
!
 
 
-
!
 
 
 
-
!
 
 
-
!
 
 
 
-
!
 
 
 
-
!
 
 
-
!
 
 
-
!
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
 
 
 
 
-
!
 
 
 
 
-
!
 
 
-
!
 
 
 
 
-
!
-
!
 
 
-
!
 
 
 
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
 
-
!
 
-
!
-
!
-
!
-
!
 
-
!
-
!
 
 
 
 
 
 
 
-
!
-
!
 
-
!
-
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
|
|
|
|
|
|
|
|
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
# -*- coding:utf-8 -*-
from tkinter import *
from tkinter.ttk import Scale
from tkinter import colorchooser,filedialog,messagebox
import smbus
import time
import math
import PIL.ImageGrab as ImageGrab
import sys
import requests
import os
import socket
import threading
from collections import deque
import subprocess
 
class Remote_Command_Reader:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    HOST = 'localhost'
    PORT = 9998
    def __init__(self,pd):
        print("start Remote_Command_Reader.__init__")
        self.plane_display=pd
        print(self.plane_display)
        self.plane_display.set_Remote_Command_Reader(self)
 
    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 parse(self,line):
      self.python2fwb(">"+line)
      self.plane_display.parse(line)
 
    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 client_start(self,addr):
      """クライアントのスタート"""
      try:
          self.sock.connect((addr, self.PORT))
      except:
          print("connect error, addr="+addr+" port="+str(self.PORT))
          return
      handle_thread = threading.Thread(target=self.handler, args=(self.sock,), daemon=True)
      handle_thread.start()
 
    def handler(self,sock):
      """サーバからメッセージを受信し、表示する"""
 
      while True:
        data = sock.recv(1024)
        print("[受信]{}".format(data.decode("utf-8")))
        line=data.decode("utf-8")
        self.parse(line)
 
 
class Pic_Element:
    def __init__(self,canvas,editor,count):
        self.canvas=canvas
        self.cx=0
        self.cy=0
        self.r=0
        self.color=editor.get_color()
        self.width=1
        self.status=0 #0:centering, 1:radius deciding, 2:showing, 3:editing,
                      #4:editing, centering, #5:editing, radius deciding.
        self.err=2.0
        self.canvas=canvas
        self.editor=editor
        self.pic_count=count
 
    def draw(self):
        a=1
    def is_selected(self,mx,my):
        a=1
    def mouse_down(self,x,y):
        a=1
    def mouse_click(self,x,y):
        a=1
    def draw(self):
        a=a
    def show_cross(self,x,y):
        self.cx=x
        self.cy=y
        self.canvas.create_line(self.cx-3,self.cy-3,self.cx+3,self.cy+3,fill="White",width=1)
        self.canvas.create_line(self.cx+3,self.cy-3,self.cx-3,self.cy+3,fill="White",width=1)
    def show_small_box(self,x,y):
        self.cx=x
        self.cy=y
        self.canvas.create_rectangle(self.cx-3,self.cy-3,self.cx+3,self.cy+3,fill="White",width=1)
        
 
class Circle(Pic_Element):
    def __init__(self,canvas,editor,count):
        super().__init__(canvas,editor,count)
        #self.cx=0
        #self.cy=0
        #self.r=0
        #self.color='green'
        #self.width=1
        #self.status=0 #0:centering, 1:radius deciding, 2:showing, 3:editing,
                      #4:editing, centering, #5:editing, radius deciding.
        #self.err=2.0
        #self.canvas=canvas
        #self.editor=editor
    def set_center(self,px,py):
        self.cx=px
        self.cy=py
    def set_radius(self,rr):
        self.r=rr
    def draw(self):
        #print("pic "+str(self.pic_count)+",status="+str(self.status)+",color="+str(self.color))
        color=self.color
        width=self.width
        #print("draw color="+color)
        if self.status==0:
            self.show_cross(self.cx,self.cy)
        elif self.status==1:
            x0=self.cx-self.r
            y0=self.cy-self.r
            x1=self.cx+self.r
            y1=self.cy+self.r
            self.canvas.create_oval(x0,y0,x1,y1,width=width,fill=color)
            self.show_cross(self.cx,self.cy)
        elif self.status==2:
            x0=self.cx-self.r
            y0=self.cy-self.r
            x1=self.cx+self.r
            y1=self.cy+self.r
            self.canvas.create_oval(x0,y0,x1,y1,width=width,fill=color)
        elif self.status==3:
            x0=self.cx-self.r
            y0=self.cy-self.r
            x1=self.cx+self.r
            y1=self.cy+self.r
            self.canvas.create_oval(x0,y0,x1,y1,width=width,fill=color)
        elif self.status==4:
            print("draw status 4 pic_count="+str(self.pic_count))
            x0=self.cx-self.r
            y0=self.cy-self.r
            x1=self.cx+self.r
            y1=self.cy+self.r
            self.canvas.create_oval(x0,y0,x1,y1,width=width,fill=color)
            self.show_small_box(self.cx,self.cy)
        elif self.status==5:
            x0=self.cx-self.r
            y0=self.cy-self.r
            x1=self.cx+self.r
            y1=self.cy+self.r
            self.canvas.create_oval(x0,y0,x1,y1,width=width,fill=color)
            self.show_small_box(self.cx,self.cy)
 
    def select(self,mx,my):
        print("select")
        rx=math.sqrt((self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my))
        if abs(rx-self.r)<self.err:
            if self.status==2:
                self.status=4
    def mouse_click(self,mx,my):
        print("mouse_click, status="+str(self.status)+",pic_count="+str(self.pic_count))
        if self.status==0:
            self.cx=mx
            self.cy=my
            self.status=1
        elif self.status==1:
            sqx=(self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my)
            self.r=math.sqrt(sqx)
            self.status=2
        elif self.status==2:
            a=1
        elif self.status==3:
            sqx=(self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my)
            rx=math.sqrt(sqx)
            d=abs(self.r-rx)
            print("selecting d="+str(d)+",err="+str(self.err))
            if abs(self.r -rx)<self.err:
                self.status=4
                #print("pic "+str(self.pic_count)+" is selected, tuned into status 4.")
        elif self.status==4:
            self.cx=mx
            self.cy=my
            self.status=5
        elif self.status==5:
            self.r=math.sqrt((self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my))
            self.status=2
        
    def mouse_move(self,mx,my):
        if self.status==0:
            self.cx=mx
            self.cy=my
        elif self.status==1:
            self.r=math.sqrt((self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my))
        elif self.status==2:
            a=1
        elif self.status==3:
            a=1
        elif self.status==4:
            self.cx=mx
            self.cy=my
        elif self.status==5:
            self.r=math.sqrt((self.cx-mx)*(self.cx-mx)+(self.cy-my)*(self.cy-my))
        
    def set_width(self,width):
        self.width=width
    def get_status(self):
        return self.status
    def set_color(self,color):
        print("set_color,status="+str(self.status)+",color-x="+str(self.color)+",new color="+str(color)+",pic_count="+str(self.pic_count))
        if (self.status==0) or (self.status==1) or (self.status==4) or (self.status==5):
            self.color=color
            print("new color="+str(self.color))
    def set_selecting(self):
        self.status=3
    def set_status(self,s):
        self.status=s
        
class Pic_Elements:
    def __init__(self,editor,canvas):
        self.element_list=[]
        self.canvas=canvas
        self.editor=editor
        
    def add(self,element):
        self.element_list.append(element)
    def remove(self,element):
        self.element_list.remove(element)
    def draw(self):
        #print("draw-elements")
        self.editor.canvas.delete('all')
        for ele in self.element_list:
            ele.draw()
    def clear_all(self):
        self.element_list.clear()
    def mouse_click(self,mx,my):
        for element in self.element_list:
            element.mouse_click(mx,my)
        self.draw()
    def mouse_move(self,mx,my):
        for element in self.element_list:
            element.mouse_move(mx,my)
        self.draw()
    def set_color(self,col):
        print("set_color")
        for element in self.element_list:
            element.set_color(col)
    def selecting(self):
        print("selecting")
        for element in self.element_list:
            element.set_selecting()
        
class Draw_Editor:
#Defining Class and constructor of the Program
    def __init__(self,root):
 
#Defining title and Size of the Tkinter Window GUI
        self.root =root
        self.root.title("Draw for Neopixel Matrix ex01")
#         self.root.geometry("810x8000")
        self.root.configure(background="white")
#         self.root.resizable(0,0)
 
#variables for pointer and Eraser   
        self.pointer= "black"
        self.erase="white"
 
#Widgets for Tkinter Window
    
# Configure the alignment , font size and color of the text
        text=Text(root)
        text.tag_configure("tag_name", justify='center', font=('arial',10),background='#292826',foreground='orange')
 
# Insert a Text
        text.insert("1.0", "Neopixel Matrix Draw.")
 
# Add the tag for following given text
        text.tag_add("tag_name", "1.0", "end")
        text.pack()
        
# Pick a color for drawing from color pannel
        self.pick_color = LabelFrame(self.root,text='Colors',font =('arial',10),bd=5,relief=RIDGE,bg="white")
        self.pick_color.place(x=0,y=80,width=120,height=210)
 
        colors = ['blue','red','green', 'orange','violet','white','yellow','purple','pink','gold','brown','black']
        i=j=0
        for color in colors:
            Button(self.pick_color,bg=color,bd=2,relief=RIDGE,width=3,command=lambda col=color:self.select_color(col)).grid(row=i,column=j)
            i+=1
            if i==6:
                i=0
                j=1
 
# New Button and its properties   
        self.new_btn= Button(self.root,text="New",bd=4,bg='white',command=self.new_element,width=10,relief=RIDGE)
        self.new_btn.place(x=0,y=290)
 
# New Button and its properties   
        self.edit_btn= Button(self.root,text="Edit",bd=4,bg='white',command=self.select,width=10,relief=RIDGE)
        self.edit_btn.place(x=0,y=320)
 
# Erase Button and its properties   
        self.eraser_btn= Button(self.root,text="Eraser",bd=4,bg='white',command=self.eraser,width=10,relief=RIDGE)
        self.eraser_btn.place(x=0,y=350)
 
# Reset Button to clear the entire screen 
        self.clear_screen= Button(self.root,text="Clear Screen",bd=4,bg='white',command= self.clear_canvas,width=10,relief=RIDGE)
        self.clear_screen.place(x=0,y=380)
 
# Save Button for saving the image in local computer
        self.save_btn= Button(self.root,text="ScreenShot",bd=4,bg='white',command=self.save_drawing,width=10,relief=RIDGE)
        self.save_btn.place(x=0,y=410)
 
# Background Button for choosing color of the Canvas
        self.bg_btn= Button(self.root,text="Background",bd=4,bg='white',command=self.canvas_color,width=10,relief=RIDGE)
        self.bg_btn.place(x=0,y=440)
 
# Background Button for choosing color of the Canvas
        self.bg_btn= Button(self.root,text="show neomatrix",bd=4,bg='white',command=self.show_neomatrix,width=10,relief=RIDGE)
        self.bg_btn.place(x=0,y=470)
 
 
#depth
        self.depth_frame= LabelFrame(self.root,text='depth',bd=5,bg='white',font=('arial',10,'bold'),relief=RIDGE)
        self.depth_frame.place(x=0,y=500,height=50,width=120)
 
        self.depth_entry =Entry(self.depth_frame,width=10)
        self.depth_entry.grid(row=0,column=1,padx=15)
 
#remote command bridge server
        self.server_field=Entry(self.root,width=50)
        self.server_field.place(x=80,y=20)
#connect Button for connecting to the bridge server
        self.save_btn= Button(self.root,text="connect",bd=4,bg='white',command=self.connect,width=8,relief=RIDGE)
        self.save_btn.place(x=500,y=20)
        
#expression input (3D)
        self.exp_input_field=Entry(self.root,width=50)
        self.exp_input_field.place(x=80,y=50)
 
 
#add Button for adding a picture element
        self.save_btn= Button(self.root,text="enter",bd=4,bg='white',command=self.add_circle_expression,width=8,relief=RIDGE)
        self.save_btn.place(x=500,y=50)
 
#Defining a background color for the Canvas 
        self.canvas = Canvas(self.root,bg='black',bd=5,relief=GROOVE,height=500,width=375)
        self.canvas.place(x=120,y=80)
 
 
#Bind the background Canvas with mouse click
        self.canvas.bind("<B1-Motion>",self.mouse_move1)
        self.canvas.bind("<Button-1>",self.mouse_click)
        self.canvas.bind("<Motion>",self.mouse_move)
 
#Picture Elements
        self.pic_elements=Pic_Elements(self,self.canvas)
        self.pic_count=0
 
# Functions are defined here
    def set_Remote_Command_Reader(self,reader):
        self.reader=reader
 
# Paint Function for Drawing the lines on Canvas
    def mouse_move(self,event):
        mx=event.x
        my=event.y
        #print("mouse_move("+str(mx)+","+str(my)+")")
        self.pic_elements.mouse_move(mx,my)
 
    def mouse_move1(self,event):
        mx=event.x
        my=event.y
        print("mouse_move1("+str(mx)+","+str(my)+")")
        self.pic_elements.mouse_move1(mx,my)
 
    def mouse_click(self,event):
        mx=event.x
        my=event.y
        print("mouse_click("+str(mx)+","+str(my)+")")
        self.pic_elements.mouse_click(mx,my)
 
# Function for choosing the color of pointer  
    def select_color(self,col):
        print("select_color,color="+col)
        self.pointer = col
        self.pic_elements.set_color(self.pointer)
        
    def get_color(self):
        return self.pointer
 
# Function for creating a circle  
    def new_element(self):
        c=Circle(self.canvas,self,self.pic_count)
        self.pic_elements.add(c)
        self.pic_count=self.pic_count+1
 
# Function for defining the eraser
    def eraser(self):
        self.pointer= self.erase
 
# Function for choosing the background color of the Canvas    
    def canvas_color(self):
        color=colorchooser.askcolor()
        self.canvas.configure(background=color[1])
        self.erase= color[1]
 
# Function for clear the Canvas    
    def clear_canvas(self):
        #print("clear_canvas")
        self.canvas.delete('all')
        self.pic_elements.clear_all()
 
# Function for clear the Canvas    
    def select(self):
        print("select")
        self.pic_elements.selecting()
 
# Function for adding ciecle of the expression
    def add_circle_expression(self):
        exp=self.exp_input_field.get()
        self.parse(exp)
        
    def parse(self,exp):
        print(exp)
        depthx=self.depth_entry.get()
        print(depthx)
        if depthx==None or depthx=="":
            depth=0
        else:
            depth=int(depthx)
        print("depth="+str(depth))
        exp2=exp.split()
        for w in exp2:
            print(w+" ")
        cx=0
        cy=0
        cz=0
        r=0
        color="blue"
        if exp2[0]=="add":
            if exp2[1]=="ball":
                cx=int(exp2[2])
                cy=int(exp2[3])
                cz=int(exp2[4])
                r=int(exp2[5])
                color=exp2[6]
                print("ball-("+str(cx)+","+str(cy)+","+str(cz)+") r="+str(r)+",color="+color)
                cz2=depth-cz
                r1sq=r*r-cz2*cz2
                if r1sq>0:
                    r2=math.sqrt(r1sq)
                    cc=Circle(self.canvas,self,self.pic_count)
                    cc.set_center(cx,cy)
                    cc.set_radius(r2)
                    cc.set_color(color)
                    cc.set_status(2)
                    self.pic_elements.add(cc)
                    self.pic_elements.draw()
        if exp2[0]=="clear":
            self.clear_canvas()
        if exp2[0]=="show":
            self.show_neomatrix()
 
# connect
    def connect(self):
        server=self.server_field.get()
        self.reader.client_start(server)
        
 
# Function for saving the image file in Local Computer
    def save_drawing(self):
        try:
            # self.background update()
            file_ss =filedialog.asksaveasfilename(defaultextension='jpg')
            #print(file_ss)
            x=self.root.winfo_rootx() + self.canvas.winfo_x()
            #print(x, self.background.winfo_x())
            y=self.root.winfo_rooty() + self.canvas.winfo_y()
            #print(y)
 
            x1= x + self.canvas.winfo_width() 
            #print(x1)
            y1= y + self.canvas.winfo_height()
            #print(y1)
            ImageGrab.grab().crop((x , y, x1, y1)).save(file_ss)
            messagebox.showinfo('Screenshot Successfully Saved as' + str(file_ss))
 
        except:
            print("Error in saving the screenshot")
            
    def return_image(self):
        x=self.root.winfo_rootx() + self.canvas.winfo_x()+10
        #print(x, self.background.winfo_x())
        y=self.root.winfo_rooty() + self.canvas.winfo_y()+10
        #print(y)
 
        x1= x + self.canvas.winfo_width() -12
        #print(x1)
        y1= y + self.canvas.winfo_height()-12
        #print(y1)
        img=ImageGrab.grab().crop((x , y, x1, y1))
        return img
 
    def show_neomatrix(self):
        img=self.return_image()
        off_x=0
        off_y=0
        
        imax=75
        jmax=16
 
        img_width, img_height=img.size
        print('width:',img_width)
        print('height:',img_height)
        dx=img_width/jmax
        dy=img_height/imax
        i2c = smbus.SMBus(1) # 注:ラズパイのI2Cポート
        #
        # 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=[[(0,0,0) for j in range(jmax)] for i in range(imax)]
          
        addrs = [0x30,0x31,0x32,0x33]
        fourpix=[0x00, 0x00, 0x04, 0,0,0, 0,0,0, 0,0,0, 0,0,0]
        for i in range(imax):
            for j in range(jmax):
                x=off_x+j*dx
                y=off_y+i*dy
                rgb=img.getpixel((x,y))
                pixels[i][j]=rgb
 
        i2c.write_byte(addrs[0],0x00)
        i2c.write_byte(addrs[1],0x00)
        i2c.write_byte(addrs[2],0x00)
        i2c.write_byte(addrs[3],0x00)
        for i in range(imax):
          for j in range(4):
            for k in range(4):
              p=pixels[i][4*j+k]
              fourpix[3+k*3+0]=p[0]
              fourpix[3+k*3+1]=p[1]
              fourpix[3+k*3+2]=p[2]
            fourpix[0]=i;
            fourpix[1]=0;
            i2c_addr=addrs[j]
            try:
              i2c.write_i2c_block_data(i2c_addr,0x03,fourpix)
            except:
              print('i2c write error at:(',i,',',j,')')
            time.sleep(0.0005)
        i2c.write_byte(addrs[0],0x01)
        i2c.write_byte(addrs[1],0x01)
        i2c.write_byte(addrs[2],0x01)
        i2c.write_byte(addrs[3],0x01)
 
if __name__=="__main__":
    root = Tk()
    p=Draw_Editor(root)
    rcr=Remote_Command_Reader(p)
    root.mainloop()

Counter: 142, today: 1, yesterday: 0

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS