diff --git a/2.13inch_e-paper_code/python2/epd2in13.py b/2.13inch_e-paper_code/python2/epd2in13.py index 8a5ba7d..6fe0ca3 100644 --- a/2.13inch_e-paper_code/python2/epd2in13.py +++ b/2.13inch_e-paper_code/python2/epd2in13.py @@ -4,27 +4,10 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V3.0 -# * | Date : 2018-11-01 +# * | This version: V3.1 +# * | Date : 2019-03-20 # * | Info : python2 demo -# * 1.Remove: -# digital_write(self, pin, value) -# digital_read(self, pin) -# delay_ms(self, delaytime) -# set_lut(self, lut) -# self.lut = self.lut_full_update -# * 2.Change: -# display_frame -> TurnOnDisplay -# set_memory_area -> SetWindow -# set_memory_pointer -> SetCursor -# * 3.How to use -# epd = epd2in13.EPD() -# epd.init(epd.lut_full_update) -# image = Image.new('1', (epd2in13.EPD_WIDTH, epd2in13.EPD_HEIGHT), 255) -# ... -# drawing ...... -# ... -# epd.display(getbuffer(image)) +# * fix: TurnOnDisplay() # ******************************************************************************/ # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal @@ -98,10 +81,11 @@ class EPD: epdconfig.delay_ms(100) def TurnOnDisplay(self): - self.send_command(0xC4) # DISPLAY_UPDATE_CONTROL_2 - self.send_data(0xC7) + self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 + self.send_data(0xC4) self.send_command(0x20) # MASTER_ACTIVATION self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE + self.wait_until_idle() def init(self, lut): @@ -226,7 +210,7 @@ class EPD: def sleep(self): self.send_command(0x10) #enter deep sleep - self.send_data(0x01) + # self.send_data(0x01) epdconfig.delay_ms(100) ### END OF FILE ### diff --git a/2.13inch_e-paper_code/python3/epd2in13.py b/2.13inch_e-paper_code/python3/epd2in13.py index be23531..5be748b 100644 --- a/2.13inch_e-paper_code/python3/epd2in13.py +++ b/2.13inch_e-paper_code/python3/epd2in13.py @@ -4,27 +4,10 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V3.0 -# * | Date : 2018-11-01 -# * | Info : python2 demo -# * 1.Remove: -# digital_write(self, pin, value) -# digital_read(self, pin) -# delay_ms(self, delaytime) -# set_lut(self, lut) -# self.lut = self.lut_full_update -# * 2.Change: -# display_frame -> TurnOnDisplay -# set_memory_area -> SetWindow -# set_memory_pointer -> SetCursor -# * 3.How to use -# epd = epd2in13.EPD() -# epd.init(epd.lut_full_update) -# image = Image.new('1', (epd2in13.EPD_WIDTH, epd2in13.EPD_HEIGHT), 255) -# ... -# drawing ...... -# ... -# epd.display(getbuffer(image)) +# * | This version: V3.1 +# * | Date : 2019-03-20 +# * | Info : python3 demo +# * fix: TurnOnDisplay() # ******************************************************************************// # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal @@ -94,12 +77,14 @@ class EPD: epdconfig.spi_writebyte([data]) def wait_until_idle(self): + print("busy") while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) + epdconfig.delay_ms(100) + print("free busy") def TurnOnDisplay(self): - self.send_command(0xC4) # DISPLAY_UPDATE_CONTROL_2 - self.send_data(0xC7) + self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 + self.send_data(0xC4) self.send_command(0x20) # MASTER_ACTIVATION self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE self.wait_until_idle() @@ -226,7 +211,7 @@ class EPD: def sleep(self): self.send_command(0x10) #enter deep sleep - self.send_data(0x01) + # self.send_data(0x01) epdconfig.delay_ms(100) ### END OF FILE ### diff --git a/2.13inch_e-paper_code/python3/main.py b/2.13inch_e-paper_code/python3/main.py index d1cbdae..efd9e90 100644 --- a/2.13inch_e-paper_code/python3/main.py +++ b/2.13inch_e-paper_code/python3/main.py @@ -11,57 +11,57 @@ try: epd.init(epd.lut_full_update) epd.Clear(0xFF) - # read bmp file on window - print("read bmp file on window") - epd.Clear(0xFF) - image1 = Image.new('1', (epd2in13.EPD_WIDTH, epd2in13.EPD_HEIGHT), 255) # 255: clear the frame - bmp = Image.open('100x100.bmp') - image1.paste(bmp, (10,10)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) + # # read bmp file on window + # print("read bmp file on window") + # epd.Clear(0xFF) + # image1 = Image.new('1', (epd2in13.EPD_WIDTH, epd2in13.EPD_HEIGHT), 255) # 255: clear the frame + # bmp = Image.open('100x100.bmp') + # image1.paste(bmp, (10,10)) + # epd.display(epd.getbuffer(image1)) + # time.sleep(2) - # Drawing on the image - image2 = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) # 255: clear the frame - # read bmp file - print("read bmp file") - epd.Clear(0xFF) - image2 = Image.open('2in13.bmp') - epd.display(epd.getbuffer(image2.rotate(180))) + # # Drawing on the image + # image2 = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) # 255: clear the frame + # # read bmp file + # print("read bmp file") + # epd.Clear(0xFF) + # image2 = Image.open('2in13.bmp') + # epd.display(epd.getbuffer(image2.rotate(180))) - print("Drawing") - epd.Clear(0xFF) - image = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) # 255: clear the frame - draw = ImageDraw.Draw(image) - draw.rectangle([(0,0),(50,50)],outline = 0) - draw.rectangle([(55,0),(100,50)],fill = 0) - draw.line([(0,0),(50,50)], fill = 0,width = 1) - draw.line([(0,50),(50,0)], fill = 0,width = 1) - draw.chord((10, 60, 50, 100), 0, 360, fill = 0) - draw.ellipse((55, 60, 95, 100), outline = 0) - draw.pieslice((55, 60, 95, 100), 90, 180, outline = 0) - draw.pieslice((55, 60, 95, 100), 270, 360, fill = 0) - draw.polygon([(110,0),(110,50),(150,25)],outline = 0) - draw.polygon([(190,0),(190,50),(150,25)],fill = 0) - font15 = ImageFont.truetype('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', 15) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - # draw.text((110, 80), 'Hello world', font = font15, fill = 0) - epd.display(epd.getbuffer(image.rotate(180))) - time.sleep(2) + # print("Drawing") + # epd.Clear(0xFF) + # image = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) # 255: clear the frame + # draw = ImageDraw.Draw(image) + # draw.rectangle([(0,0),(50,50)],outline = 0) + # draw.rectangle([(55,0),(100,50)],fill = 0) + # draw.line([(0,0),(50,50)], fill = 0,width = 1) + # draw.line([(0,50),(50,0)], fill = 0,width = 1) + # draw.chord((10, 60, 50, 100), 0, 360, fill = 0) + # draw.ellipse((55, 60, 95, 100), outline = 0) + # draw.pieslice((55, 60, 95, 100), 90, 180, outline = 0) + # draw.pieslice((55, 60, 95, 100), 270, 360, fill = 0) + # draw.polygon([(110,0),(110,50),(150,25)],outline = 0) + # draw.polygon([(190,0),(190,50),(150,25)],fill = 0) + # font15 = ImageFont.truetype('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', 15) + # draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) + # # draw.text((110, 80), 'Hello world', font = font15, fill = 0) + # epd.display(epd.getbuffer(image.rotate(180))) + # time.sleep(2) - # partial update - print("Show time") - epd.init(epd.lut_partial_update) - font24 = ImageFont.truetype('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', 24) - # time_image = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) - draw = ImageDraw.Draw(image) - while (True): - draw.rectangle((120, 80, 220, 105), fill = 255) - draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - # newimage = time_image.crop([10, 10, 120, 50]) - # time_image.paste(newimage, (10,10)) - epd.display(epd.getbuffer(image.rotate(180))) + # # partial update + # print("Show time") + # epd.init(epd.lut_partial_update) + # font24 = ImageFont.truetype('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', 24) + # # time_image = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), 255) + # draw = ImageDraw.Draw(image) + # while (True): + # draw.rectangle((120, 80, 220, 105), fill = 255) + # draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) + # # newimage = time_image.crop([10, 10, 120, 50]) + # # time_image.paste(newimage, (10,10)) + # epd.display(epd.getbuffer(image.rotate(180))) - epd.sleep() + # epd.sleep() except: print( 'traceback.format_exc():\n%s',traceback.format_exc())