Merge branch 'master' into jetson-spidev

This commit is contained in:
missionfloyd 2021-08-11 00:42:10 -06:00 committed by GitHub
commit 3a8ee3d590
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
994 changed files with 357649 additions and 78242 deletions

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 80
EPD_HEIGHT = 128
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -109,7 +111,7 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0x71)
busy = epdconfig.digital_read(self.busy_pin)
busy =not(busy & 0x01)
@ -118,7 +120,7 @@ class EPD:
busy = epdconfig.digital_read(self.busy_pin)
busy =not(busy & 0x01)
epdconfig.delay_ms(800)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x12)
@ -242,14 +244,14 @@ class EPD:
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -86,6 +86,8 @@ from . import epdconfig
EPD_WIDTH = 200
EPD_HEIGHT = 200
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -131,10 +133,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2
@ -206,14 +208,14 @@ class EPD:
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 200
EPD_HEIGHT = 200
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -43,6 +45,75 @@ class EPD:
self.width = EPD_WIDTH
self.height = EPD_HEIGHT
# waveform full refresh
WF_Full_1IN54 = [
0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x8, 0x1, 0x0, 0x8, 0x1, 0x0, 0x2,
0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22, 0x17, 0x41, 0x0, 0x32, 0x20
]
# waveform partial refresh(fast)
WF_PARTIAL_1IN54_0 = [
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xF,0x0,0x0,0x0,0x0,0x0,0x0,
0x1,0x1,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x02,0x17,0x41,0xB0,0x32,0x28,
]
# waveform partial refresh(quality)
WF_PARTIAL_1IN54_1 = [
0x0,0x00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xA,0x0,0x0,0x0,0x0,0x0,0x1,
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x22,0x17,0x41,0x0,0x32,0x20,
]
# Hardware reset
def reset(self):
epdconfig.digital_write(self.reset_pin, 1)
@ -65,69 +136,130 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1):
epdconfig.delay_ms(20)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2
self.send_data(0xF7)
self.send_data(0xc7)
self.send_command(0x20) # MASTER_ACTIVATION
self.ReadBusy()
def TurnOnDisplayPart(self):
self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2
self.send_data(0xFF)
self.send_data(0xcF)
self.send_command(0x20) # MASTER_ACTIVATION
self.ReadBusy()
def init(self):
def lut(self, lut):
self.send_command(0x32) # WRITE_LUT_REGISTER
for i in range(0, len(lut)):
self.send_data(lut[i])
def set_lut(self, lut):
self.lut(lut)
self.send_command(0x3f)
self.send_data(lut[153])
self.send_command(0x03)
self.send_data(lut[154])
self.send_command(0x04)
self.send_data(lut[155])
self.send_data(lut[156])
self.send_data(lut[157])
self.send_command(0x2c)
self.send_data(lut[158])
def SetWindows(self, Xstart, Ystart, Xend, Yend):
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
self.send_data((Xstart>>3) & 0xFF)
self.send_data((Xend>>3) & 0xFF)
self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION
self.send_data(Ystart & 0xFF)
self.send_data((Ystart >> 8) & 0xFF)
self.send_data(Yend & 0xFF)
self.send_data((Yend >> 8) & 0xFF)
def SetCursor(self, Xstart, Ystart):
self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER
self.send_data(Xstart & 0xFF)
self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER
self.send_data(Ystart & 0xFF)
self.send_data((Ystart >> 8) & 0xFF)
def init(self, isPartial):
if (epdconfig.module_init() != 0):
return -1
# EPD hardware init start
self.reset()
if(isPartial):
logger.debug("partial refresh")
self.reset()
self.ReadBusy()
self.set_lut(self.WF_PARTIAL_1IN54_0)
self.send_command(0x37)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x40)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_command(0x3c) # BorderWavefrom
self.send_data(0x80)
self.send_command(0x22)
self.send_data(0xc0)
self.send_command(0x20)
self.ReadBusy()
self.ReadBusy()
self.send_command(0x12) # SWRESET
self.ReadBusy()
self.send_command(0x01) # DRIVER_OUTPUT_CONTROL
self.send_data(0xC7) # (EPD_HEIGHT - 1) & 0xFF
self.send_data(0x00) # ((EPD_HEIGHT - 1) >> 8) & 0xFF
self.send_data(0x01) # GD = 0 SM = 0 TB = 0
self.send_command(0x11) # data entry mode
self.send_data(0x01)
self.send_command(0x44) # set Ram-X address start/end position
self.send_data(0x00)
self.send_data(0x18) # 0x0C-->(18+1)*8=200
self.send_command(0x45) # set Ram-Y address start/end position
self.send_data(0xC7) # 0xC7-->(199+1)=200
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
else:
logger.debug("full refresh")
# EPD hardware init start
self.reset()
self.ReadBusy()
self.send_command(0x12) # SWRESET (software reset)
self.ReadBusy()
self.send_command(0x01) # DRIVER_OUTPUT_CONTROL
self.send_data(0xC7) # (EPD_HEIGHT - 1) & 0xFF
self.send_data(0x00) # ((EPD_HEIGHT - 1) >> 8) & 0xFF
self.send_data(0x01) # GD = 0 SM = 0 TB = 0
self.send_command(0x11) # data entry mode
self.send_data(0x01)
self.SetWindows(0, self.height-1, self.width-1, 0) # Set Windows
self.send_command(0x3C) # BorderWavefrom
self.send_data(0x01)
self.send_command(0x3C) # BorderWavefrom
self.send_data(0x01)
self.send_command(0x18)
self.send_data(0x80)
self.send_command(0x18)
self.send_data(0x80)
self.send_command(0x22) # #Load Temperature and waveform setting.
self.send_data(0XB1)
self.send_command(0x20)
self.send_command(0x22) # #Load Temperature and waveform setting.
self.send_data(0XB1)
self.send_command(0x20)
self.send_command(0x4E) # set RAM x address count to 0;
self.send_data(0x00)
self.send_command(0x4F) # set RAM y address count to 0X199;
self.send_data(0xC7)
self.send_data(0x00)
self.ReadBusy()
self.SetCursor(0, self.height-1) # Set Cursor
self.ReadBusy()
self.set_lut(self.WF_Full_1IN54) # Set lut
def Clear(self, color):
self.send_command(0x24)
@ -143,14 +275,14 @@ class EPD:
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -188,14 +320,6 @@ class EPD:
def displayPart(self, image):
if (image == None):
return
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(10)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(10)
self.send_command(0x3c)
self.send_data(0x80)
self.send_command(0x24)
for j in range(0, self.height):

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 200
EPD_HEIGHT = 200
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -74,10 +76,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0):
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def set_lut_bw(self):
self.send_command(0x20) # vcom

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 200
EPD_HEIGHT = 200
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,10 +68,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1):
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):

