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

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