Add named logger

This commit is contained in:
missionfloyd 2021-08-01 17:52:15 -06:00 committed by GitHub
parent 551b05e2f7
commit 2a10334edc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 286 additions and 208 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
@ -134,10 +136,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(20)
logging.debug("e-Paper busy release")
logger.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2
@ -198,7 +200,7 @@ class EPD:
return -1
if(isPartial):
logging.debug("partial refresh")
logger.debug("partial refresh")
self.reset()
self.ReadBusy()
@ -225,7 +227,7 @@ class EPD:
self.ReadBusy()
else:
logging.debug("full refresh")
logger.debug("full refresh")
# EPD hardware init start
self.reset()
@ -273,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

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,7 +409,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

@ -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