View file

@ -33,6 +33,8 @@ from . import epdconfig
EPD_WIDTH = 152
EPD_HEIGHT = 152
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -64,10 +66,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -101,14 +103,14 @@ class EPD:
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -119,11 +121,11 @@ class EPD:
def display(self, blackimage, yellowimage):
self.send_command(0x10)
logging.debug("blackimage")
logger.debug("blackimage")
for i in range(0, int(self.width * self.height / 8)):
self.send_data(blackimage[i])
self.send_command(0x13)
logging.debug("yellowimage")
logger.debug("yellowimage")
for i in range(0, int(self.width * self.height / 8)):
self.send_data(yellowimage[i])

View file

@ -36,6 +36,8 @@ import numpy as np
EPD_WIDTH = 122
EPD_HEIGHT = 250
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -90,9 +92,9 @@ class EPD:
self.send_command(0x20) # MASTER_ACTIVATION
self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.ReadBusy()
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self, lut):
if (epdconfig.module_init() != 0):
@ -168,14 +170,14 @@ class EPD:
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
if pixels[x, y] == 0:
# x = imwidth - x
buf[int(x / 8) + y * linewidth] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -36,6 +36,8 @@ import numpy as np
EPD_WIDTH = 122
EPD_HEIGHT = 250
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -222,14 +224,14 @@ class EPD:
pixels = image_monocolor.load()
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
if pixels[x, y] == 0:
x = imwidth - x
buf[int(x / 8) + y * linewidth] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -293,7 +295,7 @@ class EPD:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
# logging.debug(linewidth)
# logger.debug(linewidth)
self.send_command(0x24)
for j in range(0, self.height):

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 104
EPD_HEIGHT = 212
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -65,12 +67,12 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0x71);
while(epdconfig.digital_read(self.busy_pin) == 0):
self.send_command(0x71);
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -96,21 +98,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 104
EPD_HEIGHT = 212
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -65,10 +67,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -97,21 +99,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -37,6 +37,8 @@ import RPi.GPIO as GPIO
EPD_WIDTH = 104
EPD_HEIGHT = 212
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -170,11 +172,11 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0x71)
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x12)
@ -263,21 +265,21 @@ class EPD:
self.send_data(self.lut_bb1[count])
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 152
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -88,10 +90,10 @@ class EPD:
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self, mode):
@ -143,7 +145,7 @@ class EPD:
self.ReadBusy()
else:
logging.debug("There is no such mode")
logger.debug("There is no such mode")
return 0
@ -159,21 +161,21 @@ class EPD:
self.ReadBusy()
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 152
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -68,10 +70,10 @@ class EPD:
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(20)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
@ -122,21 +124,21 @@ class EPD:
self.ReadBusy()
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -38,6 +38,9 @@ GRAY1 = 0xff #white
GRAY2 = 0xC0
GRAY3 = 0x80 #gray
GRAY4 = 0x00 #Blackest
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -171,10 +174,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def set_lut(self):
self.send_command(0x20) # vcom
@ -361,21 +364,21 @@ class EPD:
self.send_data(0x57)
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -385,15 +388,15 @@ class EPD:
return buf
def getbuffer_4Gray(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width / 4) * self.height)
image_monocolor = image.convert('L')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
i=0
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
@ -406,11 +409,11 @@ class EPD:
buf[int((x + (y * self.width))/4)] = ((pixels[x-3, y]&0xc0) | (pixels[x-2, y]&0xc0)>>2 | (pixels[x-1, y]&0xc0)>>4 | (pixels[x, y]&0xc0)>>6)
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for x in range(imwidth):
for y in range(imheight):
newx = y
newy = x
newy = self.height - x - 1
if(pixels[x, y] == 0xC0):
pixels[x, y] = 0x80
elif (pixels[x, y] == 0x80):
@ -501,13 +504,13 @@ class EPD:
self.ReadBusy()
# pass
def Clear(self, color):
def Clear(self, color=0xFF):
self.send_command(0x10)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0xFF)
self.send_data(color)
self.send_command(0x13)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0xFF)
self.send_data(color)
self.send_command(0x12)
self.ReadBusy()

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 176
EPD_HEIGHT = 264
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -119,10 +121,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def set_lut(self):
self.send_command(0x20) # vcom
@ -206,21 +208,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -243,15 +245,15 @@ class EPD:
self.send_command(0x12)
self.ReadBusy()
def Clear(self):
def Clear(self, color=0x00):
self.send_command(0x10)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0x00)
self.send_data(color)
self.send_command(0x11)
self.send_command(0x13)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0x00)
self.send_data(color)
self.send_command(0x11)
self.send_command(0x12)

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 176
EPD_HEIGHT = 264
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -69,10 +71,10 @@ class EPD:
# Read Busy
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
# Setting the display window
def SetWindows(self, Xstart, Ystart, Xend, Yend):
@ -118,21 +120,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 128
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -90,9 +92,9 @@ class EPD:
self.send_command(0x20) # MASTER_ACTIVATION
self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.ReadBusy()
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def SetWindow(self, x_start, y_start, x_end, y_end):
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
@ -149,21 +151,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 128
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -44,25 +46,47 @@ class EPD:
self.height = EPD_HEIGHT
WF_PARTIAL_2IN9 = [
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0A,0x0,0x0,0x0,0x0,0x0,0x2,
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x22,0x17,0x41,0xB0,0x32,0x36,
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0A,0x0,0x0,0x0,0x0,0x0,0x2,
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x22,0x17,0x41,0xB0,0x32,0x36,
]
WS_20_30 = [
0x80, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0,
0x10, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0,
0x80, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0,
0x10, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x14, 0x8, 0x0, 0x0, 0x0, 0x0, 0x2,
0xA, 0xA, 0x0, 0xA, 0xA, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x14, 0x8, 0x0, 0x1, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x0, 0x0, 0x0,
0x22, 0x17, 0x41, 0x0, 0x32, 0x36
]
# Hardware reset
@ -87,14 +111,14 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2
self.send_data(0xF7)
self.send_data(0xc7)
self.send_command(0x20) # MASTER_ACTIVATION
self.ReadBusy()
@ -104,12 +128,25 @@ class EPD:
self.send_command(0x20) # MASTER_ACTIVATION
self.ReadBusy()
def SendLut(self):
def lut(self, lut):
self.send_command(0x32)
for i in range(0, 153):
self.send_data(self.WF_PARTIAL_2IN9[i])
self.send_data(lut[i])
self.ReadBusy()
def SetLut(self, lut):
self.lut(lut)
self.send_command(0x3f)
self.send_data(lut[153])
self.send_command(0x03); # gate voltage
self.send_data(lut[154])
self.send_command(0x04); # source voltage
self.send_data(lut[155]) # VSH
self.send_data(lut[156]) # VSH2
self.send_data(lut[157]) # VSL
self.send_command(0x2c); # VCOM
self.send_data(lut[158])
def SetWindow(self, x_start, y_start, x_end, y_end):
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
# x point must be the multiple of 8 or the last 3 bits will be ignored
@ -129,7 +166,6 @@ class EPD:
self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER
self.send_data(y & 0xFF)
self.send_data((y >> 8) & 0xFF)
self.ReadBusy()
def init(self):
if (epdconfig.module_init() != 0):
@ -137,45 +173,47 @@ class EPD:
# EPD hardware init start
self.reset()
self.ReadBusy();
self.send_command(0x12); #SWRESET
self.ReadBusy();
self.ReadBusy()
self.send_command(0x12) #SWRESET
self.ReadBusy()
self.send_command(0x01); #Driver output control
self.send_data(0x27);
self.send_data(0x01);
self.send_data(0x00);
self.send_command(0x01) #Driver output control
self.send_data(0x27)
self.send_data(0x01)
self.send_data(0x00)
self.send_command(0x11); #data entry mode
self.send_data(0x03);
self.send_command(0x11) #data entry mode
self.send_data(0x03)
self.SetWindow(0, 0, self.width-1, self.height-1);
self.SetWindow(0, 0, self.width-1, self.height-1)
self.send_command(0x21); # Display update control
self.send_data(0x00);
self.send_data(0x80);
self.send_command(0x21) # Display update control
self.send_data(0x00)
self.send_data(0x80)
self.SetCursor(0, 0);
self.ReadBusy();
self.SetCursor(0, 0)
self.ReadBusy()
self.SetLut(self.WS_20_30)
# EPD hardware init end
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -218,26 +256,26 @@ class EPD:
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(2)
self.SendLut();
self.send_command(0x37);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x40);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x00);
self.send_data(0x00);
self.SetLut(self.WF_PARTIAL_2IN9)
self.send_command(0x37)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x40)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_command(0x3C); #BorderWavefrom
self.send_data(0x80);
self.send_command(0x3C) #BorderWavefrom
self.send_data(0x80)
self.send_command(0x22);
self.send_data(0xC0);
self.send_command(0x20);
self.ReadBusy();
self.send_command(0x22)
self.send_data(0xC0)
self.send_command(0x20)
self.ReadBusy()
self.SetWindow(0, 0, self.width - 1, self.height - 1)
self.SetCursor(0, 0)

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 128
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,12 +68,12 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0X71)
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0X71)
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -98,21 +100,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 128
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,10 +68,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -97,21 +99,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -39,6 +39,8 @@ import RPi.GPIO as GPIO
EPD_WIDTH = 128
EPD_HEIGHT = 296
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -129,11 +131,11 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0x71)
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x12)
@ -213,21 +215,21 @@ class EPD:
self.send_data(self.lut_bb1[count])
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -36,8 +36,11 @@ EPD_HEIGHT = 480
GRAY1 = 0xff #white
GRAY2 = 0xC0 #Close to white
GRAY3 = 0x80 #Close to balck
GRAY4 = 0x00 #balck
GRAY3 = 0x80 #Close to black
GRAY4 = 0x00 #black
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -132,10 +135,10 @@ class EPD:
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self, mode):
@ -211,7 +214,7 @@ class EPD:
self.send_data(0xFF)
self.send_data(0xFF)
else:
logging.debug("There is no such mode")
logger.debug("There is no such mode")
self.send_command(0x44) # setting X direction start/end position of RAM
self.send_data(0x00)
@ -237,21 +240,21 @@ class EPD:
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -262,15 +265,15 @@ class EPD:
def getbuffer_4Gray(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width / 4) * self.height)
image_monocolor = image.convert('L')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
i=0
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
@ -283,7 +286,7 @@ class EPD:
buf[int((x + (y * self.width))/4)] = ((pixels[x-3, y]&0xc0) | (pixels[x-2, y]&0xc0)>>2 | (pixels[x-1, y]&0xc0)>>4 | (pixels[x, y]&0xc0)>>6)
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for x in range(imwidth):
for y in range(imheight):
newx = y
@ -430,7 +433,7 @@ class EPD:
elif(mode == 1): #1Gray
self.load_lut(self.lut_1Gray_DU)
else:
logging.debug("There is no such mode")
logger.debug("There is no such mode")
self.send_command(0x20)
self.ReadBusy()

