Add Sunrise x3 Pi Python program, modify some programs to speed up data transfer.

This commit is contained in:
SSYYL 2022-08-15 11:14:27 +08:00
parent 979184d047
commit 88bbf456c6
28 changed files with 709 additions and 453 deletions

View file

@ -4,8 +4,8 @@
# * | Function : Electronic paper driver
# * | Info :
# *----------------
# * | This version: V4.0
# * | Date : 2019-06-20
# * | This version: V4.1
# * | Date : 2022-08-10
# # | Info : python demo
# -----------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy
@ -171,6 +171,13 @@ class EPD:
epdconfig.spi_writebyte([data])
epdconfig.digital_write(self.cs_pin, 1)
# send a lot of data
def send_data2(self, data):
epdconfig.digital_write(self.dc_pin, 1)
epdconfig.digital_write(self.cs_pin, 0)
epdconfig.spi_writebyte2(data)
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
@ -227,20 +234,15 @@ class EPD:
self.send_data(0x97)
self.send_command(0x20) # vcom
for count in range(0, 44):
self.send_data(self.lut_vcomDC[count])
self.send_data2(self.lut_vcomDC)
self.send_command(0x21) # ww --
for count in range(0, 42):
self.send_data(self.lut_ww[count])
self.send_data2(self.lut_ww)
self.send_command(0x22) # bw r
for count in range(0, 42):
self.send_data(self.lut_bw[count])
self.send_data2(self.lut_bw)
self.send_command(0x23) # wb w
for count in range(0, 42):
self.send_data(self.lut_wb[count])
self.send_data2(self.lut_wb)
self.send_command(0x24) # bb b
for count in range(0, 42):
self.send_data(self.lut_bb[count])
self.send_data2(self.lut_bb)
def SetPartReg(self):
self.send_command(0x82)
@ -249,20 +251,15 @@ class EPD:
self.send_data(0x47)
self.send_command(0x20) # vcom
for count in range(0, 44):
self.send_data(self.lut_vcom1[count])
self.send_data2(self.lut_vcom1)
self.send_command(0x21) # ww --
for count in range(0, 42):
self.send_data(self.lut_ww1[count])
self.send_data2(self.lut_ww1)
self.send_command(0x22) # bw r
for count in range(0, 42):
self.send_data(self.lut_bw1[count])
self.send_data2(self.lut_bw1)
self.send_command(0x23) # wb w
for count in range(0, 42):
self.send_data(self.lut_wb1[count])
self.send_data2(self.lut_wb1)
self.send_command(0x24) # bb b
for count in range(0, 42):
self.send_data(self.lut_bb1[count])
self.send_data2(self.lut_bb1)
def getbuffer(self, image):
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
@ -292,14 +289,17 @@ class EPD:
if (Image == None):
return
if self.width%8 == 0:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
self.send_command(0x10)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0x00)
self.send_data2([0x00] * self.height * linewidth)
epdconfig.delay_ms(10)
self.send_command(0x13)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(image[i])
self.send_data2(image)
epdconfig.delay_ms(10)
self.SetFullReg()
@ -319,29 +319,40 @@ class EPD:
self.send_data(int(self.height / 256))
self.send_data(self.height % 256 - 1)
self.send_data(0x28)
if self.width%8 == 0:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
buf = [0x00] * self.height * linewidth
for i in range(self.height * linewidth):
buf[i] = ~image[i]
self.send_command(0x10)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(image[i])
self.send_data2(image)
epdconfig.delay_ms(10)
self.send_command(0x13)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(~image[i])
self.send_data2(buf)
epdconfig.delay_ms(10)
self.SetPartReg()
self.TurnOnDisplay()
def Clear(self, color):
def Clear(self):
if self.width%8 == 0:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
self.send_command(0x10)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0x00)
self.send_data2([0x00] * self.height * linewidth)
epdconfig.delay_ms(10)
self.send_command(0x13)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0xFF)
self.send_data2([0xFF] * self.height * linewidth)
epdconfig.delay_ms(10)
self.SetFullReg()