5 #dsk = open(r"\\.\physicaldrive1",'rb+')
7 def __init__(self,drive):
8 self.dsk = open(drive,'rb+') # open drive that is memory map of the display and buzzer
9 self.drive = drive # save path
11 def writedisp(self,arr):
12 if len(arr)%512: # if not multiple of 512(sector size) round up to nearest
13 arr += [0]*(512 - len(arr)%512)
14 self.dsk.seek(0) # seek to begining of display
15 self.dsk.write(bytearray(arr)) # write display
16 self.dsk.close() # sync io reads
17 self.dsk = open(self.drive,'rb+') # sync io reads and open
19 if len(sys.argv) != 3:
20 print("you're bad at what you do [dev image]")
23 disp = hardwareD(sys.argv[1]) # open drive for me its /dev/sde on windows its `r"\\.\physicaldrive"+ number`
24 # `wmic diskdrive list` will list drive number in windows. if the drive number is a real drive it will be erased be VERY carefull
25 cap = cv2.VideoCapture(sys.argv[2]) # open image for testing
26 if (cap.isOpened()== False): # it didnt open
27 print("Error opening video stream or file")
29 while(cap.isOpened()):
30 ret, img = cap.read() # read image data
31 if ret == True: # if end of video
33 img = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE) # rotate image lcd is rotated idk why
34 img = cv2.resize(img,(128,160),interpolation = cv2.INTER_LANCZOS4) # scale image to lcd size using LANCZOS4
35 img = cv2.cvtColor(img,cv2.COLOR_BGR2BGR565) # convert to bgr565 color space the color space the lcd uses
39 arr+= [img[i,j][1],img[i,j][0]] # because idk python well we expand the 3d array to 1d and swap the bytes.
40 disp.writedisp(arr) # write the binary data to the display
45 cv2.destroyAllWindows()
47 print(disp.readtemp()) # read temp
48 sleep(1) # wait for recalc