View file

@ -36,6 +36,8 @@ from . import epdconfig
EPD_WIDTH = 640
EPD_HEIGHT = 400
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -75,16 +77,16 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusyHigh(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def ReadBusyLow(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -129,7 +131,7 @@ class EPD:
image_monocolor = image.convert('RGB')#Picture mode conversion
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
for y in range(imheight):
for x in range(imwidth):

View file

@ -42,6 +42,8 @@ GRAY2 = 0xC0
GRAY3 = 0x80 #gray
GRAY4 = 0x00 #Blackest
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -388,21 +390,21 @@ class EPD:
self.send_data(0x97)
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y
@ -412,15 +414,15 @@ class EPD:
return buf
def getbuffer_4Gray(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width / 4) * self.height)
image_monocolor = image.convert('L')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
i=0
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
@ -433,7 +435,7 @@ class EPD:
buf[int((x + (y * self.width))/4)] = ((pixels[x-3, y]&0xc0) | (pixels[x-2, y]&0xc0)>>2 | (pixels[x-1, y]&0xc0)>>4 | (pixels[x, y]&0xc0)>>6)
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for x in range(imwidth):
for y in range(imheight):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 400
EPD_HEIGHT = 300
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -65,12 +67,12 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0x71);
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0x71);
epdconfig.delay_ms(20)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -87,21 +89,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 400
EPD_HEIGHT = 300
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -65,10 +67,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -90,21 +92,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -32,10 +32,16 @@
import logging
from . import epdconfig
import PIL
from PIL import Image
import io
# Display resolution
EPD_WIDTH = 600
EPD_HEIGHT = 448
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -51,12 +57,12 @@ class EPD:
self.RED = 0x0000ff # 0100
self.YELLOW = 0x00ffff # 0101
self.ORANGE = 0x0080ff # 0110
# Hardware reset
def reset(self):
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(600)
epdconfig.delay_ms(600)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(2)
epdconfig.digital_write(self.reset_pin, 1)
@ -73,25 +79,31 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 0)
epdconfig.spi_writebyte([data])
epdconfig.digital_write(self.cs_pin, 1)
def send_data_bulk(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 ReadBusyHigh(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
epdconfig.delay_ms(100)
logger.debug("e-Paper busy release")
def ReadBusyLow(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
epdconfig.delay_ms(100)
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
return -1
# EPD hardware init start
self.reset()
self.ReadBusyHigh()
self.send_command(0x00)
self.send_data(0xEF)
@ -122,7 +134,7 @@ class EPD:
self.send_data(0xC0)
self.send_command(0xE3)
self.send_data(0xAA)
epdconfig.delay_ms(100)
self.send_command(0x50)
self.send_data(0x37)
@ -130,102 +142,67 @@ class EPD:
return 0
def getbuffer(self, image):
buf = [0x00] * int(self.width * self.height / 2)
image_monocolor = image.convert('RGB')#Picture mode conversion
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
# Create a pallette with the 7 colors supported by the panel
pal_image = Image.new("P", (1,1))
pal_image.putpalette( (0,0,0, 255,255,255, 0,255,0, 0,0,255, 255,0,0, 255,255,0, 255,128,0) + (0,0,0)*249)
# Check if we need to rotate the image
imwidth, imheight = image.size
if(imwidth == self.width and imheight == self.height):
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
Add = int((x + y * self.width) / 2)
Color = 0;
if (pixels[x, y][0] == 0 and pixels[x, y][1] == 0 and pixels[x, y][2] == 0):
Color = 0
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 255 and pixels[x, y][2] == 255):
Color = 1
elif (pixels[x, y][0] == 0 and pixels[x, y][1] == 255 and pixels[x, y][2] == 0):
Color = 2
elif (pixels[x, y][0] == 0 and pixels[x, y][1] == 0 and pixels[x, y][2] == 255):
Color = 3
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 0 and pixels[x, y][2] == 0):
Color = 4
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 255 and pixels[x, y][2] == 0):
Color = 5
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 128 and pixels[x, y][2] == 0):
Color = 6
data_t = buf[Add]&(~(0xF0 >> ((x % 2)*4)))
buf[Add] = data_t | ((Color << 4) >> ((x % 2)*4));
image_temp = image
elif(imwidth == self.height and imheight == self.width):
for y in range(imheight):
for x in range(imwidth):
newx = y
newy = self.height - x - 1
Add = int((newx + newy*self.width) / 2)
Color = 0;
if (pixels[x, y][0] == 0 and pixels[x, y][1] == 0 and pixels[x, y][2] == 0):
Color = 0
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 255 and pixels[x, y][2] == 255):
Color = 1
elif (pixels[x, y][0] == 0 and pixels[x, y][1] == 255 and pixels[x, y][2] == 0):
Color = 2
elif (pixels[x, y][0] == 0 and pixels[x, y][1] == 0 and pixels[x, y][2] == 255):
Color = 3
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 0 and pixels[x, y][2] == 0):
Color = 4
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 255 and pixels[x, y][2] == 0):
Color = 5
elif (pixels[x, y][0] == 255 and pixels[x, y][1] == 128 and pixels[x, y][2] == 0):
Color = 6
data_t = buf[Add]&(~(0xF0 >> ((newx % 2)*4)))
buf[Add] = data_t | ((Color << 4) >> ((newx % 2)*4));
image_temp = image.rotate(90, expand=True)
else:
logger.warning("Invalid image dimensions: %d x %d, expected %d x %d" % (imwidth, imheight, self.width, self.height))
# Convert the soruce image to the 7 colors, dithering if needed
image_7color = image_temp.convert("RGB").quantize(palette=pal_image)
buf_7color = bytearray(image_7color.tobytes('raw'))
# PIL does not support 4 bit color, so pack the 4 bits of color
# into a single byte to transfer to the panel
buf = [0x00] * int(self.width * self.height / 2)
idx = 0
for i in range(0, len(buf_7color), 2):
buf[idx] = (buf_7color[i] << 4) + buf_7color[i+1]
idx += 1
return buf
def display(self,image):
self.send_command(0x61)#Set Resolution setting
self.send_command(0x61) #Set Resolution setting
self.send_data(0x02)
self.send_data(0x58)
self.send_data(0x01)
self.send_data(0xC0)
self.send_command(0x10)
for i in range(0, int(EPD_HEIGHT)):
for j in range(0, int(EPD_WIDTH/2)):
self.send_data((image[j+(int(EPD_WIDTH/2)*i)]))
self.send_command(0x04)#0x04
self.send_data_bulk(image)
self.send_command(0x04) #0x04
self.ReadBusyHigh()
self.send_command(0x12)#0x12
self.send_command(0x12) #0x12
self.ReadBusyHigh()
self.send_command(0x02) #0x02
self.send_command(0x02) #0x02
self.ReadBusyLow()
epdconfig.delay_ms(500)
def Clear(self):
self.send_command(0x61)#Set Resolution setting
self.send_command(0x61) #Set Resolution setting
self.send_data(0x02)
self.send_data(0x58)
self.send_data(0x01)
self.send_data(0xC0)
self.send_command(0x10)
for i in range(0, int(EPD_HEIGHT)):
for j in range(0, int(EPD_WIDTH/2)):
self.send_data(0x11)
#BLACK 0x00 /// 0000
#WHITE 0x11 /// 0001
#GREEN 0x22 /// 0010
#BLUE 0x33 /// 0011
#RED 0x44 /// 0100
#YELLOW 0x55 /// 0101
#ORANGE 0x66 /// 0110
#CLEAN 0x77 /// 0111 unavailable Afterimage
self.send_command(0x04)#0x04
# Set all pixels to white
buf = [0x11] * int(self.width * self.height / 2)
self.send_data_bulk(buf)
self.send_command(0x04) #0x04
self.ReadBusyHigh()
self.send_command(0x12)#0x12
self.send_command(0x12) #0x12
self.ReadBusyHigh()
self.send_command(0x02) #0x02
self.send_command(0x02) #0x02
self.ReadBusyLow()
epdconfig.delay_ms(500)
@ -236,5 +213,4 @@ class EPD:
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(2000)
epdconfig.module_exit()
epdconfig.module_exit()

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 600
EPD_HEIGHT = 448
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,10 +68,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -125,7 +127,7 @@ class EPD:
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
for y in range(imheight):
for x in range(imwidth):

