Add named logger

This commit is contained in:
missionfloyd 2021-08-01 17:52:15 -06:00 committed by GitHub
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

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