View file

@ -34,6 +34,8 @@ from . import epdconfig
EPD_WIDTH = 648
EPD_HEIGHT = 480
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -65,10 +67,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0):
epdconfig.delay_ms(20)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x12); #POWER ON
@ -114,21 +116,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 648
EPD_HEIGHT = 480
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,12 +68,12 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0X71)
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0X71)
epdconfig.delay_ms(200)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -111,21 +113,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 600
EPD_HEIGHT = 448
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,10 +68,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -117,21 +119,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 640
EPD_HEIGHT = 384
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -72,10 +74,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -134,7 +136,7 @@ class EPD:
img = img.rotate(90, expand=True).convert('1')
imwidth, imheight = img.size
else:
logging.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
# return a blank buffer
return buf

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 880
EPD_HEIGHT = 528
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -72,7 +74,7 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
busy = epdconfig.digital_read(self.busy_pin)
while(busy == 1):
busy = epdconfig.digital_read(self.busy_pin)
@ -136,7 +138,7 @@ class EPD:
elif(imwidth == self.height and imheight == self.width):
img = img.rotate(90, expand=True).convert('1')
else:
logging.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
# return a blank buffer
return [0xff] * int(self.width * self.height / 8)

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 800
EPD_HEIGHT = 480
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -44,14 +46,68 @@ class EPD:
self.width = EPD_WIDTH
self.height = EPD_HEIGHT
Voltage_Frame_7IN5_V2 = [
0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
]
LUT_VCOM_7IN5_V2 = [
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0xF, 0x1, 0xF, 0x1, 0x2,
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
]
LUT_WW_7IN5_V2 = [
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
]
LUT_BW_7IN5_V2 = [
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
]
LUT_WB_7IN5_V2 = [
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
]
LUT_BB_7IN5_V2 = [
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
]
# Hardware reset
def reset(self):
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(2)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
def send_command(self, command):
epdconfig.digital_write(self.dc_pin, 0)
@ -72,32 +128,79 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0x71)
busy = epdconfig.digital_read(self.busy_pin)
while(busy == 0):
self.send_command(0x71)
busy = epdconfig.digital_read(self.busy_pin)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
logger.debug("e-Paper busy release")
def SetLut(self, lut_vcom, lut_ww, lut_bw, lut_wb, lut_bb):
self.send_command(0x20)
for count in range(0, 42):
self.send_data(lut_vcom[count])
self.send_command(0x21)
for count in range(0, 42):
self.send_data(lut_ww[count])
self.send_command(0x22)
for count in range(0, 42):
self.send_data(lut_bw[count])
self.send_command(0x23)
for count in range(0, 42):
self.send_data(lut_wb[count])
self.send_command(0x24)
for count in range(0, 42):
self.send_data(lut_bb[count])
def init(self):
if (epdconfig.module_init() != 0):
return -1
# EPD hardware init start
self.reset()
self.send_command(0x01) #POWER SETTING
self.send_data(0x07)
self.send_data(0x07) #VGH=20V,VGL=-20V
self.send_data(0x3f) #VDH=15V
self.send_data(0x3f) #VDL=-15V
# self.send_command(0x06) # btst
# self.send_data(0x17)
# self.send_data(0x17)
# self.send_data(0x28) # If an exception is displayed, try using 0x38
# self.send_data(0x17)
# self.send_command(0x01) #POWER SETTING
# self.send_data(0x07)
# self.send_data(0x07) #VGH=20V,VGL=-20V
# self.send_data(0x3f) #VDH=15V
# self.send_data(0x3f) #VDL=-15V
self.send_command(0x01) # power setting
self.send_data(0x17) # 1-0=11: internal power
self.send_data(self.Voltage_Frame_7IN5_V2[6]) # VGH&VGL
self.send_data(self.Voltage_Frame_7IN5_V2[1]) # VSH
self.send_data(self.Voltage_Frame_7IN5_V2[2]) # VSL
self.send_data(self.Voltage_Frame_7IN5_V2[3]) # VSHR
self.send_command(0x82) # VCOM DC Setting
self.send_data(self.Voltage_Frame_7IN5_V2[4]) # VCOM
self.send_command(0x06) # Booster Setting
self.send_data(0x27)
self.send_data(0x27)
self.send_data(0x2F)
self.send_data(0x17)
self.send_command(0x30) # OSC Setting
self.send_data(self.Voltage_Frame_7IN5_V2[0]) # 2-0=100: N=4 5-3=111: M=7 3C=50Hz 3A=100HZ
self.send_command(0x04) #POWER ON
epdconfig.delay_ms(100)
self.ReadBusy()
self.send_command(0X00) #PANNEL SETTING
self.send_data(0x1F) #KW-3f KWR-2F BWROTP 0f BWOTP 1f
self.send_data(0x3F) #KW-3f KWR-2F BWROTP 0f BWOTP 1f
self.send_command(0x61) #tres
self.send_data(0x03) #source 800
@ -115,6 +218,13 @@ class EPD:
self.send_command(0X60) #TCON SETTING
self.send_data(0x22)
self.send_command(0x65) # Resolution setting
self.send_data(0x00)
self.send_data(0x00) # 800*480
self.send_data(0x00)
self.send_data(0x00)
self.SetLut(self.LUT_VCOM_7IN5_V2, self.LUT_WW_7IN5_V2, self.LUT_BW_7IN5_V2, self.LUT_WB_7IN5_V2, self.LUT_BB_7IN5_V2)
# EPD hardware init end
return 0
@ -127,7 +237,7 @@ class EPD:
# image has correct dimensions, but needs to be rotated
img = img.rotate(90, expand=True).convert('1')
else:
logging.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
# return a blank buffer
return [0x00] * (int(self.width/8) * self.height)

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 880
EPD_HEIGHT = 528
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,7 +68,7 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
busy = epdconfig.digital_read(self.busy_pin)
while(busy == 1):
busy = epdconfig.digital_read(self.busy_pin)
@ -135,21 +137,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 800
EPD_HEIGHT = 480
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,20 +68,27 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
self.send_command(0x71)
busy = epdconfig.digital_read(self.busy_pin)
while(busy == 0):
self.send_command(0x71)
busy = epdconfig.digital_read(self.busy_pin)
epdconfig.delay_ms(200)
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
return -1
self.reset()
# self.send_command(0x06) # btst
# self.send_data(0x17)
# self.send_data(0x17)
# self.send_data(0x38) # If an exception is displayed, try using 0x38
# self.send_data(0x17)
self.send_command(0x01); #POWER SETTING
self.send_data(0x07);
self.send_data(0x07); #VGH=20V,VGL=-20V
@ -118,21 +127,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -35,6 +35,8 @@ from . import epdconfig
EPD_WIDTH = 640
EPD_HEIGHT = 384
logger = logging.getLogger(__name__)
class EPD:
def __init__(self):
self.reset_pin = epdconfig.RST_PIN
@ -66,10 +68,10 @@ class EPD:
epdconfig.digital_write(self.cs_pin, 1)
def ReadBusy(self):
logging.debug("e-Paper busy")
logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
epdconfig.delay_ms(100)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def init(self):
if (epdconfig.module_init() != 0):
@ -117,21 +119,21 @@ class EPD:
return 0
def getbuffer(self, image):
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
buf = [0xFF] * (int(self.width/8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
logging.debug('imwidth = %d imheight = %d ',imwidth, imheight)
logger.debug('imwidth = %d imheight = %d ',imwidth, imheight)
if(imwidth == self.width and imheight == self.height):
logging.debug("Horizontal")
logger.debug("Horizontal")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
elif(imwidth == self.height and imheight == self.width):
logging.debug("Vertical")
logger.debug("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y

View file

@ -40,6 +40,8 @@ DC_PIN = 25
CS_PIN = 8
BUSY_PIN = 24
logger = logging.getLogger(__name__)
SPI = spidev.SpiDev()
def digital_write(pin, value):
@ -72,13 +74,13 @@ def module_init():
return 0
def module_exit():
logging.debug("spi end")
logger.debug("spi end")
SPI.close()
logging.debug("close 5V, Module enters 0 power consumption ...")
logger.debug("close 5V, Module enters 0 power consumption ...")
GPIO.output(RST_PIN, 0)
GPIO.output(DC_PIN, 0)
GPIO.cleanup()
### END OF FILE ###
### END OF FILE ###