diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f7f154 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +Python/build/ +Python/dist/ +*.egg-info/ +*.pyc +__pycache__/ diff --git a/Jetson Nano/python2/examples/epd_1in54_test.py b/Jetson Nano/python2/examples/epd_1in54_test.py deleted file mode 100644 index 92f619f..0000000 --- a/Jetson Nano/python2/examples/epd_1in54_test.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54 Demo") - - epd = epd1in54.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_1in54b_test.py b/Jetson Nano/python2/examples/epd_1in54b_test.py deleted file mode 100644 index d48b8e2..0000000 --- a/Jetson Nano/python2/examples/epd_1in54b_test.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54b Demo") - - epd = epd1in54b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawred = ImageDraw.Draw(redimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font18, fill = 0) - drawblack.line((16, 60, 56, 60), fill = 0) - drawblack.line((56, 60, 56, 110), fill = 0) - drawblack.line((16, 110, 56, 110), fill = 0) - drawred.line((16, 110, 16, 60), fill = 0) - drawred.line((16, 60, 56, 110), fill = 0) - drawred.line((56, 60, 16, 110), fill = 0) - drawred.arc((90, 60, 150, 120), 0, 360, fill = 0) - drawred.rectangle((16, 130, 56, 180), fill = 0) - drawred.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54b-b.bmp') - redimage = Image.open('../pic/1in54b-r.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_1in54c_test.py b/Jetson Nano/python2/examples/epd_1in54c_test.py deleted file mode 100644 index 7374e6d..0000000 --- a/Jetson Nano/python2/examples/epd_1in54c_test.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54c -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54c Demo") - - epd = epd1in54c.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawyellow = ImageDraw.Draw(yellowimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font, fill = 0) - drawblack.line((10, 100, 70, 100), fill = 0) - drawblack.line((40, 70, 40, 130), fill = 0) - - drawyellow.rectangle((10, 70, 70, 130), outline = 0) - drawyellow.arc((80, 70, 140, 130), 0, 360, fill = 0) - drawyellow.chord((90, 80, 130, 120), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54c-b.bmp') - yellowimage = Image.open('../pic/1in54c-y.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(yellowimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in13_V2_test.py b/Jetson Nano/python2/examples/epd_2in13_V2_test.py deleted file mode 100644 index 85f5ee7..0000000 --- a/Jetson Nano/python2/examples/epd_2in13_V2_test.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13_V2 Demo") - - epd = epd2in13_V2.EPD() - print("init and Clear") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - - epd.init(epd.FULL_UPDATE) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - epd.init(epd.PART_UPDATE) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.displayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in13_test.py b/Jetson Nano/python2/examples/epd_2in13_test.py deleted file mode 100644 index 1081d79..0000000 --- a/Jetson Nano/python2/examples/epd_2in13_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13 Demo") - - epd = epd2in13.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in13bc_test.py b/Jetson Nano/python2/examples/epd_2in13bc_test.py deleted file mode 100644 index ad24c87..0000000 --- a/Jetson Nano/python2/examples/epd_2in13bc_test.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13bc Demo") - - epd = epd2in13bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font20 = ImageFont.truetype('../lib/Font.ttc', 20) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font20, fill = 0) - drawblack.text((10, 20), '2.13inch e-Paper bc', font = font20, fill = 0) - drawblack.text((120, 0), u'微雪电子', font = font20, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((85, 55, 125, 95), 0, 360, fill =1) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.13 epd b', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.arc((15, 95, 55, 135), 0, 360, fill = 0) - drawry.chord((15, 155, 55, 195), 0, 360, fill =1) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in13bc-b.bmp') - HRYimage = Image.open('../pic/2in13bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (10,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in7_test.py b/Jetson Nano/python2/examples/epd_2in7_test.py deleted file mode 100644 index 24a7c43..0000000 --- a/Jetson Nano/python2/examples/epd_2in7_test.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7 Demo") - - epd = epd2in7.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in7.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in9bc_test.py b/Jetson Nano/python2/examples/epd_2in9bc_test.py deleted file mode 100644 index b16809d..0000000 --- a/Jetson Nano/python2/examples/epd_2in9bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9bc Demo") - - epd = epd2in9bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in9bc-b.bmp') - HRYimage = Image.open('../pic/2in9bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_2in9d_test.py b/Jetson Nano/python2/examples/epd_2in9d_test.py deleted file mode 100644 index 34f5f71..0000000 --- a/Jetson Nano/python2/examples/epd_2in9d_test.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9d Demo") - - epd = epd2in9d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper d', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd d', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_4in2_test.py b/Jetson Nano/python2/examples/epd_4in2_test.py deleted file mode 100644 index 6343f58..0000000 --- a/Jetson Nano/python2/examples/epd_4in2_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2 Demo") - - epd = epd4in2.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '4.2inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '4.2inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/4in2.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_4in2bc_test.py b/Jetson Nano/python2/examples/epd_4in2bc_test.py deleted file mode 100644 index ad1abda..0000000 --- a/Jetson Nano/python2/examples/epd_4in2bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2bc Demo") - - epd = epd4in2bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '4.2inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '4.2inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/4in2b-b.bmp') - HRYimage = Image.open('../pic/4in2b-r.bmp') - # HBlackimage = Image.open('../pic/4in2c-b.bmp') - # HRYimage = Image.open('../pic/4in2c-y.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_7in5_test.py b/Jetson Nano/python2/examples/epd_7in5_test.py deleted file mode 100644 index eaf11ec..0000000 --- a/Jetson Nano/python2/examples/epd_7in5_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5 Demo") - - epd = epd7in5.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '7.5inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '7.5inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/7in5.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/examples/epd_7in5bc_test.py b/Jetson Nano/python2/examples/epd_7in5bc_test.py deleted file mode 100644 index 82153b4..0000000 --- a/Jetson Nano/python2/examples/epd_7in5bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5bc Demo") - - epd = epd7in5bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '7.5inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '7.5inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/7in5b-b.bmp') - HRYimage = Image.open('../pic/7in5b-r.bmp') - # HBlackimage = Image.open('../pic/7in5c-b.bmp') - # HRYimage = Image.open('../pic/7in5c-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python2/lib/epd1in54.py b/Jetson Nano/python2/lib/epd1in54.py deleted file mode 100644 index ffd2815..0000000 --- a/Jetson Nano/python2/lib/epd1in54.py +++ /dev/null @@ -1,254 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V3.1 -# * | Date : 2019-06-18 -# # | Info : python2 demo -# ----------------------------------------------------------------------------- -# V3.1(2019-06-18): -# 2.remove commands define: -# #define PANEL_SETTING 0x00 -# #define POWER_SETTING 0x01 -# #define POWER_OFF 0x02 -# #define POWER_OFF_SEQUENCE_SETTING 0x03 -# #define POWER_ON 0x04 -# #define POWER_ON_MEASURE 0x05 -# #define BOOSTER_SOFT_START 0x06 -# #define DEEP_SLEEP 0x07 -# #define DATA_START_TRANSMISSION_1 0x10 -# #define DATA_STOP 0x11 -# #define DISPLAY_REFRESH 0x12 -# #define DATA_START_TRANSMISSION_2 0x13 -# #define PLL_CONTROL 0x30 -# #define TEMPERATURE_SENSOR_COMMAND 0x40 -# #define TEMPERATURE_SENSOR_CALIBRATION 0x41 -# #define TEMPERATURE_SENSOR_WRITE 0x42 -# #define TEMPERATURE_SENSOR_READ 0x43 -# #define VCOM_AND_DATA_INTERVAL_SETTING 0x50 -# #define LOW_POWER_DETECTION 0x51 -# #define TCON_SETTING 0x60 -# #define TCON_RESOLUTION 0x61 -# #define SOURCE_AND_GATE_START_SETTING 0x62 -# #define GET_STATUS 0x71 -# #define AUTO_MEASURE_VCOM 0x80 -# #define VCOM_VALUE 0x81 -# #define VCM_DC_SETTING_REGISTER 0x82 -# #define PROGRAM_MODE 0xA0 -# #define ACTIVE_PROGRAM 0xA1 -# #define READ_OTP_DATA 0xA2 -# ----------------------------------------------------------------------------- -# V3.0(2018-11-01): -# # 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 = epd1in54.EPD() -# epd.init(epd.lut_full_update) -# image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) -# ... -# drawing ...... -# ... -# epd.display(getbuffer(image)) -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, - 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, - 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - 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.ReadBusy() - - 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 - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - # set the look-up table register - self.send_command(0x32) - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - # self.SetWindow(0, 0, self.width - 1, self.height - 1) - # send the color data - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width / 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd1in54.pyc b/Jetson Nano/python2/lib/epd1in54.pyc deleted file mode 100644 index 36b73c0..0000000 Binary files a/Jetson Nano/python2/lib/epd1in54.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd1in54_V2.pyc b/Jetson Nano/python2/lib/epd1in54_V2.pyc deleted file mode 100644 index 2daa315..0000000 Binary files a/Jetson Nano/python2/lib/epd1in54_V2.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd1in54b.py b/Jetson Nano/python2/lib/epd1in54b.py deleted file mode 100644 index a7ac01d..0000000 --- a/Jetson Nano/python2/lib/epd1in54b.py +++ /dev/null @@ -1,218 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-18 -# * | Info : python2 demo -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A, 0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00] - lut_w = [0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04] - lut_b = [0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04] - lut_g1 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_g2 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_vcom1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red0 = [0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut_bw(self): - self.send_command(0x20) # vcom - for count in range(0, 15): - self.send_data(self.lut_vcom0[count]) - self.send_command(0x21) # ww -- - for count in range(0, 15): - self.send_data(self.lut_w[count]) - self.send_command(0x22) # bw r - for count in range(0, 15): - self.send_data(self.lut_b[count]) - self.send_command(0x23) # wb w - for count in range(0, 15): - self.send_data(self.lut_g1[count]) - self.send_command(0x24) # bb b - for count in range(0, 15): - self.send_data(self.lut_g2[count]) - - def set_lut_red(self): - self.send_command(0x25) - for count in range(0, 15): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x26) - for count in range(0, 15): - self.send_data(self.lut_red0[count]) - self.send_command(0x27) - for count in range(0, 15): - self.send_data(self.lut_red1[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(0x00) - self.send_data(0x08) - self.send_data(0x00) - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x07) - self.send_command(0x04) # POWER_ON - - self.ReadBusy() - - self.send_command(0X00) # PANEL_SETTING - self.send_data(0xCF) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x39) - self.send_command(0x61) # TCON_RESOLUTION set x and y - self.send_data(0xC8) - self.send_data(0x00) - self.send_data(0xC8) - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x0E) - - self.set_lut_bw() - self.set_lut_red() - return 0 - - def getbuffer(self, image): - buf = [0xFF] * (self.width * self.height / 8) - # Set buffer to value of Python Imaging Library image. - # Image must be in mode 1. - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display \ - ({0}x{1}).' .format(self.width, self.height)) - - pixels = image_monocolor.load() - for y in range(self.height): - for x in range(self.width): - # Set the bits for the column of pixels at the current position. - if pixels[x, y] == 0: - buf[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - return buf - - def display(self, blackimage, redimage): - # send black data - if (blackimage != None): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height / 8): - temp = 0x00 - for bit in range(0, 4): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> (bit * 2) - self.send_data(temp) - temp = 0x00 - for bit in range(4, 8): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> ((bit - 4) * 2) - self.send_data(temp) - - # send red data - if (redimage != None): - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height / 8): - self.send_data(redimage[i]) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_data(0xFF) - - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x82) # to solve Vcom drop - self.send_data(0x00) - self.send_command(0x01) # power setting - self.send_data(0x02) # gate switch to external - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - self.ReadBusy() - - self.send_command(0x02) # power off - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd1in54b.pyc b/Jetson Nano/python2/lib/epd1in54b.pyc deleted file mode 100644 index 846bbee..0000000 Binary files a/Jetson Nano/python2/lib/epd1in54b.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd1in54c.py b/Jetson Nano/python2/lib/epd1in54c.py deleted file mode 100644 index 8231aca..0000000 --- a/Jetson Nano/python2/lib/epd1in54c.py +++ /dev/null @@ -1,152 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54c.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-18 -# * | Info : python2 demo -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -import epdconfig - -# Display resolution -EPD_WIDTH = 152 -EPD_HEIGHT = 152 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(1) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - self.send_command(0x04) # power on - - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0x0f) # LUT from OTP,160x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x61) # resolution setting - self.send_data(0x98) - self.send_data(0x00) - self.send_data(0x98) - - self.send_command(0x50) - self.send_data(0x77) - - def getbuffer(self, image): - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, yellowimage): - self.send_command(0x10) - print("blackimage") - for i in range(0, self.width * self.height / 8): - self.send_data(blackimage[i]) - self.send_command(0x13) - print("yellowimage") - for i in range(0, self.width * self.height / 8): - self.send_data(yellowimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - # after this, call epd.init() to awaken the module - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd1in54c.pyc b/Jetson Nano/python2/lib/epd1in54c.pyc deleted file mode 100644 index 3bd7cbe..0000000 Binary files a/Jetson Nano/python2/lib/epd1in54c.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in13.py b/Jetson Nano/python2/lib/epd2in13.py deleted file mode 100644 index 39b1914..0000000 --- a/Jetson Nano/python2/lib/epd2in13.py +++ /dev/null @@ -1,224 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("e-Paper busy release") - - def init(self, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0X3C) # BORDER_WAVEFORM_CONTROL - self.send_data(0x03) - - self.send_command(0X11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment; Y increment - - # WRITE_LUT_REGISTER - self.send_command(0x32) - for count in range(30): - self.send_data(lut[count]) - - return 0 - -## - # @brief: specify the memory area for data R/W - ## - def SetWindows(self, x_start, y_start, x_end, y_end): - self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - -## - # @brief: specify the start point for data R/W - ## - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER - self.send_data(y & 0xFF) - self.send_data((y >> 8) & 0xFF) - self.ReadBusy() - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - # x = imwidth - x - buf[x / 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - # newy = imwidth - newy - 1 - buf[newx / 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in13.pyc b/Jetson Nano/python2/lib/epd2in13.pyc deleted file mode 100644 index b350d67..0000000 Binary files a/Jetson Nano/python2/lib/epd2in13.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in13_V2.pyc b/Jetson Nano/python2/lib/epd2in13_V2.pyc deleted file mode 100644 index c2480b5..0000000 Binary files a/Jetson Nano/python2/lib/epd2in13_V2.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in13bc.py b/Jetson Nano/python2/lib/epd2in13bc.py deleted file mode 100644 index 04f3512..0000000 --- a/Jetson Nano/python2/lib/epd2in13bc.py +++ /dev/null @@ -1,158 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x8F) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0xF0) - - self.send_command(0x61) # RESOLUTION_SETTING - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) - self.send_data(self.height & 0xff) - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(imageblack[i]) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(imagered[i]) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in13bc.pyc b/Jetson Nano/python2/lib/epd2in13bc.pyc deleted file mode 100644 index 789e1a1..0000000 Binary files a/Jetson Nano/python2/lib/epd2in13bc.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in13d.py b/Jetson Nano/python2/lib/epd2in13d.py deleted file mode 100644 index 30ebb77..0000000 --- a/Jetson Nano/python2/lib/epd2in13d.py +++ /dev/null @@ -1,357 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) # PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print "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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print "Horizontal" - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (Image == None): - return - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - if (Image == None): - return - - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height / 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) # power off - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in13d.pyc b/Jetson Nano/python2/lib/epd2in13d.pyc deleted file mode 100644 index c585890..0000000 Binary files a/Jetson Nano/python2/lib/epd2in13d.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in7.py b/Jetson Nano/python2/lib/epd2in7.py deleted file mode 100644 index 9d5fca6..0000000 --- a/Jetson Nano/python2/lib/epd2in7.py +++ /dev/null @@ -1,258 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in7.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA0) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA1) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xAF) # KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.set_lut() - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - self.send_command(0x12) - self.ReadBusy() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in7.pyc b/Jetson Nano/python2/lib/epd2in7.pyc deleted file mode 100644 index 89c55ab..0000000 Binary files a/Jetson Nano/python2/lib/epd2in7.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in7b.py b/Jetson Nano/python2/lib/epd2in7b.py deleted file mode 100644 index 358adb4..0000000 --- a/Jetson Nano/python2/lib/epd2in7b.py +++ /dev/null @@ -1,266 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in7b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [ - 0x00, 0x00, - 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - lut_ww = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R22H r - lut_bw = [ - 0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0xB0, 0x04, 0x10, 0x00, 0x00, 0x05, - 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R23H w - lut_bb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - # R24H b - lut_wb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xaf) #KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3a) #3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x87) # define by OTP - - self.set_lut() - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(~imageblack[i]) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~imagered[i]) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in7b.pyc b/Jetson Nano/python2/lib/epd2in7b.pyc deleted file mode 100644 index f88a113..0000000 Binary files a/Jetson Nano/python2/lib/epd2in7b.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in9.py b/Jetson Nano/python2/lib/epd2in9.py deleted file mode 100644 index 9e2bd6d..0000000 --- a/Jetson Nano/python2/lib/epd2in9.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(200) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("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 - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - self.send_command(0x32) # WRITE_LUT_REGISTER - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width / 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in9.pyc b/Jetson Nano/python2/lib/epd2in9.pyc deleted file mode 100644 index bbcf85c..0000000 Binary files a/Jetson Nano/python2/lib/epd2in9.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in9bc.py b/Jetson Nano/python2/lib/epd2in9bc.py deleted file mode 100644 index baee127..0000000 --- a/Jetson Nano/python2/lib/epd2in9bc.py +++ /dev/null @@ -1,154 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - self.send_command(0X00) # PANEL_SETTING - self.send_data(0x8F) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - self.send_command(0x61) # TCON_RESOLUTION - self.send_data (0x80) - self.send_data (0x01) - self.send_data (0x28) - # self.send_command(VCM_DC_SETTING_REGISTER) - # self.send_data (0x0A) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, ryimage): # ryimage: red or yellow image - if (blackimage != None): - self.send_command(0X10) - for i in range(0, self.width * self.height / 8): - self.send_data(blackimage[i]) - if (ryimage != None): - self.send_command(0X13) - for i in range(0, self.width * self.height / 8): - self.send_data(ryimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0X10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xff) - self.send_command(0X13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xff) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in9bc.pyc b/Jetson Nano/python2/lib/epd2in9bc.pyc deleted file mode 100644 index f35e880..0000000 Binary files a/Jetson Nano/python2/lib/epd2in9bc.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd2in9d.py b/Jetson Nano/python2/lib/epd2in9d.py deleted file mode 100644 index ab0212c..0000000 --- a/Jetson Nano/python2/lib/epd2in9d.py +++ /dev/null @@ -1,350 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V2.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) #PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height / 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) #power off - self.send_command(0X07) #deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd2in9d.pyc b/Jetson Nano/python2/lib/epd2in9d.pyc deleted file mode 100644 index 4fea169..0000000 Binary files a/Jetson Nano/python2/lib/epd2in9d.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd4in2.py b/Jetson Nano/python2/lib/epd4in2.py deleted file mode 100644 index 36c07b1..0000000 --- a/Jetson Nano/python2/lib/epd4in2.py +++ /dev/null @@ -1,240 +0,0 @@ -# /***************************************************************************** -# * | File : epd4in2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [ - 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_ww = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom0[count]) - - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # KW-BF KWR-AF BWROTP 0f - self.send_data(0x0d) - - self.send_command(0x30) # PLL setting - self.send_data(0x3c) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(0x01) - self.send_data(0x90) # 128 - self.send_data(0x01) - self.send_data(0x2c) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x97) # 97white border 77black border VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - - self.set_lut() - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print "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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print "Vertical" - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd4in2.pyc b/Jetson Nano/python2/lib/epd4in2.pyc deleted file mode 100644 index 8d0194f..0000000 Binary files a/Jetson Nano/python2/lib/epd4in2.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd4in2bc.py b/Jetson Nano/python2/lib/epd4in2bc.py deleted file mode 100644 index 0760c48..0000000 --- a/Jetson Nano/python2/lib/epd4in2bc.py +++ /dev/null @@ -1,147 +0,0 @@ -# /***************************************************************************** -# * | File : epd4in2bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) # 07 0f 17 1f 27 2F 37 2f - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x0F) # LUT from OTP - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(imageblack[i]) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(imagered[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd4in2bc.pyc b/Jetson Nano/python2/lib/epd4in2bc.pyc deleted file mode 100644 index ef2ec4a..0000000 Binary files a/Jetson Nano/python2/lib/epd4in2bc.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd5in83.py b/Jetson Nano/python2/lib/epd5in83.py deleted file mode 100644 index e309db0..0000000 --- a/Jetson Nano/python2/lib/epd5in83.py +++ /dev/null @@ -1,199 +0,0 @@ -# /***************************************************************************** -# * | File : epd5in83.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xC0) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height / 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) / 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) / 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) / 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) / 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd5in83.pyc b/Jetson Nano/python2/lib/epd5in83.pyc deleted file mode 100644 index ec4406c..0000000 Binary files a/Jetson Nano/python2/lib/epd5in83.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd5in83bc.py b/Jetson Nano/python2/lib/epd5in83bc.py deleted file mode 100644 index 60ef7d6..0000000 --- a/Jetson Nano/python2/lib/epd5in83bc.py +++ /dev/null @@ -1,199 +0,0 @@ -# /***************************************************************************** -# * | File : epd5in83b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - self.send_command(0X82) # VCOM VOLTAGE SETTING - self.send_data(0x28) # all temperature range - - self.send_command(0x06) # boost - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0X60) # TCON SETTING - self.send_data(0x22) - - self.send_command(0X65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # tres - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xc0) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd5in83bc.pyc b/Jetson Nano/python2/lib/epd5in83bc.pyc deleted file mode 100644 index 56cd1b8..0000000 Binary files a/Jetson Nano/python2/lib/epd5in83bc.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd7in5.py b/Jetson Nano/python2/lib/epd7in5.py deleted file mode 100644 index 6e5a70f..0000000 --- a/Jetson Nano/python2/lib/epd7in5.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd7in5.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(EPD_WIDTH >> 8) #source 640 - self.send_data(EPD_WIDTH & 0xff) - self.send_data(EPD_HEIGHT >> 8) #gate 384 - self.send_data(EPD_HEIGHT & 0xff) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height / 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) / 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) / 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) / 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) / 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd7in5.pyc b/Jetson Nano/python2/lib/epd7in5.pyc deleted file mode 100644 index 2b03b1f..0000000 Binary files a/Jetson Nano/python2/lib/epd7in5.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epd7in5bc.py b/Jetson Nano/python2/lib/epd7in5bc.py deleted file mode 100644 index 58157f8..0000000 --- a/Jetson Nano/python2/lib/epd7in5bc.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd7in5bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x28) #all temperature range - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0x50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(self.width >> 8) # source 640 - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) # gate 384 - self.send_data(self.height & 0xff) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python2/lib/epd7in5bc.pyc b/Jetson Nano/python2/lib/epd7in5bc.pyc deleted file mode 100644 index 4aff03d..0000000 Binary files a/Jetson Nano/python2/lib/epd7in5bc.pyc and /dev/null differ diff --git a/Jetson Nano/python2/lib/epdconfig.py b/Jetson Nano/python2/lib/epdconfig.py deleted file mode 100644 index 403d6a1..0000000 --- a/Jetson Nano/python2/lib/epdconfig.py +++ /dev/null @@ -1,97 +0,0 @@ -# /***************************************************************************** -# * | File : epdconfig.py -# * | Author : Waveshare team -# * | Function : Hardware underlying interface -# * | Info : -# *---------------- -# * | This version: V1.0 -# * | Date : 2019-06-06 -# * | Info : -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import Jetson.GPIO as GPIO -import time - -import ctypes -# import spidev - -# Pin definition -RST_PIN = 17 -DC_PIN = 25 -CS_PIN = 8 -BUSY_PIN = 24 - -# SPI device, bus = 0, device = 0 -# SPI = spidev.SpiDev(0, 0) - -clib = ctypes.cdll.LoadLibrary -spi = clib('../lib/sysfs_software_spi.so') -# gpio2 = clib('../lib/sysfs_gpio.so') - -def digital_write(pin, value): - GPIO.output(pin, value) - -def digital_read(pin): - return GPIO.input(BUSY_PIN) - # return gpio2.SYSFS_GPIO_Read(15) - -def delay_ms(delaytime): - time.sleep(delaytime / 1000.0) - -def spi_writebyte(data): - # SPI.writebytes(data) - spi.SYSFS_software_spi_transfer(data[0]) - -def module_init(): - # print("module_init") - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - # print("RST_PIN") - GPIO.setup(RST_PIN, GPIO.OUT) - # print("DC_PIN") - GPIO.setup(DC_PIN, GPIO.OUT) - # print("CS_PIN") - GPIO.setup(CS_PIN, GPIO.OUT) - # print("BUSY_PIN") - GPIO.setup(BUSY_PIN, GPIO.IN) - # SPI.max_speed_hz = 2000000 - # SPI.mode = 0b00 - - # gpio2.SYSFS_GPIO_Export(15) - # gpio2.SYSFS_GPIO_Direction(15, 0) - - spi.SYSFS_software_spi_begin() - return 0 - - -def module_exit(): - print("spi end") - spi.SYSFS_software_spi_end() - - print("close 5V, Module enters 0 power consumption ...") - GPIO.output(RST_PIN, 0) - GPIO.output(DC_PIN, 0) - - GPIO.cleanup() - - - -### END OF FILE ### diff --git a/Jetson Nano/python2/lib/epdconfig.pyc b/Jetson Nano/python2/lib/epdconfig.pyc deleted file mode 100644 index da933d7..0000000 Binary files a/Jetson Nano/python2/lib/epdconfig.pyc and /dev/null differ diff --git a/Jetson Nano/python2/readme_CN.txt b/Jetson Nano/python2/readme_CN.txt deleted file mode 100644 index 38eb743..0000000 --- a/Jetson Nano/python2/readme_CN.txt +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** -* | File : Readme_CN.txt -* | Author : Waveshare team -* | Function : Help with use -* | Info : -*---------------- -* | This version: V1.0 -* | Date : 2019-06-20 -* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 -******************************************************************************/ -这个文件是帮助您使用本例程。 -由于我们的墨水屏越来越多,不便于我们的维护,因此把所有的墨水屏程序做成一个工程。 -在这里简略的描述本工程的使用: - -1.基本信息: -本例程是基于jetson-nano-sd-r32.1-2019-03-18系统镜像而开发的,由于目前的系统是没有硬件SPI的, -目前采用模拟SPI进行开发的,因此墨水屏的刷新速度较慢; -本例程是基于Jetson Nano进行开发的,例程均在Jetson Nano上进行了验证; -本例程使用e-paper Driver HAT模块进行了验证,你可以在工程的examples\中查看对应的测试例程; - -2.管脚连接: -管脚连接你可以在\lib\epdconfig.py中查看,这里也再重述一次: -EPD => Jetson Nano/RPI(BCM) -VCC -> 3.3 -GND -> GND -DIN -> 10(SPI0_MOSI) -CLK -> 11(SPI0_SCK) -CS -> 8(SPI0_CS0) -DC -> 25 -RST -> 17 -BUSY -> 24 - -3.安装库: - sudo apt-get update - sudo apt-get install python3-pip - sudo apt-get install python3-pil - sudo apt-get install python3-numpy - sudo pip3 install Jetson.GPIO - -4.基本使用: -由于本工程是一个综合工程,对于使用而言,你可能需要阅读以下内容: -你可以在examples\目录中查看测试程序 -请注意你购买的是哪一款的墨水屏。 -栗子1: - 如果你购买的5.83inch e-paper,那么你应该执行命令: - sudo python epd_5in83_test.py -栗子2: - 如果你购买的2.9inch e-paper (B),由于2.9寸的B型和C型是公用的驱动代码, - 那么你应该执行命令: - sudo python epd_2in9bc_test.py - -注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 \ No newline at end of file diff --git a/Jetson Nano/python2/readme_EN.txt b/Jetson Nano/python2/readme_EN.txt deleted file mode 100644 index 2904db3..0000000 --- a/Jetson Nano/python2/readme_EN.txt +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** -* | File : Readme_CN.txt -* | Author : Waveshare team -* | Function : Help with use -* | Info : -*---------------- -* | This version: V1.0 -* | Date : 2019-06-20 -* | Info : Here is an English version of the documentation for your quick use. -******************************************************************************/ -This file is to help you use this routine. -Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project. -A brief description of the use of this project is here: - -1. Basic information: -This routine was developed based on the jetson-nano-sd-r32.1-2019-03-18 system -image. Since the current system does not have a hardware SPI,Currently developed -with analog SPI, so the ink screen refresh rate is slower; -This routine was developed based on the Jetson Nano and the routines were -verified on the Jetson Nano; -This routine has been verified using the e-paper Driver HAT module. -You can view the corresponding test routines in the examples\ -of the project. - -2. Pin connection: -Pin connections can be viewed in \lib\epdconfig.py and will be repeated here: -EPD => Jetson Nano/RPI(BCM) -VCC -> 3.3 -GND -> GND -DIN -> 10(SPI0_MOSI) -CLK -> 11(SPI0_SCK) -CS -> 8(SPI0_CS0) -DC -> 25 -RST -> 17 -BUSY -> 24 - -3.Installation library - sudo apt-get update - sudo apt-get install python3-pip - sudo apt-get install python3-pil - sudo apt-get install python3-numpy - sudo pip3 install Jetson.GPIO - -4. Basic use: -Since this project is a comprehensive project, you may need to read the following for use: -You can view the test program in the examples\ directory. -Please note which ink screen you purchased. -Chestnut 1: -     If you purchased 5.83inch e-paper, then you should execute the command: -     Sudo python epd_5in83_test.py -Chestnut 2: -     If you buy a 2.9inch e-paper (B), since the 2.9-inch Type B and Type C are common driver codes, -     Then you should execute the command: -     Sudo python epd_2in9bc_test.py -     -Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. \ No newline at end of file diff --git a/Jetson Nano/python3/examples/epd_1in54_V2_test.py b/Jetson Nano/python3/examples/epd_1in54_V2_test.py deleted file mode 100644 index 2e51114..0000000 --- a/Jetson Nano/python3/examples/epd_1in54_V2_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54_V2 Demo") - - epd = epd1in54_V2.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # partial update - print("4.show time...") - time_image = Image.new('1', (epd.width, epd.height), 255) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.displayPart(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init() - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() \ No newline at end of file diff --git a/Jetson Nano/python3/examples/epd_1in54_test.py b/Jetson Nano/python3/examples/epd_1in54_test.py deleted file mode 100644 index 7844db3..0000000 --- a/Jetson Nano/python3/examples/epd_1in54_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54 Demo") - - epd = epd1in54.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_1in54c_test.py b/Jetson Nano/python3/examples/epd_1in54c_test.py deleted file mode 100644 index 7374e6d..0000000 --- a/Jetson Nano/python3/examples/epd_1in54c_test.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54c -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54c Demo") - - epd = epd1in54c.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawyellow = ImageDraw.Draw(yellowimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font, fill = 0) - drawblack.line((10, 100, 70, 100), fill = 0) - drawblack.line((40, 70, 40, 130), fill = 0) - - drawyellow.rectangle((10, 70, 70, 130), outline = 0) - drawyellow.arc((80, 70, 140, 130), 0, 360, fill = 0) - drawyellow.chord((90, 80, 130, 120), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54c-b.bmp') - yellowimage = Image.open('../pic/1in54c-y.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(yellowimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_2in13d_test.py b/Jetson Nano/python3/examples/epd_2in13d_test.py deleted file mode 100644 index 883ccb3..0000000 --- a/Jetson Nano/python3/examples/epd_2in13d_test.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13d Demo") - - epd = epd2in13d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - 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) - draw.text((110, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 80), u'微雪电子', font = font15, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in13d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (20,20)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font24, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.DisplayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_2in7b_test.py b/Jetson Nano/python3/examples/epd_2in7b_test.py deleted file mode 100644 index ece7390..0000000 --- a/Jetson Nano/python3/examples/epd_2in7b_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7b Demo") - - epd = epd2in7b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - - drawblack = ImageDraw.Draw(HBlackimage) - drawred = ImageDraw.Draw(HRedimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawred.line((165, 50, 165, 100), fill = 0) - drawred.line((140, 75, 190, 75), fill = 0) - drawred.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawred.rectangle((80, 50, 130, 100), fill = 0) - drawred.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRedimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawred = ImageDraw.Draw(LRedimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawred.line((95, 90, 95, 140), fill = 0) - drawred.line((70, 115, 120, 115), fill = 0) - drawred.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawred.rectangle((10, 150, 60, 200), fill = 0) - drawred.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRedimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in7b-b.bmp') - HRedimage = Image.open('../pic/2in7b-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_2in9_test.py b/Jetson Nano/python3/examples/epd_2in9_test.py deleted file mode 100644 index 59c7ca1..0000000 --- a/Jetson Nano/python3/examples/epd_2in9_test.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9 Demo") - - epd = epd2in9.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # partial update - print("5.show time") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_2in9d_test.py b/Jetson Nano/python3/examples/epd_2in9d_test.py deleted file mode 100644 index 34f5f71..0000000 --- a/Jetson Nano/python3/examples/epd_2in9d_test.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9d Demo") - - epd = epd2in9d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper d', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd d', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_4in2_test.py b/Jetson Nano/python3/examples/epd_4in2_test.py deleted file mode 100644 index 6343f58..0000000 --- a/Jetson Nano/python3/examples/epd_4in2_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2 Demo") - - epd = epd4in2.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '4.2inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '4.2inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/4in2.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_4in2bc_test.py b/Jetson Nano/python3/examples/epd_4in2bc_test.py deleted file mode 100644 index ad1abda..0000000 --- a/Jetson Nano/python3/examples/epd_4in2bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2bc Demo") - - epd = epd4in2bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '4.2inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '4.2inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/4in2b-b.bmp') - HRYimage = Image.open('../pic/4in2b-r.bmp') - # HBlackimage = Image.open('../pic/4in2c-b.bmp') - # HRYimage = Image.open('../pic/4in2c-y.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_5in83_test.py b/Jetson Nano/python3/examples/epd_5in83_test.py deleted file mode 100644 index cb7858c..0000000 --- a/Jetson Nano/python3/examples/epd_5in83_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83 Demo") - - epd = epd5in83.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '5.83inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '5.83inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/5in83.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/examples/epd_5in83bc_test.py b/Jetson Nano/python3/examples/epd_5in83bc_test.py deleted file mode 100644 index b5e3b39..0000000 --- a/Jetson Nano/python3/examples/epd_5in83bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83bc Demo") - - epd = epd5in83bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '5.83inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '5.83inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/5in83bc-b.bmp') - HRYimage = Image.open('../pic/5in83bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Jetson Nano/python3/lib/Font.ttc b/Jetson Nano/python3/lib/Font.ttc deleted file mode 100644 index 4cbb7c5..0000000 Binary files a/Jetson Nano/python3/lib/Font.ttc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd1in54.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd1in54.cpython-36.pyc deleted file mode 100644 index 4f38d73..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd1in54.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd1in54_V2.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd1in54_V2.cpython-36.pyc deleted file mode 100644 index 4b7a257..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd1in54_V2.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd1in54b.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd1in54b.cpython-36.pyc deleted file mode 100644 index 2614d48..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd1in54b.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd1in54c.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd1in54c.cpython-36.pyc deleted file mode 100644 index 95fc097..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd1in54c.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in13.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in13.cpython-36.pyc deleted file mode 100644 index aff19b5..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in13.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in13_V2.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in13_V2.cpython-36.pyc deleted file mode 100644 index ba84173..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in13_V2.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in13bc.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in13bc.cpython-36.pyc deleted file mode 100644 index c324fcf..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in13bc.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in7.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in7.cpython-36.pyc deleted file mode 100644 index 0cb6dac..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in7.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in7b.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in7b.cpython-36.pyc deleted file mode 100644 index 018c4c4..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in7b.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in9.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in9.cpython-36.pyc deleted file mode 100644 index d7def41..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in9.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in9bc.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in9bc.cpython-36.pyc deleted file mode 100644 index 329cd94..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in9bc.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd2in9d.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd2in9d.cpython-36.pyc deleted file mode 100644 index 860f8ad..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd2in9d.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd4in2.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd4in2.cpython-36.pyc deleted file mode 100644 index b7edcd9..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd4in2.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd4in2bc.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd4in2bc.cpython-36.pyc deleted file mode 100644 index 1dc4708..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd4in2bc.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epd7in5bc.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epd7in5bc.cpython-36.pyc deleted file mode 100644 index 41c49a9..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epd7in5bc.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/__pycache__/epdconfig.cpython-36.pyc b/Jetson Nano/python3/lib/__pycache__/epdconfig.cpython-36.pyc deleted file mode 100644 index dd24df4..0000000 Binary files a/Jetson Nano/python3/lib/__pycache__/epdconfig.cpython-36.pyc and /dev/null differ diff --git a/Jetson Nano/python3/lib/epd1in54_V2.py b/Jetson Nano/python3/lib/epd1in54_V2.py deleted file mode 100644 index 76136ed..0000000 --- a/Jetson Nano/python3/lib/epd1in54_V2.py +++ /dev/null @@ -1,206 +0,0 @@ -# ***************************************************************************** -# * | File : epd1in54_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V1 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 - self.send_data(0xF7) - 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_command(0x20) # MASTER_ACTIVATION - - self.ReadBusy() - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - # EPD hardware init start - self.reset() - - 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) - - self.send_command(0x3C) # BorderWavefrom - self.send_data(0x01) - - 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(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() - - def Clear(self, color): - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(color) - self.TurnOnDisplay() - - def getbuffer(self, image): - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - self.TurnOnDisplay() - - def displayPartBaseImage(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.TurnOnDisplayPart() - - def displayPart(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.TurnOnDisplayPart() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in13_V2.py b/Jetson Nano/python3/lib/epd2in13_V2.py deleted file mode 100644 index f4407ff..0000000 --- a/Jetson Nano/python3/lib/epd2in13_V2.py +++ /dev/null @@ -1,315 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in13_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - FULL_UPDATE = 0 - PART_UPDATE = 1 - lut_full_update= [ - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x03,0x03,0x00,0x00,0x02, # TP0 A~D RP0 - 0x09,0x09,0x00,0x00,0x02, # TP1 A~D RP1 - 0x03,0x03,0x00,0x00,0x02, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - lut_partial_update = [ #20 bytes - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x80,0x00,0x00,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x40,0x00,0x00,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x0A,0x00,0x00,0x00,0x00, # TP0 A~D RP0 - 0x00,0x00,0x00,0x00,0x00, # TP1 A~D RP1 - 0x00,0x00,0x00,0x00,0x00, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - self.send_command(0x22) - self.send_data(0xC7) - self.send_command(0x20) - self.ReadBusy() - - def TurnOnDisplayPart(self): - self.send_command(0x22) - self.send_data(0x0c) - self.send_command(0x20) - self.ReadBusy() - - def init(self, update): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - if(update == self.FULL_UPDATE): - self.ReadBusy() - self.send_command(0x12) # soft reset - self.ReadBusy() - - self.send_command(0x74) #set analog block control - self.send_data(0x54) - self.send_command(0x7E) #set digital block control - self.send_data(0x3B) - - self.send_command(0x01) #Driver output control - self.send_data(0xF9) - self.send_data(0x00) - self.send_data(0x00) - - 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(0x0F) #0x0C-->(15+1)*8=128 - - self.send_command(0x45) #set Ram-Y address start//end position - self.send_data(0xF9) #0xF9-->(249+1)=250 - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x03) - - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x55) # - - self.send_command(0x03) - self.send_data(self.lut_full_update[70]) - - self.send_command(0x04) # - self.send_data(self.lut_full_update[71]) - self.send_data(self.lut_full_update[72]) - self.send_data(self.lut_full_update[73]) - - self.send_command(0x3A) #Dummy Line - self.send_data(self.lut_full_update[74]) - self.send_command(0x3B) #Gate time - self.send_data(self.lut_full_update[75]) - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_full_update[count]) - - 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 0X127 - self.send_data(0xF9) - self.send_data(0x00) - self.ReadBusy() - else: - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x26) - - self.ReadBusy() - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_partial_update[count]) - - self.send_command(0x37) - 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_command(0x22) - self.send_data(0xC0) - self.send_command(0x20) - self.ReadBusy() - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x01) - return 0 - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - x = imwidth - x - buf[x // 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - newy = imwidth - newy - 1 - buf[newx // 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def displayPartial(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - # self.send_command(0x26) - # for j in range(0, self.height): - # for i in range(0, linewidth): - # self.send_data(~image[i + j * linewidth]) - self.TurnOnDisplayPart() - - def displayPartBaseImage(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - # print(linewidth) - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x22) #POWER OFF - self.send_data(0xC3) - self.send_command(0x20) - - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in13bc.py b/Jetson Nano/python3/lib/epd2in13bc.py deleted file mode 100644 index aad8f47..0000000 --- a/Jetson Nano/python3/lib/epd2in13bc.py +++ /dev/null @@ -1,158 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in13bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x8F) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0xF0) - - self.send_command(0x61) # RESOLUTION_SETTING - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) - self.send_data(self.height & 0xff) - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(imageblack[i]) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(imagered[i]) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in7.py b/Jetson Nano/python3/lib/epd2in7.py deleted file mode 100644 index d958c53..0000000 --- a/Jetson Nano/python3/lib/epd2in7.py +++ /dev/null @@ -1,258 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in7.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA0) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA1) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xAF) # KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.set_lut() - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - self.send_command(0x12) - self.ReadBusy() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in7b.py b/Jetson Nano/python3/lib/epd2in7b.py deleted file mode 100644 index 52d0719..0000000 --- a/Jetson Nano/python3/lib/epd2in7b.py +++ /dev/null @@ -1,266 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in7b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [ - 0x00, 0x00, - 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - lut_ww = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R22H r - lut_bw = [ - 0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0xB0, 0x04, 0x10, 0x00, 0x00, 0x05, - 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R23H w - lut_bb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - # R24H b - lut_wb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xaf) #KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3a) #3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x87) # define by OTP - - self.set_lut() - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(~imageblack[i]) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(~imagered[i]) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in9.py b/Jetson Nano/python3/lib/epd2in9.py deleted file mode 100644 index 604230e..0000000 --- a/Jetson Nano/python3/lib/epd2in9.py +++ /dev/null @@ -1,200 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in9.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(200) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("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 - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - self.send_command(0x32) # WRITE_LUT_REGISTER - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width // 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd2in9d.py b/Jetson Nano/python3/lib/epd2in9d.py deleted file mode 100644 index 4847b18..0000000 --- a/Jetson Nano/python3/lib/epd2in9d.py +++ /dev/null @@ -1,350 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in9d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V2.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) #PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height // 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) #power off - self.send_command(0X07) #deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epd4in2.py b/Jetson Nano/python3/lib/epd4in2.py deleted file mode 100644 index a748b3d..0000000 --- a/Jetson Nano/python3/lib/epd4in2.py +++ /dev/null @@ -1,240 +0,0 @@ -# ***************************************************************************** -# * | File : epd4in2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [ - 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_ww = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom0[count]) - - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # KW-BF KWR-AF BWROTP 0f - self.send_data(0x0d) - - self.send_command(0x30) # PLL setting - self.send_data(0x3c) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(0x01) - self.send_data(0x90) # 128 - self.send_data(0x01) - self.send_data(0x2c) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x97) # 97white border 77black border VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - - self.set_lut() - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Jetson Nano/python3/lib/epdconfig.py b/Jetson Nano/python3/lib/epdconfig.py deleted file mode 100644 index 403d6a1..0000000 --- a/Jetson Nano/python3/lib/epdconfig.py +++ /dev/null @@ -1,97 +0,0 @@ -# /***************************************************************************** -# * | File : epdconfig.py -# * | Author : Waveshare team -# * | Function : Hardware underlying interface -# * | Info : -# *---------------- -# * | This version: V1.0 -# * | Date : 2019-06-06 -# * | Info : -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import Jetson.GPIO as GPIO -import time - -import ctypes -# import spidev - -# Pin definition -RST_PIN = 17 -DC_PIN = 25 -CS_PIN = 8 -BUSY_PIN = 24 - -# SPI device, bus = 0, device = 0 -# SPI = spidev.SpiDev(0, 0) - -clib = ctypes.cdll.LoadLibrary -spi = clib('../lib/sysfs_software_spi.so') -# gpio2 = clib('../lib/sysfs_gpio.so') - -def digital_write(pin, value): - GPIO.output(pin, value) - -def digital_read(pin): - return GPIO.input(BUSY_PIN) - # return gpio2.SYSFS_GPIO_Read(15) - -def delay_ms(delaytime): - time.sleep(delaytime / 1000.0) - -def spi_writebyte(data): - # SPI.writebytes(data) - spi.SYSFS_software_spi_transfer(data[0]) - -def module_init(): - # print("module_init") - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - # print("RST_PIN") - GPIO.setup(RST_PIN, GPIO.OUT) - # print("DC_PIN") - GPIO.setup(DC_PIN, GPIO.OUT) - # print("CS_PIN") - GPIO.setup(CS_PIN, GPIO.OUT) - # print("BUSY_PIN") - GPIO.setup(BUSY_PIN, GPIO.IN) - # SPI.max_speed_hz = 2000000 - # SPI.mode = 0b00 - - # gpio2.SYSFS_GPIO_Export(15) - # gpio2.SYSFS_GPIO_Direction(15, 0) - - spi.SYSFS_software_spi_begin() - return 0 - - -def module_exit(): - print("spi end") - spi.SYSFS_software_spi_end() - - print("close 5V, Module enters 0 power consumption ...") - GPIO.output(RST_PIN, 0) - GPIO.output(DC_PIN, 0) - - GPIO.cleanup() - - - -### END OF FILE ### diff --git a/Jetson Nano/python3/lib/sysfs_gpio.so b/Jetson Nano/python3/lib/sysfs_gpio.so deleted file mode 100644 index b8d9cdd..0000000 Binary files a/Jetson Nano/python3/lib/sysfs_gpio.so and /dev/null differ diff --git a/Jetson Nano/python3/lib/sysfs_software_spi.so b/Jetson Nano/python3/lib/sysfs_software_spi.so deleted file mode 100644 index f9ff3a6..0000000 Binary files a/Jetson Nano/python3/lib/sysfs_software_spi.so and /dev/null differ diff --git a/Jetson Nano/python3/pic/100x100.bmp b/Jetson Nano/python3/pic/100x100.bmp deleted file mode 100644 index 70f4584..0000000 Binary files a/Jetson Nano/python3/pic/100x100.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/1in54.bmp b/Jetson Nano/python3/pic/1in54.bmp deleted file mode 100644 index a877bfa..0000000 Binary files a/Jetson Nano/python3/pic/1in54.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/1in54b-b.bmp b/Jetson Nano/python3/pic/1in54b-b.bmp deleted file mode 100644 index e992aea..0000000 Binary files a/Jetson Nano/python3/pic/1in54b-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/1in54b-r.bmp b/Jetson Nano/python3/pic/1in54b-r.bmp deleted file mode 100644 index 68c339b..0000000 Binary files a/Jetson Nano/python3/pic/1in54b-r.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/1in54c-b.bmp b/Jetson Nano/python3/pic/1in54c-b.bmp deleted file mode 100644 index 159795e..0000000 Binary files a/Jetson Nano/python3/pic/1in54c-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/1in54c-y.bmp b/Jetson Nano/python3/pic/1in54c-y.bmp deleted file mode 100644 index fe37382..0000000 Binary files a/Jetson Nano/python3/pic/1in54c-y.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in13-v2.bmp b/Jetson Nano/python3/pic/2in13-v2.bmp deleted file mode 100644 index 5156852..0000000 Binary files a/Jetson Nano/python3/pic/2in13-v2.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in13.bmp b/Jetson Nano/python3/pic/2in13.bmp deleted file mode 100644 index a579e2a..0000000 Binary files a/Jetson Nano/python3/pic/2in13.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in13bc-b.bmp b/Jetson Nano/python3/pic/2in13bc-b.bmp deleted file mode 100644 index 6b70b26..0000000 Binary files a/Jetson Nano/python3/pic/2in13bc-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in13bc-ry.bmp b/Jetson Nano/python3/pic/2in13bc-ry.bmp deleted file mode 100644 index ec5cf02..0000000 Binary files a/Jetson Nano/python3/pic/2in13bc-ry.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in13d.bmp b/Jetson Nano/python3/pic/2in13d.bmp deleted file mode 100644 index 6f0a83d..0000000 Binary files a/Jetson Nano/python3/pic/2in13d.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in7.bmp b/Jetson Nano/python3/pic/2in7.bmp deleted file mode 100644 index 48138bb..0000000 Binary files a/Jetson Nano/python3/pic/2in7.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in7b-b.bmp b/Jetson Nano/python3/pic/2in7b-b.bmp deleted file mode 100644 index d25dec3..0000000 Binary files a/Jetson Nano/python3/pic/2in7b-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in7b-r.bmp b/Jetson Nano/python3/pic/2in7b-r.bmp deleted file mode 100644 index 66d51b1..0000000 Binary files a/Jetson Nano/python3/pic/2in7b-r.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in9.bmp b/Jetson Nano/python3/pic/2in9.bmp deleted file mode 100644 index c3e0181..0000000 Binary files a/Jetson Nano/python3/pic/2in9.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in9bc-b.bmp b/Jetson Nano/python3/pic/2in9bc-b.bmp deleted file mode 100644 index d45ff48..0000000 Binary files a/Jetson Nano/python3/pic/2in9bc-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in9bc-ry.bmp b/Jetson Nano/python3/pic/2in9bc-ry.bmp deleted file mode 100644 index 402727c..0000000 Binary files a/Jetson Nano/python3/pic/2in9bc-ry.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/2in9d.bmp b/Jetson Nano/python3/pic/2in9d.bmp deleted file mode 100644 index 61e0fd3..0000000 Binary files a/Jetson Nano/python3/pic/2in9d.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/4in2.bmp b/Jetson Nano/python3/pic/4in2.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Jetson Nano/python3/pic/4in2.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/4in2b-b.bmp b/Jetson Nano/python3/pic/4in2b-b.bmp deleted file mode 100644 index 7c537a4..0000000 Binary files a/Jetson Nano/python3/pic/4in2b-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/4in2b-r.bmp b/Jetson Nano/python3/pic/4in2b-r.bmp deleted file mode 100644 index 3de854c..0000000 Binary files a/Jetson Nano/python3/pic/4in2b-r.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/4in2c-b.bmp b/Jetson Nano/python3/pic/4in2c-b.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Jetson Nano/python3/pic/4in2c-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/4in2c-y.bmp b/Jetson Nano/python3/pic/4in2c-y.bmp deleted file mode 100644 index cd5c0d6..0000000 Binary files a/Jetson Nano/python3/pic/4in2c-y.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/5in83.bmp b/Jetson Nano/python3/pic/5in83.bmp deleted file mode 100644 index 6b8f604..0000000 Binary files a/Jetson Nano/python3/pic/5in83.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/5in83bc-b.bmp b/Jetson Nano/python3/pic/5in83bc-b.bmp deleted file mode 100644 index 545e060..0000000 Binary files a/Jetson Nano/python3/pic/5in83bc-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/5in83bc-ry.bmp b/Jetson Nano/python3/pic/5in83bc-ry.bmp deleted file mode 100644 index 41884b3..0000000 Binary files a/Jetson Nano/python3/pic/5in83bc-ry.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/7in5.bmp b/Jetson Nano/python3/pic/7in5.bmp deleted file mode 100644 index b997800..0000000 Binary files a/Jetson Nano/python3/pic/7in5.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/7in5b-b.bmp b/Jetson Nano/python3/pic/7in5b-b.bmp deleted file mode 100644 index 8f84025..0000000 Binary files a/Jetson Nano/python3/pic/7in5b-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/7in5b-r.bmp b/Jetson Nano/python3/pic/7in5b-r.bmp deleted file mode 100644 index 3f81b2c..0000000 Binary files a/Jetson Nano/python3/pic/7in5b-r.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/7in5c-b.bmp b/Jetson Nano/python3/pic/7in5c-b.bmp deleted file mode 100644 index a69ddbc..0000000 Binary files a/Jetson Nano/python3/pic/7in5c-b.bmp and /dev/null differ diff --git a/Jetson Nano/python3/pic/7in5c-r.bmp b/Jetson Nano/python3/pic/7in5c-r.bmp deleted file mode 100644 index be84903..0000000 Binary files a/Jetson Nano/python3/pic/7in5c-r.bmp and /dev/null differ diff --git a/Jetson Nano/python2/examples/epd_1in54_V2_test.py b/Python/examples/epd_1in54_V2_test.py similarity index 68% rename from Jetson Nano/python2/examples/epd_1in54_V2_test.py rename to Python/examples/epd_1in54_V2_test.py index 2e51114..57125ee 100644 --- a/Jetson Nano/python2/examples/epd_1in54_V2_test.py +++ b/Python/examples/epd_1in54_V2_test.py @@ -1,29 +1,35 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd1in54_V2 -import epdconfig +import logging +from waveshare_epd import epd1in54_V2 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd1in54_V2 Demo") + logging.info("epd1in54_V2 Demo") epd = epd1in54_V2.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear(0xFF) time.sleep(1) # Drawing on the image - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) + font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) draw.rectangle((0, 10, 200, 34), fill = 0) draw.text((8, 12), 'hello world', font = font, fill = 255) draw.text((8, 36), u'微雪电子', font = font, fill = 0) @@ -40,22 +46,22 @@ try: time.sleep(2) # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') + logging.info("2.read bmp file...") + image = Image.open(os.path.join(picdir, '1in54.bmp')) epd.display(epd.getbuffer(image)) time.sleep(2) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") epd.Clear(0xFF) image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) image1.paste(bmp, (50,50)) epd.display(epd.getbuffer(image1)) time.sleep(2) # partial update - print("4.show time...") + logging.info("4.show time...") time_image = Image.new('1', (epd.width, epd.height), 255) epd.displayPartBaseImage(epd.getbuffer(time_image)) @@ -71,17 +77,17 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() \ No newline at end of file + logging.info("ctrl + c:") + epd1in54_V2.epdconfig.module_exit() + exit() diff --git a/Raspberry Pi/python3/examples/epd_1in54_test.py b/Python/examples/epd_1in54_test.py similarity index 69% rename from Raspberry Pi/python3/examples/epd_1in54_test.py rename to Python/examples/epd_1in54_test.py index 7844db3..76efcf7 100644 --- a/Raspberry Pi/python3/examples/epd_1in54_test.py +++ b/Python/examples/epd_1in54_test.py @@ -1,28 +1,34 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd1in54 -import epdconfig +import logging +from waveshare_epd import epd1in54 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd1in54 Demo") + logging.info("epd1in54 Demo") epd = epd1in54.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init(epd.lut_full_update) epd.Clear(0xFF) # Drawing on the image - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) + font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) draw.rectangle((0, 10, 200, 34), fill = 0) draw.text((8, 12), 'hello world', font = font, fill = 255) draw.text((8, 36), u'微雪电子', font = font, fill = 0) @@ -39,22 +45,22 @@ try: time.sleep(2) # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') + logging.info("2.read bmp file...") + image = Image.open(os.path.join(picdir, '1in54.bmp')) epd.display(epd.getbuffer(image)) time.sleep(2) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") epd.Clear(0xFF) image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) image1.paste(bmp, (50,50)) epd.display(epd.getbuffer(image1)) time.sleep(2) # # partial update - print("4.show time...") + logging.info("4.show time...") epd.init(epd.lut_partial_update) epd.Clear(0xFF) @@ -71,17 +77,17 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.init(epd.lut_full_update) epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd1in54.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_1in54b_test.py b/Python/examples/epd_1in54b_test.py similarity index 63% rename from Jetson Nano/python3/examples/epd_1in54b_test.py rename to Python/examples/epd_1in54b_test.py index d48b8e2..9549253 100644 --- a/Jetson Nano/python3/examples/epd_1in54b_test.py +++ b/Python/examples/epd_1in54b_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd1in54b -import epdconfig +import logging +from waveshare_epd import epd1in54b import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd1in54b Demo") + logging.info("epd1in54b Demo") epd = epd1in54b.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) drawblack = ImageDraw.Draw(blackimage) drawred = ImageDraw.Draw(redimage) @@ -44,32 +50,32 @@ try: time.sleep(1) # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54b-b.bmp') - redimage = Image.open('../pic/1in54b-r.bmp') + logging.info("2.read bmp file...") + blackimage = Image.open(os.path.join(picdir, '1in54b-b.bmp')) + redimage = Image.open(os.path.join(picdir, '1in54b-r.bmp')) epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) time.sleep(1) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame redimage2 = Image.new('1', (epd.width, epd.height), 255) - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,50)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage2)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd1in54b.epdconfig.module_exit() exit() diff --git a/Raspberry Pi/python2/examples/epd_1in54c_test.py b/Python/examples/epd_1in54c_test.py similarity index 61% rename from Raspberry Pi/python2/examples/epd_1in54c_test.py rename to Python/examples/epd_1in54c_test.py index 7374e6d..4559c9c 100644 --- a/Raspberry Pi/python2/examples/epd_1in54c_test.py +++ b/Python/examples/epd_1in54c_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd1in54c -import epdconfig +import logging +from waveshare_epd import epd1in54c import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd1in54c Demo") + logging.info("epd1in54c Demo") epd = epd1in54c.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame yellowimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) drawblack = ImageDraw.Draw(blackimage) drawyellow = ImageDraw.Draw(yellowimage) @@ -41,32 +47,32 @@ try: time.sleep(1) # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54c-b.bmp') - yellowimage = Image.open('../pic/1in54c-y.bmp') + logging.info("2.read bmp file...") + blackimage = Image.open(os.path.join(picdir, '1in54c-b.bmp')) + yellowimage = Image.open(os.path.join(picdir, '1in54c-y.bmp')) epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) time.sleep(1) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame yellowimage2 = Image.new('1', (epd.width, epd.height), 255) - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,50)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(yellowimage2)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd1in54c.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_2in13_V2_test.py b/Python/examples/epd_2in13_V2_test.py similarity index 67% rename from Jetson Nano/python3/examples/epd_2in13_V2_test.py rename to Python/examples/epd_2in13_V2_test.py index 85f5ee7..570cb75 100644 --- a/Jetson Nano/python3/examples/epd_2in13_V2_test.py +++ b/Python/examples/epd_2in13_V2_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in13_V2 -import epdconfig +import logging +from waveshare_epd import epd2in13_V2 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in13_V2 Demo") + logging.info("epd2in13_V2 Demo") epd = epd2in13_V2.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init(epd.FULL_UPDATE) epd.Clear(0xFF) # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) + font15 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 15) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(image) @@ -41,22 +47,22 @@ try: time.sleep(2) # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') + logging.info("2.read bmp file...") + image = Image.open(os.path.join(picdir, '2in13.bmp')) epd.display(epd.getbuffer(image)) time.sleep(2) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") # epd.Clear(0xFF) image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) image1.paste(bmp, (2,2)) epd.display(epd.getbuffer(image1)) time.sleep(2) # # partial update - print("4.show time...") + logging.info("4.show time...") time_image = Image.new('1', (epd.height, epd.width), 255) time_draw = ImageDraw.Draw(time_image) @@ -73,17 +79,17 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.init(epd.FULL_UPDATE) epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in13_V2.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_2in13_test.py b/Python/examples/epd_2in13_test.py similarity index 67% rename from Jetson Nano/python3/examples/epd_2in13_test.py rename to Python/examples/epd_2in13_test.py index 1081d79..f72cf6d 100644 --- a/Jetson Nano/python3/examples/epd_2in13_test.py +++ b/Python/examples/epd_2in13_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in13 -import epdconfig +import logging +from waveshare_epd import epd2in13 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in13 Demo") + logging.info("epd2in13 Demo") epd = epd2in13.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init(epd.lut_full_update) epd.Clear(0xFF) # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) + font15 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 15) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) - print("1.Drawing on the image...") + logging.info("1.Drawing on the image...") image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(image) @@ -41,22 +47,22 @@ try: time.sleep(2) # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') + logging.info("2.read bmp file...") + image = Image.open(os.path.join(picdir, '2in13.bmp')) epd.display(epd.getbuffer(image)) time.sleep(2) # read bmp file on window - print("3.read bmp file on window...") + logging.info("3.read bmp file on window...") # epd.Clear(0xFF) image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) image1.paste(bmp, (2,2)) epd.display(epd.getbuffer(image1)) time.sleep(2) # # partial update - print("4.show time...") + logging.info("4.show time...") epd.init(epd.lut_partial_update) epd.Clear(0xFF) @@ -71,17 +77,17 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.init(epd.lut_full_update) epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in13.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_2in13bc_test.py b/Python/examples/epd_2in13bc_test.py similarity index 69% rename from Jetson Nano/python3/examples/epd_2in13bc_test.py rename to Python/examples/epd_2in13bc_test.py index ad24c87..d1b74de 100644 --- a/Jetson Nano/python3/examples/epd_2in13bc_test.py +++ b/Python/examples/epd_2in13bc_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in13bc -import epdconfig +import logging +from waveshare_epd import epd2in13bc import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in13bc Demo") + logging.info("epd2in13bc Demo") epd = epd2in13bc.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") - font20 = ImageFont.truetype('../lib/Font.ttc', 20) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + logging.info("Drawing") + font20 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 20) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image drawblack = ImageDraw.Draw(HBlackimage) @@ -44,7 +50,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -62,30 +68,30 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in13bc-b.bmp') - HRYimage = Image.open('../pic/2in13bc-ry.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '2in13bc-b.bmp')) + HRYimage = Image.open(os.path.join(picdir, '2in13bc-ry.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (10,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in13bc.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python2/examples/epd_2in13d_test.py b/Python/examples/epd_2in13d_test.py similarity index 68% rename from Jetson Nano/python2/examples/epd_2in13d_test.py rename to Python/examples/epd_2in13d_test.py index 883ccb3..c3f37f5 100644 --- a/Jetson Nano/python2/examples/epd_2in13d_test.py +++ b/Python/examples/epd_2in13d_test.py @@ -1,26 +1,32 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in13d -import epdconfig +import logging +from waveshare_epd import epd2in13d import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in13d Demo") + logging.info("epd2in13d Demo") epd = epd2in13d.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear(0xFF) - font15 = ImageFont.truetype('../lib/Font.ttc', 15) + font15 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 15) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.rectangle([(0,0),(50,50)],outline = 0) @@ -38,20 +44,20 @@ try: epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/2in13d.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '2in13d.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (20,20)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) # # partial update - print("5.show time...") + logging.info("5.show time...") epd.init() epd.Clear(0xFF) @@ -68,16 +74,16 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in13d.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_2in7_test.py b/Python/examples/epd_2in7_test.py similarity index 66% rename from Jetson Nano/python3/examples/epd_2in7_test.py rename to Python/examples/epd_2in7_test.py index 24a7c43..9589ad9 100644 --- a/Jetson Nano/python3/examples/epd_2in7_test.py +++ b/Python/examples/epd_2in7_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in7 -import epdconfig +import logging +from waveshare_epd import epd2in7 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in7 Demo") + logging.info("epd2in7 Demo") epd = epd2in7.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear(0xFF) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -38,7 +44,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -54,28 +60,28 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/2in7.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '2in7.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) - print("Clear...") + logging.info("Clear...") epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in7.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python2/examples/epd_2in7b_test.py b/Python/examples/epd_2in7b_test.py similarity index 72% rename from Jetson Nano/python2/examples/epd_2in7b_test.py rename to Python/examples/epd_2in7b_test.py index ece7390..0dfc8a4 100644 --- a/Jetson Nano/python2/examples/epd_2in7b_test.py +++ b/Python/examples/epd_2in7b_test.py @@ -1,34 +1,40 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in7b -import epdconfig +import logging +from waveshare_epd import epd2in7b import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in7b Demo") + logging.info("epd2in7b Demo") epd = epd2in7b.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") + logging.info("Drawing") blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 @@ -49,7 +55,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 LRedimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -69,30 +75,30 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRedimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in7b-b.bmp') - HRedimage = Image.open('../pic/2in7b-r.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '2in7b-b.bmp')) + HRedimage = Image.open(os.path.join(picdir, '2in7b-r.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in7b.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python2/examples/epd_2in9_test.py b/Python/examples/epd_2in9_test.py similarity index 72% rename from Jetson Nano/python2/examples/epd_2in9_test.py rename to Python/examples/epd_2in9_test.py index 59c7ca1..6ac6115 100644 --- a/Jetson Nano/python2/examples/epd_2in9_test.py +++ b/Python/examples/epd_2in9_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in9 -import epdconfig +import logging +from waveshare_epd import epd2in9 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in9 Demo") + logging.info("epd2in9 Demo") epd = epd2in9.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init(epd.lut_full_update) epd.Clear(0xFF) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -39,7 +45,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -56,20 +62,20 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/2in9.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '2in9.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) # partial update - print("5.show time") + logging.info("5.show time") epd.init(epd.lut_partial_update) epd.Clear(0xFF) time_image = Image.new('1', (epd.height, epd.width), 255) @@ -86,17 +92,17 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.init(epd.lut_full_update) epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in9.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_2in9bc_test.py b/Python/examples/epd_2in9bc_test.py similarity index 70% rename from Jetson Nano/python3/examples/epd_2in9bc_test.py rename to Python/examples/epd_2in9bc_test.py index b16809d..1060bbf 100644 --- a/Jetson Nano/python3/examples/epd_2in9bc_test.py +++ b/Python/examples/epd_2in9bc_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in9bc -import epdconfig +import logging +from waveshare_epd import epd2in9bc import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in9bc Demo") + logging.info("epd2in9bc Demo") epd = epd2in9bc.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + logging.info("Drawing") + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image drawblack = ImageDraw.Draw(HBlackimage) @@ -44,7 +50,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -64,30 +70,30 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in9bc-b.bmp') - HRYimage = Image.open('../pic/2in9bc-ry.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '2in9bc-b.bmp')) + HRYimage = Image.open(os.path.join(picdir, '2in9bc-ry.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in9bc.epdconfig.module_exit() exit() diff --git a/Raspberry Pi/python2/examples/epd_2in9d_test.py b/Python/examples/epd_2in9d_test.py similarity index 72% rename from Raspberry Pi/python2/examples/epd_2in9d_test.py rename to Python/examples/epd_2in9d_test.py index 34f5f71..8f53436 100644 --- a/Raspberry Pi/python2/examples/epd_2in9d_test.py +++ b/Python/examples/epd_2in9d_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd2in9d -import epdconfig +import logging +from waveshare_epd import epd2in9d import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd2in9d Demo") + logging.info("epd2in9d Demo") epd = epd2in9d.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear(0xFF) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -39,7 +45,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -56,20 +62,20 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/2in9d.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '2in9d.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) # # partial update - print("5.show time...") + logging.info("5.show time...") epd.init() epd.Clear(0xFF) @@ -86,16 +92,16 @@ try: if(num == 10): break - print("Clear...") + logging.info("Clear...") epd.Clear(0xFF) - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd2in9d.epdconfig.module_exit() exit() diff --git a/Raspberry Pi/python2/examples/epd_4in2_test.py b/Python/examples/epd_4in2_test.py similarity index 68% rename from Raspberry Pi/python2/examples/epd_4in2_test.py rename to Python/examples/epd_4in2_test.py index 6343f58..bc3bd92 100644 --- a/Raspberry Pi/python2/examples/epd_4in2_test.py +++ b/Python/examples/epd_4in2_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd4in2 -import epdconfig +import logging +from waveshare_epd import epd4in2 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd4in2 Demo") + logging.info("epd4in2 Demo") epd = epd4in2.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -39,7 +45,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -56,29 +62,29 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/4in2.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '4in2.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd4in2.epdconfig.module_exit() exit() diff --git a/Raspberry Pi/python2/examples/epd_4in2bc_test.py b/Python/examples/epd_4in2bc_test.py similarity index 68% rename from Raspberry Pi/python2/examples/epd_4in2bc_test.py rename to Python/examples/epd_4in2bc_test.py index ad1abda..2e45ba3 100644 --- a/Raspberry Pi/python2/examples/epd_4in2bc_test.py +++ b/Python/examples/epd_4in2bc_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd4in2bc -import epdconfig +import logging +from waveshare_epd import epd4in2bc import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd4in2bc Demo") + logging.info("epd4in2bc Demo") epd = epd4in2bc.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + logging.info("Drawing") + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image drawblack = ImageDraw.Draw(HBlackimage) @@ -44,7 +50,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -64,32 +70,32 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/4in2b-b.bmp') - HRYimage = Image.open('../pic/4in2b-r.bmp') - # HBlackimage = Image.open('../pic/4in2c-b.bmp') - # HRYimage = Image.open('../pic/4in2c-y.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '4in2b-b.bmp')) + HRYimage = Image.open(os.path.join(picdir, '4in2b-r.bmp')) + # HBlackimage = Image.open(os.path.join(picdir, '4in2c-b.bmp')) + # HRYimage = Image.open(os.path.join(picdir, '4in2c-y.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd4in2bc.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python2/examples/epd_5in83_test.py b/Python/examples/epd_5in83_test.py similarity index 68% rename from Jetson Nano/python2/examples/epd_5in83_test.py rename to Python/examples/epd_5in83_test.py index cb7858c..ef69892 100644 --- a/Jetson Nano/python2/examples/epd_5in83_test.py +++ b/Python/examples/epd_5in83_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd5in83 -import epdconfig +import logging +from waveshare_epd import epd5in83 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd5in83 Demo") + logging.info("epd5in83 Demo") epd = epd5in83.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -39,7 +45,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -56,29 +62,29 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/5in83.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '5in83.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd5in83.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python2/examples/epd_5in83bc_test.py b/Python/examples/epd_5in83bc_test.py similarity index 70% rename from Jetson Nano/python2/examples/epd_5in83bc_test.py rename to Python/examples/epd_5in83bc_test.py index b5e3b39..5f12bfc 100644 --- a/Jetson Nano/python2/examples/epd_5in83bc_test.py +++ b/Python/examples/epd_5in83bc_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd5in83bc -import epdconfig +import logging +from waveshare_epd import epd5in83bc import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd5in83bc Demo") + logging.info("epd5in83bc Demo") epd = epd5in83bc.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + logging.info("Drawing") + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image drawblack = ImageDraw.Draw(HBlackimage) @@ -44,7 +50,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -64,30 +70,30 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/5in83bc-b.bmp') - HRYimage = Image.open('../pic/5in83bc-ry.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '5in83bc-b.bmp')) + HRYimage = Image.open(os.path.join(picdir, '5in83bc-ry.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd5in83bc.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_7in5_test.py b/Python/examples/epd_7in5_test.py similarity index 68% rename from Jetson Nano/python3/examples/epd_7in5_test.py rename to Python/examples/epd_7in5_test.py index eaf11ec..10dc1f2 100644 --- a/Jetson Nano/python3/examples/epd_7in5_test.py +++ b/Python/examples/epd_7in5_test.py @@ -1,27 +1,33 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd7in5 -import epdconfig +import logging +from waveshare_epd import epd7in5 import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd7in5 Demo") + logging.info("epd7in5 Demo") epd = epd7in5.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) @@ -39,7 +45,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) @@ -56,29 +62,29 @@ try: epd.display(epd.getbuffer(Limage)) time.sleep(2) - print("3.read bmp file") - Himage = Image.open('../pic/7in5.bmp') + logging.info("3.read bmp file") + Himage = Image.open(os.path.join(picdir, '7in5.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') + bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd7in5.epdconfig.module_exit() exit() diff --git a/Jetson Nano/python3/examples/epd_7in5bc_test.py b/Python/examples/epd_7in5bc_test.py similarity index 68% rename from Jetson Nano/python3/examples/epd_7in5bc_test.py rename to Python/examples/epd_7in5bc_test.py index 82153b4..bf7df7a 100644 --- a/Jetson Nano/python3/examples/epd_7in5bc_test.py +++ b/Python/examples/epd_7in5bc_test.py @@ -1,30 +1,36 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import sys -sys.path.append(r'../lib') +import os +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) -import epd7in5bc -import epdconfig +import logging +from waveshare_epd import epd7in5bc import time from PIL import Image,ImageDraw,ImageFont import traceback +logging.basicConfig(level=logging.DEBUG) + try: - print("epd7in5bc Demo") + logging.info("epd7in5bc Demo") epd = epd7in5bc.EPD() - print("init and Clear") + logging.info("init and Clear") epd.init() epd.Clear() time.sleep(1) # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) + logging.info("Drawing") + font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) + font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") + logging.info("1.Drawing on the Horizontal image...") HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image drawblack = ImageDraw.Draw(HBlackimage) @@ -44,7 +50,7 @@ try: time.sleep(2) # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") + logging.info("2.Drawing on the Vertical image...") LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 drawblack = ImageDraw.Draw(LBlackimage) @@ -64,32 +70,32 @@ try: epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) time.sleep(2) - print("3.read bmp file") - HBlackimage = Image.open('../pic/7in5b-b.bmp') - HRYimage = Image.open('../pic/7in5b-r.bmp') - # HBlackimage = Image.open('../pic/7in5c-b.bmp') - # HRYimage = Image.open('../pic/7in5c-r.bmp') + logging.info("3.read bmp file") + HBlackimage = Image.open(os.path.join(picdir, '7in5b-b.bmp')) + HRYimage = Image.open(os.path.join(picdir, '7in5b-r.bmp')) + # HBlackimage = Image.open(os.path.join(picdir, '7in5c-b.bmp')) + # HRYimage = Image.open(os.path.join(picdir, '7in5c-r.bmp')) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) time.sleep(2) - print("4.read bmp file on window") + logging.info("4.read bmp file on window") blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') + newimage = Image.open(os.path.join(picdir, '100x100.bmp')) blackimage1.paste(newimage, (50,10)) epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - print("Clear...") + logging.info("Clear...") epd.init() epd.Clear() - print("Goto Sleep...") + logging.info("Goto Sleep...") epd.sleep() except IOError as e: - print(e) + logging.info(e) except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() + logging.info("ctrl + c:") + epd7in5bc.epdconfig.module_exit() exit() diff --git a/Python/lib/waveshare_epd/__init__.py b/Python/lib/waveshare_epd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Jetson Nano/python3/lib/epd1in54.py b/Python/lib/waveshare_epd/epd1in54.py similarity index 93% rename from Jetson Nano/python3/lib/epd1in54.py rename to Python/lib/waveshare_epd/epd1in54.py index 54a21e4..bf45731 100644 --- a/Jetson Nano/python3/lib/epd1in54.py +++ b/Python/lib/waveshare_epd/epd1in54.py @@ -6,7 +6,7 @@ # *---------------- # * | This version: V3.1 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # V3.1(2019-06-18): # 2.remove commands define: @@ -59,11 +59,11 @@ # drawing ...... # ... # epd.display(getbuffer(image)) -# ******************************************************************************// +# ******************************************************************************/ # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -79,7 +79,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 200 @@ -130,10 +131,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def TurnOnDisplay(self): self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 @@ -200,25 +201,25 @@ class EPD: return 0 def getbuffer(self, image): - buf = [0xFF] * ((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() if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): @@ -229,8 +230,8 @@ class EPD: for j in range(0, self.height): self.SetCursor(0, j) self.send_command(0x24) - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) + for i in range(0, int(self.width / 8)): + self.send_data(image[i + j * int(self.width / 8)]) self.TurnOnDisplay() def Clear(self, color): @@ -240,7 +241,7 @@ class EPD: for j in range(0, self.height): self.SetCursor(0, j) self.send_command(0x24) - for i in range(0, self.width // 8): + for i in range(0, int(self.width / 8)): self.send_data(color) self.TurnOnDisplay() diff --git a/Jetson Nano/python2/lib/epd1in54_V2.py b/Python/lib/waveshare_epd/epd1in54_V2.py similarity index 85% rename from Jetson Nano/python2/lib/epd1in54_V2.py rename to Python/lib/waveshare_epd/epd1in54_V2.py index a940541..8c8f09a 100644 --- a/Jetson Nano/python2/lib/epd1in54_V2.py +++ b/Python/lib/waveshare_epd/epd1in54_V2.py @@ -1,13 +1,13 @@ -# /***************************************************************************** +# ***************************************************************************** # * | File : epd1in54_V2.py # * | Author : Waveshare team # * | Function : Electronic paper driver # * | Info : # *---------------- # * | This version: V1 -# * | Date : 2019-06-18 -# # | Info : python2 demo -# ******************************************************************************/ +# * | Date : 2019-06-20 +# # | Info : python demo +# ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 200 @@ -64,10 +65,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 1): epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def TurnOnDisplay(self): self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 @@ -133,30 +134,30 @@ class EPD: def Clear(self, color): self.send_command(0x24) for j in range(0, self.height): - for i in range(0, self.width / 8): + for i in range(0, int(self.width / 8)): self.send_data(color) self.TurnOnDisplay() def getbuffer(self, image): - buf = [0xFF] * ((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() if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): @@ -165,8 +166,8 @@ class EPD: self.send_command(0x24) for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) + for i in range(0, int(self.width / 8)): + self.send_data(image[i + j * int(self.width / 8)]) self.TurnOnDisplay() def displayPartBaseImage(self, image): @@ -175,13 +176,13 @@ class EPD: self.send_command(0x24) for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) + for i in range(0, int(self.width / 8)): + self.send_data(image[i + j * int(self.width / 8)]) self.send_command(0x26) for j in range(0, self.height): for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) + self.send_data(image[i + j * int(self.width / 8)]) self.TurnOnDisplayPart() @@ -191,8 +192,8 @@ class EPD: self.send_command(0x24) for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) + for i in range(0, int(self.width / 8)): + self.send_data(image[i + j * int(self.width / 8)]) self.TurnOnDisplayPart() diff --git a/Jetson Nano/python3/lib/epd1in54b.py b/Python/lib/waveshare_epd/epd1in54b.py similarity index 93% rename from Jetson Nano/python3/lib/epd1in54b.py rename to Python/lib/waveshare_epd/epd1in54b.py index e35014c..7b241c9 100644 --- a/Jetson Nano/python3/lib/epd1in54b.py +++ b/Python/lib/waveshare_epd/epd1in54b.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 200 @@ -73,10 +74,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def set_lut_bw(self): self.send_command(0x20) # vcom @@ -143,7 +144,7 @@ class EPD: return 0 def getbuffer(self, image): - buf = [0xFF] * (self.width * self.height // 8) + buf = [0xFF] * int(self.width * self.height / 8) # Set buffer to value of Python Imaging Library image. # Image must be in mode 1. image_monocolor = image.convert('1') @@ -157,14 +158,14 @@ class EPD: for x in range(self.width): # Set the bits for the column of pixels at the current position. if pixels[x, y] == 0: - buf[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) return buf def display(self, blackimage, redimage): # send black data if (blackimage != None): self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): temp = 0x00 for bit in range(0, 4): if (blackimage[i] & (0x80 >> bit) != 0): @@ -179,7 +180,7 @@ class EPD: # send red data if (redimage != None): self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(redimage[i]) self.send_command(0x12) # DISPLAY_REFRESH @@ -187,12 +188,12 @@ class EPD: def Clear(self): self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_data(0xFF) self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x12) # DISPLAY_REFRESH diff --git a/Jetson Nano/python3/lib/epd1in54c.py b/Python/lib/waveshare_epd/epd1in54c.py similarity index 86% rename from Jetson Nano/python3/lib/epd1in54c.py rename to Python/lib/waveshare_epd/epd1in54c.py index 2880b1c..11f9c6f 100644 --- a/Jetson Nano/python3/lib/epd1in54c.py +++ b/Python/lib/waveshare_epd/epd1in54c.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -26,7 +26,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 152 @@ -63,10 +64,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(200) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -95,35 +96,35 @@ class EPD: self.send_data(0x77) def getbuffer(self, image): - buf = [0xFF] * ((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() if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, blackimage, yellowimage): self.send_command(0x10) - print("blackimage") - for i in range(0, self.width * self.height // 8): + logging.debug("blackimage") + for i in range(0, int(self.width * self.height / 8)): self.send_data(blackimage[i]) self.send_command(0x13) - print("yellowimage") - for i in range(0, self.width * self.height // 8): + logging.debug("yellowimage") + for i in range(0, int(self.width * self.height / 8)): self.send_data(yellowimage[i]) self.send_command(0x12) @@ -131,10 +132,10 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x12) diff --git a/Jetson Nano/python3/lib/epd2in13.py b/Python/lib/waveshare_epd/epd2in13.py similarity index 90% rename from Jetson Nano/python3/lib/epd2in13.py rename to Python/lib/waveshare_epd/epd2in13.py index 9424d9a..3039b59 100644 --- a/Jetson Nano/python3/lib/epd2in13.py +++ b/Python/lib/waveshare_epd/epd2in13.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig import numpy as np # Display resolution @@ -89,9 +90,9 @@ class EPD: self.send_command(0x20) # MASTER_ACTIVATION self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE - print("e-Paper busy") + logging.debug("e-Paper busy") self.ReadBusy() - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self, lut): if (epdconfig.module_init() != 0): @@ -131,7 +132,7 @@ class EPD: return 0 ## - # @brief: specify the memory area for data R//W + # @brief: specify the memory area for data R/W ## def SetWindows(self, x_start, y_start, x_end, y_end): self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION @@ -144,7 +145,7 @@ class EPD: self.send_data((y_end >> 8) & 0xFF) ## - # @brief: specify the start point for data R//W + # @brief: specify the start point for data R/W ## def SetCursor(self, x, y): self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER @@ -157,9 +158,9 @@ class EPD: def getbuffer(self, image): if self.width%8 == 0: - linewidth = self.width//8 + linewidth = int(self.width/8) else: - linewidth = self.width//8 + 1 + linewidth = int(self.width/8) + 1 buf = [0xFF] * (linewidth * self.height) image_monocolor = image.convert('1') @@ -167,29 +168,29 @@ class EPD: pixels = image_monocolor.load() if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): if pixels[x, y] == 0: # x = imwidth - x - buf[x // 8 + y * linewidth] &= ~(0x80 >> (x % 8)) + buf[int(x / 8) + y * linewidth] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: # newy = imwidth - newy - 1 - buf[newx // 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) + buf[int(newx / 8) + newy*linewidth] &= ~(0x80 >> (y % 8)) return buf def display(self, image): if self.width%8 == 0: - linewidth = self.width//8 + linewidth = int(self.width/8) else: - linewidth = self.width//8 + 1 + linewidth = int(self.width/8) + 1 self.SetWindows(0, 0, self.width, self.height); for j in range(0, self.height): @@ -201,9 +202,9 @@ class EPD: def Clear(self, color): if self.width%8 == 0: - linewidth = self.width//8 + linewidth = int(self.width/8) else: - linewidth = self.width//8 + 1 + linewidth = int(self.width/8) + 1 self.SetWindows(0, 0, self.width, self.height); for j in range(0, self.height): diff --git a/Jetson Nano/python2/lib/epd2in13_V2.py b/Python/lib/waveshare_epd/epd2in13_V2.py similarity index 92% rename from Jetson Nano/python2/lib/epd2in13_V2.py rename to Python/lib/waveshare_epd/epd2in13_V2.py index aaeed0b..fe532f4 100644 --- a/Jetson Nano/python2/lib/epd2in13_V2.py +++ b/Python/lib/waveshare_epd/epd2in13_V2.py @@ -1,13 +1,13 @@ -# /***************************************************************************** +# ***************************************************************************** # * | File : epd2in13_V2.py # * | Author : Waveshare team # * | Function : Electronic paper driver # * | Info : # *---------------- # * | This version: V4.0 -# * | Date : 2018-06-20 -# * | Info : python2 demo -# ******************************************************************************/ +# * | Date : 2019-06-20 +# # | Info : python demo +# ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig import numpy as np # Display resolution @@ -211,9 +212,9 @@ class EPD: def getbuffer(self, image): if self.width%8 == 0: - linewidth = self.width/8 + linewidth = int(self.width/8) else: - linewidth = self.width/8 + 1 + linewidth = int(self.width/8) + 1 buf = [0xFF] * (linewidth * self.height) image_monocolor = image.convert('1') @@ -221,29 +222,29 @@ class EPD: pixels = image_monocolor.load() if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): if pixels[x, y] == 0: x = imwidth - x - buf[x / 8 + y * linewidth] &= ~(0x80 >> (x % 8)) + buf[int(x / 8) + y * linewidth] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: newy = imwidth - newy - 1 - buf[newx / 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) + buf[int(newx / 8) + newy*linewidth] &= ~(0x80 >> (y % 8)) return buf def display(self, image): if self.width%8 == 0: - linewidth = self.width/8 + linewidth = int(self.width/8) else: - linewidth = self.width/8 + 1 + linewidth = int(self.width/8) + 1 self.send_command(0x24) for j in range(0, self.height): @@ -253,9 +254,9 @@ class EPD: def displayPartial(self, image): if self.width%8 == 0: - linewidth = self.width/8 + linewidth = int(self.width/8) else: - linewidth = self.width/8 + 1 + linewidth = int(self.width/8) + 1 self.send_command(0x24) for j in range(0, self.height): @@ -271,9 +272,9 @@ class EPD: def displayPartBaseImage(self, image): if self.width%8 == 0: - linewidth = self.width/8 + linewidth = int(self.width/8) else: - linewidth = self.width/8 + 1 + linewidth = int(self.width/8) + 1 self.send_command(0x24) for j in range(0, self.height): @@ -289,10 +290,10 @@ class EPD: def Clear(self, color): if self.width%8 == 0: - linewidth = self.width/8 + linewidth = int(self.width/8) else: - linewidth = self.width/8 + 1 - # print(linewidth) + linewidth = int(self.width/8) + 1 + # logging.debug(linewidth) self.send_command(0x24) for j in range(0, self.height): diff --git a/Raspberry Pi/python3/lib/epd2in13bc.py b/Python/lib/waveshare_epd/epd2in13bc.py similarity index 85% rename from Raspberry Pi/python3/lib/epd2in13bc.py rename to Python/lib/waveshare_epd/epd2in13bc.py index aad8f47..864d8c5 100644 --- a/Raspberry Pi/python3/lib/epd2in13bc.py +++ b/Python/lib/waveshare_epd/epd2in13bc.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 104 @@ -64,10 +65,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -96,37 +97,37 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(imageblack[i]) self.send_command(0x92) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(imagered[i]) self.send_command(0x92) @@ -135,12 +136,12 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x92) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x92) diff --git a/Jetson Nano/python3/lib/epd2in13d.py b/Python/lib/waveshare_epd/epd2in13d.py similarity index 91% rename from Jetson Nano/python3/lib/epd2in13d.py rename to Python/lib/waveshare_epd/epd2in13d.py index 30b4fa0..de02f86 100644 --- a/Jetson Nano/python3/lib/epd2in13d.py +++ b/Python/lib/waveshare_epd/epd2in13d.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig from PIL import Image import RPi.GPIO as GPIO @@ -169,11 +170,11 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy self.send_command(0x71) epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def TurnOnDisplay(self): self.send_command(0x12) @@ -262,40 +263,40 @@ class EPD: self.send_data(self.lut_bb1[count]) def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print "Vertical" + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print "Horizontal" + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): if (Image == None): - return + return self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) epdconfig.delay_ms(10) @@ -304,7 +305,7 @@ class EPD: def DisplayPartial(self, image): if (Image == None): - return + return self.SetPartReg() self.send_command(0x91) @@ -314,17 +315,17 @@ class EPD: self.send_data(0) self.send_data(0) - self.send_data(self.height // 256) + self.send_data(int(self.height / 256)) self.send_data(self.height % 256 - 1) self.send_data(0x28) self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(~image[i]) epdconfig.delay_ms(10) @@ -332,12 +333,12 @@ class EPD: def Clear(self, color): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) epdconfig.delay_ms(10) diff --git a/Raspberry Pi/python3/lib/epd2in7.py b/Python/lib/waveshare_epd/epd2in7.py similarity index 90% rename from Raspberry Pi/python3/lib/epd2in7.py rename to Python/lib/waveshare_epd/epd2in7.py index d958c53..e4741ca 100644 --- a/Raspberry Pi/python3/lib/epd2in7.py +++ b/Python/lib/waveshare_epd/epd2in7.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 176 @@ -110,10 +111,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(200) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def set_lut(self): self.send_command(0x20) # vcom @@ -203,45 +204,45 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) self.send_command(0x12) self.ReadBusy() def Clear(self, color): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x12) self.ReadBusy() diff --git a/Raspberry Pi/python3/lib/epd2in7b.py b/Python/lib/waveshare_epd/epd2in7b.py similarity index 90% rename from Raspberry Pi/python3/lib/epd2in7b.py rename to Python/lib/waveshare_epd/epd2in7b.py index b8f6500..4e938f0 100644 --- a/Raspberry Pi/python3/lib/epd2in7b.py +++ b/Python/lib/waveshare_epd/epd2in7b.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 176 @@ -118,10 +119,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def set_lut(self): self.send_command(0x20) # vcom @@ -205,37 +206,37 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(~imageblack[i]) self.send_command(0x11) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(~imagered[i]) self.send_command(0x11) @@ -244,12 +245,12 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) self.send_command(0x11) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) self.send_command(0x11) diff --git a/Raspberry Pi/python3/lib/epd2in9.py b/Python/lib/waveshare_epd/epd2in9.py similarity index 89% rename from Raspberry Pi/python3/lib/epd2in9.py rename to Python/lib/waveshare_epd/epd2in9.py index 604230e..80671a4 100644 --- a/Raspberry Pi/python3/lib/epd2in9.py +++ b/Python/lib/waveshare_epd/epd2in9.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 128 @@ -89,9 +90,9 @@ class EPD: self.send_command(0x20) # MASTER_ACTIVATION self.send_command(0xFF) # TERMINATE_FRAME_READ_WRITE - print("e-Paper busy") + logging.debug("e-Paper busy") self.ReadBusy() - print("e-Paper busy release") + logging.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 @@ -148,27 +149,27 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): @@ -178,8 +179,8 @@ class EPD: for j in range(0, self.height): self.SetCursor(0, j) self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) + for i in range(0, int(self.width / 8)): + self.send_data(image[i + j * int(self.width / 8)]) self.TurnOnDisplay() def Clear(self, color): @@ -187,7 +188,7 @@ class EPD: for j in range(0, self.height): self.SetCursor(0, j) self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width // 8): + for i in range(0, int(self.width / 8)): self.send_data(color) self.TurnOnDisplay() diff --git a/Jetson Nano/python3/lib/epd2in9bc.py b/Python/lib/waveshare_epd/epd2in9bc.py similarity index 85% rename from Jetson Nano/python3/lib/epd2in9bc.py rename to Python/lib/waveshare_epd/epd2in9bc.py index fdf7817..1d116eb 100644 --- a/Jetson Nano/python3/lib/epd2in9bc.py +++ b/Python/lib/waveshare_epd/epd2in9bc.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 128 @@ -65,10 +66,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(200) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -96,37 +97,37 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, blackimage, ryimage): # ryimage: red or yellow image if (blackimage != None): self.send_command(0X10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(blackimage[i]) if (ryimage != None): self.send_command(0X13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(ryimage[i]) self.send_command(0x12) @@ -134,10 +135,10 @@ class EPD: def Clear(self): self.send_command(0X10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xff) self.send_command(0X13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xff) self.send_command(0x12) diff --git a/Raspberry Pi/python3/lib/epd2in9d.py b/Python/lib/waveshare_epd/epd2in9d.py similarity index 91% rename from Raspberry Pi/python3/lib/epd2in9d.py rename to Python/lib/waveshare_epd/epd2in9d.py index 4847b18..67c0a7a 100644 --- a/Raspberry Pi/python3/lib/epd2in9d.py +++ b/Python/lib/waveshare_epd/epd2in9d.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V2.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig from PIL import Image import RPi.GPIO as GPIO @@ -169,11 +170,11 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy self.send_command(0x71) epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def TurnOnDisplay(self): self.send_command(0x12) epdconfig.delay_ms(10) @@ -261,37 +262,37 @@ class EPD: self.send_data(self.lut_bb1[count]) def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Vertical") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Horizontal") + logging.debug("Horizontal") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) epdconfig.delay_ms(10) @@ -307,17 +308,17 @@ class EPD: self.send_data(0) self.send_data(0) - self.send_data(self.height // 256) + self.send_data(int(self.height / 256)) self.send_data(self.height % 256 - 1) self.send_data(0x28) self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(~image[i]) epdconfig.delay_ms(10) @@ -325,12 +326,12 @@ class EPD: def Clear(self, color): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0x00) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) epdconfig.delay_ms(10) diff --git a/Raspberry Pi/python3/lib/epd4in2.py b/Python/lib/waveshare_epd/epd4in2.py similarity index 91% rename from Raspberry Pi/python3/lib/epd4in2.py rename to Python/lib/waveshare_epd/epd4in2.py index a748b3d..47ba04c 100644 --- a/Raspberry Pi/python3/lib/epd4in2.py +++ b/Python/lib/waveshare_epd/epd4in2.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig from PIL import Image import RPi.GPIO as GPIO @@ -181,36 +182,36 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, image): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(image[i]) self.send_command(0x12) @@ -218,11 +219,11 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x12) diff --git a/Jetson Nano/python3/lib/epd4in2bc.py b/Python/lib/waveshare_epd/epd4in2bc.py similarity index 84% rename from Jetson Nano/python3/lib/epd4in2bc.py rename to Python/lib/waveshare_epd/epd4in2bc.py index 637be5c..d29465a 100644 --- a/Jetson Nano/python3/lib/epd4in2bc.py +++ b/Python/lib/waveshare_epd/epd4in2bc.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -27,7 +27,8 @@ # THE SOFTWARE. # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 400 @@ -64,10 +65,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -89,36 +90,36 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(imageblack[i]) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(imagered[i]) self.send_command(0x12) @@ -126,11 +127,11 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x13) - for i in range(0, self.width * self.height // 8): + for i in range(0, int(self.width * self.height / 8)): self.send_data(0xFF) self.send_command(0x12) diff --git a/Jetson Nano/python3/lib/epd5in83.py b/Python/lib/waveshare_epd/epd5in83.py similarity index 85% rename from Jetson Nano/python3/lib/epd5in83.py rename to Python/lib/waveshare_epd/epd5in83.py index e108d73..b51363c 100644 --- a/Jetson Nano/python3/lib/epd5in83.py +++ b/Python/lib/waveshare_epd/epd5in83.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 600 @@ -65,10 +66,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -120,39 +121,39 @@ class EPD: return 0 def getbuffer(self, image): - buf = [0x00] * (self.width * self.height // 4) + buf = [0x00] * int(self.width * self.height / 4) image_monocolor = image.convert('1') imwidth, imheight = image_monocolor.size pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) + logging.debug("imwidth = ", imwidth, "imheight = ", imheight) 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. if pixels[x, y] < 64: # black - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) + buf[int((x + y * self.width) / 4)] &= ~(0xC0 >> (x % 4 * 2)) elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) // 4] |= 0x40 >> (x % 4 * 2) + buf[int((x + y * self.width) / 4)] &= ~(0xC0 >> (x % 4 * 2)) + buf[int((x + y * self.width) / 4)] |= 0x40 >> (x % 4 * 2) else: # white - buf[(x + y * self.width) // 4] |= 0xC0 >> (x % 4 * 2) + buf[int((x + y * self.width) / 4)] |= 0xC0 >> (x % 4 * 2) 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 if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) + buf[int((newx + newy*self.width) / 4)] &= ~(0xC0 >> (y % 4 * 2)) elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) // 4] |= 0x40 >> (y % 4 * 2) + buf[int((newx + newy*self.width) / 4)] &= ~(0xC0 >> (y % 4 * 2)) + buf[int((newx + newy*self.width) / 4)] |= 0x40 >> (y % 4 * 2) else: # white - buf[(newx + newy*self.width) // 4] |= 0xC0 >> (y % 4 * 2) + buf[int((newx + newy*self.width) / 4)] |= 0xC0 >> (y % 4 * 2) return buf def display(self, image): self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): + for i in range(0, int(self.width / 4 * self.height)): temp1 = image[i] j = 0 while (j < 4): @@ -181,7 +182,7 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): + for i in range(0, int(self.width / 4 * self.height)): for j in range(0, 4): self.send_data(0x33) self.send_command(0x12) diff --git a/Jetson Nano/python3/lib/epd5in83bc.py b/Python/lib/waveshare_epd/epd5in83bc.py similarity index 89% rename from Jetson Nano/python3/lib/epd5in83bc.py rename to Python/lib/waveshare_epd/epd5in83bc.py index c9457d5..93b317f 100644 --- a/Jetson Nano/python3/lib/epd5in83bc.py +++ b/Python/lib/waveshare_epd/epd5in83bc.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 600 @@ -65,10 +66,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -116,32 +117,32 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): + for i in range(0, int(self.width / 8 * self.height)): temp1 = imageblack[i] temp2 = imagered[i] j = 0 @@ -176,7 +177,7 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): + for i in range(0, int(self.width / 8 * self.height)): self.send_data(0x33) self.send_data(0x33) self.send_data(0x33) diff --git a/Jetson Nano/python3/lib/epd7in5.py b/Python/lib/waveshare_epd/epd7in5.py similarity index 85% rename from Jetson Nano/python3/lib/epd7in5.py rename to Python/lib/waveshare_epd/epd7in5.py index a03e62a..e2f2676 100644 --- a/Jetson Nano/python3/lib/epd7in5.py +++ b/Python/lib/waveshare_epd/epd7in5.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 640 @@ -65,10 +66,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -120,39 +121,39 @@ class EPD: return 0 def getbuffer(self, image): - buf = [0x00] * (self.width * self.height // 4) + buf = [0x00] * int(self.width * self.height / 4) image_monocolor = image.convert('1') imwidth, imheight = image_monocolor.size pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) + logging.debug("imwidth = ", imwidth, "imheight = ", imheight) 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. if pixels[x, y] < 64: # black - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) + buf[int((x + y * self.width) / 4)] &= ~(0xC0 >> (x % 4 * 2)) elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) // 4] |= 0x40 >> (x % 4 * 2) + buf[int((x + y * self.width) / 4)] &= ~(0xC0 >> (x % 4 * 2)) + buf[int((x + y * self.width) / 4)] |= 0x40 >> (x % 4 * 2) else: # white - buf[(x + y * self.width) // 4] |= 0xC0 >> (x % 4 * 2) + buf[int((x + y * self.width) / 4)] |= 0xC0 >> (x % 4 * 2) 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 if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) + buf[int((newx + newy*self.width) / 4)] &= ~(0xC0 >> (y % 4 * 2)) elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) // 4] |= 0x40 >> (y % 4 * 2) + buf[int((newx + newy*self.width) / 4)] &= ~(0xC0 >> (y % 4 * 2)) + buf[int((newx + newy*self.width) / 4)] |= 0x40 >> (y % 4 * 2) else: # white - buf[(newx + newy*self.width) // 4] |= 0xC0 >> (y % 4 * 2) + buf[int((newx + newy*self.width) / 4)] |= 0xC0 >> (y % 4 * 2) return buf def display(self, image): self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): + for i in range(0, int(self.width / 4 * self.height)): temp1 = image[i] j = 0 while (j < 4): @@ -181,7 +182,7 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): + for i in range(0, int(self.width / 4 * self.height)): for j in range(0, 4): self.send_data(0x33) diff --git a/Jetson Nano/python3/lib/epd7in5bc.py b/Python/lib/waveshare_epd/epd7in5bc.py similarity index 89% rename from Jetson Nano/python3/lib/epd7in5bc.py rename to Python/lib/waveshare_epd/epd7in5bc.py index bd7d047..9c7769d 100644 --- a/Jetson Nano/python3/lib/epd7in5bc.py +++ b/Python/lib/waveshare_epd/epd7in5bc.py @@ -6,12 +6,12 @@ # *---------------- # * | This version: V4.0 # * | Date : 2019-06-20 -# # | Info : python3 demo +# # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # @@ -28,7 +28,8 @@ # -import epdconfig +import logging +from . import epdconfig # Display resolution EPD_WIDTH = 640 @@ -65,10 +66,10 @@ class EPD: epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): - print("e-Paper busy") + logging.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy epdconfig.delay_ms(100) - print("e-Paper busy release") + logging.debug("e-Paper busy release") def init(self): if (epdconfig.module_init() != 0): @@ -116,32 +117,32 @@ class EPD: return 0 def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) + # logging.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() - # print "imwidth = %d, imheight = %d",imwidth,imheight + # logging.debug("imwidth = %d, imheight = %d",imwidth,imheight) if(imwidth == self.width and imheight == self.height): - print("Horizontal") + logging.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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) + buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) elif(imwidth == self.height and imheight == self.width): - print("Vertical") + logging.debug("Vertical") for y in range(imheight): for x in range(imwidth): newx = y newy = self.height - x - 1 if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) + buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8)) return buf def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): + for i in range(0, int(self.width / 8 * self.height)): temp1 = imageblack[i] temp2 = imagered[i] j = 0 @@ -176,7 +177,7 @@ class EPD: def Clear(self): self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): + for i in range(0, int(self.width / 8 * self.height)): self.send_data(0x33) self.send_data(0x33) self.send_data(0x33) diff --git a/Python/lib/waveshare_epd/epdconfig.py b/Python/lib/waveshare_epd/epdconfig.py new file mode 100644 index 0000000..13fbe0f --- /dev/null +++ b/Python/lib/waveshare_epd/epdconfig.py @@ -0,0 +1,154 @@ +# /***************************************************************************** +# * | File : epdconfig.py +# * | Author : Waveshare team +# * | Function : Hardware underlying interface +# * | Info : +# *---------------- +# * | This version: V1.0 +# * | Date : 2019-06-21 +# * | Info : +# ****************************************************************************** +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documnetation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +import os +import logging +import sys +import time + + +class RaspberryPi: + # Pin definition + RST_PIN = 17 + DC_PIN = 25 + CS_PIN = 8 + BUSY_PIN = 24 + + def __init__(self): + import spidev + import RPi.GPIO + + self.GPIO = RPi.GPIO + + # SPI device, bus = 0, device = 0 + self.SPI = spidev.SpiDev(0, 0) + + def digital_write(self, pin, value): + self.GPIO.output(pin, value) + + def digital_read(self, pin): + return self.GPIO.input(self.BUSY_PIN) + + def delay_ms(self, delaytime): + time.sleep(delaytime / 1000.0) + + def spi_writebyte(self, data): + self.SPI.writebytes(data) + + def module_init(self): + self.GPIO.setmode(self.GPIO.BCM) + self.GPIO.setwarnings(False) + self.GPIO.setup(self.RST_PIN, self.GPIO.OUT) + self.GPIO.setup(self.DC_PIN, self.GPIO.OUT) + self.GPIO.setup(self.CS_PIN, self.GPIO.OUT) + self.GPIO.setup(self.BUSY_PIN, self.GPIO.IN) + self.SPI.max_speed_hz = 2000000 + self.SPI.mode = 0b00 + return 0 + + def module_exit(self): + logging.debug("spi end") + self.SPI.close() + + logging.debug("close 5V, Module enters 0 power consumption ...") + self.GPIO.output(self.RST_PIN, 0) + self.GPIO.output(self.DC_PIN, 0) + + self.GPIO.cleanup() + + +class JetsonNano: + # Pin definition + RST_PIN = 17 + DC_PIN = 25 + CS_PIN = 8 + BUSY_PIN = 24 + + def __init__(self): + import ctypes + find_dirs = [ + os.path.dirname(os.path.realpath(__file__)), + '/usr/local/lib', + '/usr/lib', + ] + self.SPI = None + for find_dir in find_dirs: + so_filename = os.path.join(find_dir, 'sysfs_software_spi.so') + if os.path.exists(so_filename): + self.SPI = ctypes.cdll.LoadLibrary(so_filename) + break + if self.SPI is None: + raise RuntimeError('Cannot find sysfs_software_spi.so') + + import Jetson.GPIO + self.GPIO = Jetson.GPIO + + def digital_write(self, pin, value): + self.GPIO.output(pin, value) + + def digital_read(self, pin): + return self.GPIO.input(self.BUSY_PIN) + + def delay_ms(self, delaytime): + time.sleep(delaytime / 1000.0) + + def spi_writebyte(self, data): + self.SPI.SYSFS_software_spi_transfer(data[0]) + + def module_init(self): + self.GPIO.setmode(self.GPIO.BCM) + self.GPIO.setwarnings(False) + self.GPIO.setup(self.RST_PIN, self.GPIO.OUT) + self.GPIO.setup(self.DC_PIN, self.GPIO.OUT) + self.GPIO.setup(self.CS_PIN, self.GPIO.OUT) + self.GPIO.setup(self.BUSY_PIN, self.GPIO.IN) + self.SPI.SYSFS_software_spi_begin() + return 0 + + def module_exit(self): + logging.debug("spi end") + self.SPI.SYSFS_software_spi_end() + + logging.debug("close 5V, Module enters 0 power consumption ...") + self.GPIO.output(self.RST_PIN, 0) + self.GPIO.output(self.DC_PIN, 0) + + self.GPIO.cleanup() + + +if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'): + implementation = RaspberryPi() +else: + implementation = JetsonNano() + +for func in [x for x in dir(implementation) if not x.startswith('_')]: + setattr(sys.modules[__name__], func, getattr(implementation, func)) + + +### END OF FILE ### diff --git a/Jetson Nano/python2/lib/sysfs_gpio.so b/Python/lib/waveshare_epd/sysfs_gpio.so similarity index 100% rename from Jetson Nano/python2/lib/sysfs_gpio.so rename to Python/lib/waveshare_epd/sysfs_gpio.so diff --git a/Jetson Nano/python2/lib/sysfs_software_spi.so b/Python/lib/waveshare_epd/sysfs_software_spi.so similarity index 100% rename from Jetson Nano/python2/lib/sysfs_software_spi.so rename to Python/lib/waveshare_epd/sysfs_software_spi.so diff --git a/Jetson Nano/python2/pic/100x100.bmp b/Python/pic/100x100.bmp similarity index 100% rename from Jetson Nano/python2/pic/100x100.bmp rename to Python/pic/100x100.bmp diff --git a/Jetson Nano/python2/pic/1in54.bmp b/Python/pic/1in54.bmp similarity index 100% rename from Jetson Nano/python2/pic/1in54.bmp rename to Python/pic/1in54.bmp diff --git a/Jetson Nano/python2/pic/1in54b-b.bmp b/Python/pic/1in54b-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/1in54b-b.bmp rename to Python/pic/1in54b-b.bmp diff --git a/Jetson Nano/python2/pic/1in54b-r.bmp b/Python/pic/1in54b-r.bmp similarity index 100% rename from Jetson Nano/python2/pic/1in54b-r.bmp rename to Python/pic/1in54b-r.bmp diff --git a/Jetson Nano/python2/pic/1in54c-b.bmp b/Python/pic/1in54c-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/1in54c-b.bmp rename to Python/pic/1in54c-b.bmp diff --git a/Jetson Nano/python2/pic/1in54c-y.bmp b/Python/pic/1in54c-y.bmp similarity index 100% rename from Jetson Nano/python2/pic/1in54c-y.bmp rename to Python/pic/1in54c-y.bmp diff --git a/Jetson Nano/python2/pic/2in13-v2.bmp b/Python/pic/2in13-v2.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in13-v2.bmp rename to Python/pic/2in13-v2.bmp diff --git a/Jetson Nano/python2/pic/2in13.bmp b/Python/pic/2in13.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in13.bmp rename to Python/pic/2in13.bmp diff --git a/Jetson Nano/python2/pic/2in13bc-b.bmp b/Python/pic/2in13bc-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in13bc-b.bmp rename to Python/pic/2in13bc-b.bmp diff --git a/Jetson Nano/python2/pic/2in13bc-ry.bmp b/Python/pic/2in13bc-ry.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in13bc-ry.bmp rename to Python/pic/2in13bc-ry.bmp diff --git a/Jetson Nano/python2/pic/2in13d.bmp b/Python/pic/2in13d.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in13d.bmp rename to Python/pic/2in13d.bmp diff --git a/Jetson Nano/python2/pic/2in7.bmp b/Python/pic/2in7.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in7.bmp rename to Python/pic/2in7.bmp diff --git a/Jetson Nano/python2/pic/2in7b-b.bmp b/Python/pic/2in7b-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in7b-b.bmp rename to Python/pic/2in7b-b.bmp diff --git a/Jetson Nano/python2/pic/2in7b-r.bmp b/Python/pic/2in7b-r.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in7b-r.bmp rename to Python/pic/2in7b-r.bmp diff --git a/Jetson Nano/python2/pic/2in9.bmp b/Python/pic/2in9.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in9.bmp rename to Python/pic/2in9.bmp diff --git a/Jetson Nano/python2/pic/2in9bc-b.bmp b/Python/pic/2in9bc-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in9bc-b.bmp rename to Python/pic/2in9bc-b.bmp diff --git a/Jetson Nano/python2/pic/2in9bc-ry.bmp b/Python/pic/2in9bc-ry.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in9bc-ry.bmp rename to Python/pic/2in9bc-ry.bmp diff --git a/Jetson Nano/python2/pic/2in9d.bmp b/Python/pic/2in9d.bmp similarity index 100% rename from Jetson Nano/python2/pic/2in9d.bmp rename to Python/pic/2in9d.bmp diff --git a/Jetson Nano/python2/pic/4in2.bmp b/Python/pic/4in2.bmp similarity index 100% rename from Jetson Nano/python2/pic/4in2.bmp rename to Python/pic/4in2.bmp diff --git a/Jetson Nano/python2/pic/4in2b-b.bmp b/Python/pic/4in2b-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/4in2b-b.bmp rename to Python/pic/4in2b-b.bmp diff --git a/Jetson Nano/python2/pic/4in2b-r.bmp b/Python/pic/4in2b-r.bmp similarity index 100% rename from Jetson Nano/python2/pic/4in2b-r.bmp rename to Python/pic/4in2b-r.bmp diff --git a/Jetson Nano/python2/pic/4in2c-b.bmp b/Python/pic/4in2c-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/4in2c-b.bmp rename to Python/pic/4in2c-b.bmp diff --git a/Jetson Nano/python2/pic/4in2c-y.bmp b/Python/pic/4in2c-y.bmp similarity index 100% rename from Jetson Nano/python2/pic/4in2c-y.bmp rename to Python/pic/4in2c-y.bmp diff --git a/Jetson Nano/python2/pic/5in83.bmp b/Python/pic/5in83.bmp similarity index 100% rename from Jetson Nano/python2/pic/5in83.bmp rename to Python/pic/5in83.bmp diff --git a/Jetson Nano/python2/pic/5in83bc-b.bmp b/Python/pic/5in83bc-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/5in83bc-b.bmp rename to Python/pic/5in83bc-b.bmp diff --git a/Jetson Nano/python2/pic/5in83bc-ry.bmp b/Python/pic/5in83bc-ry.bmp similarity index 100% rename from Jetson Nano/python2/pic/5in83bc-ry.bmp rename to Python/pic/5in83bc-ry.bmp diff --git a/Jetson Nano/python2/pic/7in5.bmp b/Python/pic/7in5.bmp similarity index 100% rename from Jetson Nano/python2/pic/7in5.bmp rename to Python/pic/7in5.bmp diff --git a/Jetson Nano/python2/pic/7in5b-b.bmp b/Python/pic/7in5b-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/7in5b-b.bmp rename to Python/pic/7in5b-b.bmp diff --git a/Jetson Nano/python2/pic/7in5b-r.bmp b/Python/pic/7in5b-r.bmp similarity index 100% rename from Jetson Nano/python2/pic/7in5b-r.bmp rename to Python/pic/7in5b-r.bmp diff --git a/Jetson Nano/python2/pic/7in5c-b.bmp b/Python/pic/7in5c-b.bmp similarity index 100% rename from Jetson Nano/python2/pic/7in5c-b.bmp rename to Python/pic/7in5c-b.bmp diff --git a/Jetson Nano/python2/pic/7in5c-r.bmp b/Python/pic/7in5c-r.bmp similarity index 100% rename from Jetson Nano/python2/pic/7in5c-r.bmp rename to Python/pic/7in5c-r.bmp diff --git a/Jetson Nano/python2/lib/Font.ttc b/Python/pic/Font.ttc similarity index 100% rename from Jetson Nano/python2/lib/Font.ttc rename to Python/pic/Font.ttc diff --git a/Jetson Nano/python3/readme_CN.txt b/Python/readme_jetson_CN.txt similarity index 90% rename from Jetson Nano/python3/readme_CN.txt rename to Python/readme_jetson_CN.txt index 38eb743..80be97d 100644 --- a/Jetson Nano/python3/readme_CN.txt +++ b/Python/readme_jetson_CN.txt @@ -31,6 +31,14 @@ RST -> 17 BUSY -> 24 3.安装库: + sudo apt-get update + sudo apt-get install python-pip + sudo apt-get install python-pil + sudo apt-get install python-numpy + sudo pip install Jetson.GPIO + +或 + sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil @@ -49,4 +57,4 @@ BUSY -> 24 那么你应该执行命令: sudo python epd_2in9bc_test.py -注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 \ No newline at end of file +注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 diff --git a/Jetson Nano/python3/readme_EN.txt b/Python/readme_jetson_EN.txt similarity index 90% rename from Jetson Nano/python3/readme_EN.txt rename to Python/readme_jetson_EN.txt index 2904db3..b732211 100644 --- a/Jetson Nano/python3/readme_EN.txt +++ b/Python/readme_jetson_EN.txt @@ -35,6 +35,14 @@ RST -> 17 BUSY -> 24 3.Installation library + sudo apt-get update + sudo apt-get install python-pip + sudo apt-get install python-pil + sudo apt-get install python-numpy + sudo pip install Jetson.GPIO + +or + sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil @@ -53,4 +61,4 @@ Chestnut 2:      Then you should execute the command:      Sudo python epd_2in9bc_test.py      -Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. \ No newline at end of file +Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. diff --git a/Raspberry Pi/python3/readme_CN.txt b/Python/readme_rpi_CN.txt similarity index 90% rename from Raspberry Pi/python3/readme_CN.txt rename to Python/readme_rpi_CN.txt index 67ca2bc..6ed14ae 100644 --- a/Raspberry Pi/python3/readme_CN.txt +++ b/Python/readme_rpi_CN.txt @@ -30,6 +30,14 @@ RST -> 17 BUSY -> 24 3.安装库: + sudo apt-get update + sudo apt-get install python-pip + sudo apt-get install python-pil + sudo apt-get install python-numpy + sudo pip install RPi.GPIO + +或 + sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil @@ -48,4 +56,4 @@ BUSY -> 24 那么你应该执行命令: sudo python epd_2in9bc_test.py -注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 \ No newline at end of file +注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 diff --git a/Raspberry Pi/python3/readme_EN.txt b/Python/readme_rpi_EN.txt similarity index 90% rename from Raspberry Pi/python3/readme_EN.txt rename to Python/readme_rpi_EN.txt index 68ab9d5..659ee04 100644 --- a/Raspberry Pi/python3/readme_EN.txt +++ b/Python/readme_rpi_EN.txt @@ -31,6 +31,14 @@ RST -> 17 BUSY -> 24 3.Installation library + sudo apt-get update + sudo apt-get install python-pip + sudo apt-get install python-pil + sudo apt-get install python-numpy + sudo pip install RPi.GPIO + +or + sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil @@ -49,4 +57,4 @@ Chestnut 2:      Then you should execute the command:      Sudo python epd_2in9bc_test.py      -Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. \ No newline at end of file +Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. diff --git a/Python/setup.py b/Python/setup.py new file mode 100644 index 0000000..7ca1805 --- /dev/null +++ b/Python/setup.py @@ -0,0 +1,12 @@ +import sys +from setuptools import setup + + +setup( + name='waveshare-epd', + description='Waveshare e-Paper Display', + author='Waveshare', + package_dir={'': 'lib'}, + packages=['waveshare_epd'], +) + diff --git a/README.md b/README.md index d8dfb91..c20ed1a 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,11 @@ waveshare electronics ## 中文: Jetson Nano、Raspberry Pi、Arduino、STM32例程 +* Python (Jetson Nano、Raspberry Pi、Python 2/3) * Jetson Nano: > C - > Python2 - > python3 * Raspberry Pi: > C(BCM2835\WiringPi) - > Python2 - > python3 * Arduino: > Arduino UNO * STM32: @@ -23,14 +20,11 @@ http://www.waveshare.net ## English: Jetson Nano、Raspberry Pi、Arduino、STM32 Demo: +* Python (Jetson Nano、Raspberry Pi、Python 2/3) * Jetson Nano: > C - > Python2 - > python3 * Raspberry Pi: > C(BCM2835\WiringPi) - > Python2 - > python3 * Arduino: > Arduino UNO * STM32: diff --git a/Raspberry Pi/python2/examples/epd_1in54_V2_test.py b/Raspberry Pi/python2/examples/epd_1in54_V2_test.py deleted file mode 100644 index 2e51114..0000000 --- a/Raspberry Pi/python2/examples/epd_1in54_V2_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54_V2 Demo") - - epd = epd1in54_V2.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # partial update - print("4.show time...") - time_image = Image.new('1', (epd.width, epd.height), 255) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.displayPart(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init() - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() \ No newline at end of file diff --git a/Raspberry Pi/python2/examples/epd_1in54_test.py b/Raspberry Pi/python2/examples/epd_1in54_test.py deleted file mode 100644 index 92f619f..0000000 --- a/Raspberry Pi/python2/examples/epd_1in54_test.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54 Demo") - - epd = epd1in54.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_1in54b_test.py b/Raspberry Pi/python2/examples/epd_1in54b_test.py deleted file mode 100644 index d48b8e2..0000000 --- a/Raspberry Pi/python2/examples/epd_1in54b_test.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54b Demo") - - epd = epd1in54b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawred = ImageDraw.Draw(redimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font18, fill = 0) - drawblack.line((16, 60, 56, 60), fill = 0) - drawblack.line((56, 60, 56, 110), fill = 0) - drawblack.line((16, 110, 56, 110), fill = 0) - drawred.line((16, 110, 16, 60), fill = 0) - drawred.line((16, 60, 56, 110), fill = 0) - drawred.line((56, 60, 16, 110), fill = 0) - drawred.arc((90, 60, 150, 120), 0, 360, fill = 0) - drawred.rectangle((16, 130, 56, 180), fill = 0) - drawred.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54b-b.bmp') - redimage = Image.open('../pic/1in54b-r.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in13_V2_test.py b/Raspberry Pi/python2/examples/epd_2in13_V2_test.py deleted file mode 100644 index 85f5ee7..0000000 --- a/Raspberry Pi/python2/examples/epd_2in13_V2_test.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13_V2 Demo") - - epd = epd2in13_V2.EPD() - print("init and Clear") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - - epd.init(epd.FULL_UPDATE) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - epd.init(epd.PART_UPDATE) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.displayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in13_test.py b/Raspberry Pi/python2/examples/epd_2in13_test.py deleted file mode 100644 index 1081d79..0000000 --- a/Raspberry Pi/python2/examples/epd_2in13_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13 Demo") - - epd = epd2in13.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in13bc_test.py b/Raspberry Pi/python2/examples/epd_2in13bc_test.py deleted file mode 100644 index ad24c87..0000000 --- a/Raspberry Pi/python2/examples/epd_2in13bc_test.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13bc Demo") - - epd = epd2in13bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font20 = ImageFont.truetype('../lib/Font.ttc', 20) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font20, fill = 0) - drawblack.text((10, 20), '2.13inch e-Paper bc', font = font20, fill = 0) - drawblack.text((120, 0), u'微雪电子', font = font20, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((85, 55, 125, 95), 0, 360, fill =1) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.13 epd b', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.arc((15, 95, 55, 135), 0, 360, fill = 0) - drawry.chord((15, 155, 55, 195), 0, 360, fill =1) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in13bc-b.bmp') - HRYimage = Image.open('../pic/2in13bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (10,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in13d_test.py b/Raspberry Pi/python2/examples/epd_2in13d_test.py deleted file mode 100644 index 883ccb3..0000000 --- a/Raspberry Pi/python2/examples/epd_2in13d_test.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13d Demo") - - epd = epd2in13d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - 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) - draw.text((110, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 80), u'微雪电子', font = font15, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in13d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (20,20)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font24, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.DisplayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in7_test.py b/Raspberry Pi/python2/examples/epd_2in7_test.py deleted file mode 100644 index 24a7c43..0000000 --- a/Raspberry Pi/python2/examples/epd_2in7_test.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7 Demo") - - epd = epd2in7.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in7.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in7b_test.py b/Raspberry Pi/python2/examples/epd_2in7b_test.py deleted file mode 100644 index ece7390..0000000 --- a/Raspberry Pi/python2/examples/epd_2in7b_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7b Demo") - - epd = epd2in7b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - - drawblack = ImageDraw.Draw(HBlackimage) - drawred = ImageDraw.Draw(HRedimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawred.line((165, 50, 165, 100), fill = 0) - drawred.line((140, 75, 190, 75), fill = 0) - drawred.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawred.rectangle((80, 50, 130, 100), fill = 0) - drawred.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRedimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawred = ImageDraw.Draw(LRedimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawred.line((95, 90, 95, 140), fill = 0) - drawred.line((70, 115, 120, 115), fill = 0) - drawred.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawred.rectangle((10, 150, 60, 200), fill = 0) - drawred.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRedimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in7b-b.bmp') - HRedimage = Image.open('../pic/2in7b-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in9_test.py b/Raspberry Pi/python2/examples/epd_2in9_test.py deleted file mode 100644 index 59c7ca1..0000000 --- a/Raspberry Pi/python2/examples/epd_2in9_test.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9 Demo") - - epd = epd2in9.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # partial update - print("5.show time") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_2in9bc_test.py b/Raspberry Pi/python2/examples/epd_2in9bc_test.py deleted file mode 100644 index b16809d..0000000 --- a/Raspberry Pi/python2/examples/epd_2in9bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9bc Demo") - - epd = epd2in9bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in9bc-b.bmp') - HRYimage = Image.open('../pic/2in9bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_5in83_test.py b/Raspberry Pi/python2/examples/epd_5in83_test.py deleted file mode 100644 index cb7858c..0000000 --- a/Raspberry Pi/python2/examples/epd_5in83_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83 Demo") - - epd = epd5in83.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '5.83inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '5.83inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/5in83.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_5in83bc_test.py b/Raspberry Pi/python2/examples/epd_5in83bc_test.py deleted file mode 100644 index b5e3b39..0000000 --- a/Raspberry Pi/python2/examples/epd_5in83bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83bc Demo") - - epd = epd5in83bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '5.83inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '5.83inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/5in83bc-b.bmp') - HRYimage = Image.open('../pic/5in83bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_7in5_test.py b/Raspberry Pi/python2/examples/epd_7in5_test.py deleted file mode 100644 index eaf11ec..0000000 --- a/Raspberry Pi/python2/examples/epd_7in5_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5 Demo") - - epd = epd7in5.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '7.5inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '7.5inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/7in5.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/examples/epd_7in5bc_test.py b/Raspberry Pi/python2/examples/epd_7in5bc_test.py deleted file mode 100644 index 82153b4..0000000 --- a/Raspberry Pi/python2/examples/epd_7in5bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5bc Demo") - - epd = epd7in5bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '7.5inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '7.5inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/7in5b-b.bmp') - HRYimage = Image.open('../pic/7in5b-r.bmp') - # HBlackimage = Image.open('../pic/7in5c-b.bmp') - # HRYimage = Image.open('../pic/7in5c-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python2/lib/Font.ttc b/Raspberry Pi/python2/lib/Font.ttc deleted file mode 100644 index 4cbb7c5..0000000 Binary files a/Raspberry Pi/python2/lib/Font.ttc and /dev/null differ diff --git a/Raspberry Pi/python2/lib/epd1in54.py b/Raspberry Pi/python2/lib/epd1in54.py deleted file mode 100644 index ffd2815..0000000 --- a/Raspberry Pi/python2/lib/epd1in54.py +++ /dev/null @@ -1,254 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V3.1 -# * | Date : 2019-06-18 -# # | Info : python2 demo -# ----------------------------------------------------------------------------- -# V3.1(2019-06-18): -# 2.remove commands define: -# #define PANEL_SETTING 0x00 -# #define POWER_SETTING 0x01 -# #define POWER_OFF 0x02 -# #define POWER_OFF_SEQUENCE_SETTING 0x03 -# #define POWER_ON 0x04 -# #define POWER_ON_MEASURE 0x05 -# #define BOOSTER_SOFT_START 0x06 -# #define DEEP_SLEEP 0x07 -# #define DATA_START_TRANSMISSION_1 0x10 -# #define DATA_STOP 0x11 -# #define DISPLAY_REFRESH 0x12 -# #define DATA_START_TRANSMISSION_2 0x13 -# #define PLL_CONTROL 0x30 -# #define TEMPERATURE_SENSOR_COMMAND 0x40 -# #define TEMPERATURE_SENSOR_CALIBRATION 0x41 -# #define TEMPERATURE_SENSOR_WRITE 0x42 -# #define TEMPERATURE_SENSOR_READ 0x43 -# #define VCOM_AND_DATA_INTERVAL_SETTING 0x50 -# #define LOW_POWER_DETECTION 0x51 -# #define TCON_SETTING 0x60 -# #define TCON_RESOLUTION 0x61 -# #define SOURCE_AND_GATE_START_SETTING 0x62 -# #define GET_STATUS 0x71 -# #define AUTO_MEASURE_VCOM 0x80 -# #define VCOM_VALUE 0x81 -# #define VCM_DC_SETTING_REGISTER 0x82 -# #define PROGRAM_MODE 0xA0 -# #define ACTIVE_PROGRAM 0xA1 -# #define READ_OTP_DATA 0xA2 -# ----------------------------------------------------------------------------- -# V3.0(2018-11-01): -# # 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 = epd1in54.EPD() -# epd.init(epd.lut_full_update) -# image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) -# ... -# drawing ...... -# ... -# epd.display(getbuffer(image)) -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, - 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, - 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - 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.ReadBusy() - - 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 - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - # set the look-up table register - self.send_command(0x32) - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - # self.SetWindow(0, 0, self.width - 1, self.height - 1) - # send the color data - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width / 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd1in54_V2.py b/Raspberry Pi/python2/lib/epd1in54_V2.py deleted file mode 100644 index a940541..0000000 --- a/Raspberry Pi/python2/lib/epd1in54_V2.py +++ /dev/null @@ -1,206 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V1 -# * | Date : 2019-06-18 -# # | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 - self.send_data(0xF7) - 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_command(0x20) # MASTER_ACTIVATION - - self.ReadBusy() - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - # EPD hardware init start - self.reset() - - 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) - - self.send_command(0x3C) # BorderWavefrom - self.send_data(0x01) - - 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(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() - - def Clear(self, color): - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(color) - self.TurnOnDisplay() - - def getbuffer(self, image): - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - self.TurnOnDisplay() - - def displayPartBaseImage(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - - self.TurnOnDisplayPart() - - def displayPart(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - - self.TurnOnDisplayPart() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd1in54b.py b/Raspberry Pi/python2/lib/epd1in54b.py deleted file mode 100644 index a7ac01d..0000000 --- a/Raspberry Pi/python2/lib/epd1in54b.py +++ /dev/null @@ -1,218 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-18 -# * | Info : python2 demo -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A, 0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00] - lut_w = [0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04] - lut_b = [0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04] - lut_g1 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_g2 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_vcom1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red0 = [0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut_bw(self): - self.send_command(0x20) # vcom - for count in range(0, 15): - self.send_data(self.lut_vcom0[count]) - self.send_command(0x21) # ww -- - for count in range(0, 15): - self.send_data(self.lut_w[count]) - self.send_command(0x22) # bw r - for count in range(0, 15): - self.send_data(self.lut_b[count]) - self.send_command(0x23) # wb w - for count in range(0, 15): - self.send_data(self.lut_g1[count]) - self.send_command(0x24) # bb b - for count in range(0, 15): - self.send_data(self.lut_g2[count]) - - def set_lut_red(self): - self.send_command(0x25) - for count in range(0, 15): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x26) - for count in range(0, 15): - self.send_data(self.lut_red0[count]) - self.send_command(0x27) - for count in range(0, 15): - self.send_data(self.lut_red1[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(0x00) - self.send_data(0x08) - self.send_data(0x00) - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x07) - self.send_command(0x04) # POWER_ON - - self.ReadBusy() - - self.send_command(0X00) # PANEL_SETTING - self.send_data(0xCF) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x39) - self.send_command(0x61) # TCON_RESOLUTION set x and y - self.send_data(0xC8) - self.send_data(0x00) - self.send_data(0xC8) - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x0E) - - self.set_lut_bw() - self.set_lut_red() - return 0 - - def getbuffer(self, image): - buf = [0xFF] * (self.width * self.height / 8) - # Set buffer to value of Python Imaging Library image. - # Image must be in mode 1. - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display \ - ({0}x{1}).' .format(self.width, self.height)) - - pixels = image_monocolor.load() - for y in range(self.height): - for x in range(self.width): - # Set the bits for the column of pixels at the current position. - if pixels[x, y] == 0: - buf[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - return buf - - def display(self, blackimage, redimage): - # send black data - if (blackimage != None): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height / 8): - temp = 0x00 - for bit in range(0, 4): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> (bit * 2) - self.send_data(temp) - temp = 0x00 - for bit in range(4, 8): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> ((bit - 4) * 2) - self.send_data(temp) - - # send red data - if (redimage != None): - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height / 8): - self.send_data(redimage[i]) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_data(0xFF) - - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x82) # to solve Vcom drop - self.send_data(0x00) - self.send_command(0x01) # power setting - self.send_data(0x02) # gate switch to external - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - self.ReadBusy() - - self.send_command(0x02) # power off - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd1in54c.py b/Raspberry Pi/python2/lib/epd1in54c.py deleted file mode 100644 index 8231aca..0000000 --- a/Raspberry Pi/python2/lib/epd1in54c.py +++ /dev/null @@ -1,152 +0,0 @@ -# /***************************************************************************** -# * | File : epd1in54c.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-18 -# * | Info : python2 demo -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -import epdconfig - -# Display resolution -EPD_WIDTH = 152 -EPD_HEIGHT = 152 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(1) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - self.send_command(0x04) # power on - - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0x0f) # LUT from OTP,160x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x61) # resolution setting - self.send_data(0x98) - self.send_data(0x00) - self.send_data(0x98) - - self.send_command(0x50) - self.send_data(0x77) - - def getbuffer(self, image): - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, yellowimage): - self.send_command(0x10) - print("blackimage") - for i in range(0, self.width * self.height / 8): - self.send_data(blackimage[i]) - self.send_command(0x13) - print("yellowimage") - for i in range(0, self.width * self.height / 8): - self.send_data(yellowimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - # after this, call epd.init() to awaken the module - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in13.py b/Raspberry Pi/python2/lib/epd2in13.py deleted file mode 100644 index 39b1914..0000000 --- a/Raspberry Pi/python2/lib/epd2in13.py +++ /dev/null @@ -1,224 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("e-Paper busy release") - - def init(self, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0X3C) # BORDER_WAVEFORM_CONTROL - self.send_data(0x03) - - self.send_command(0X11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment; Y increment - - # WRITE_LUT_REGISTER - self.send_command(0x32) - for count in range(30): - self.send_data(lut[count]) - - return 0 - -## - # @brief: specify the memory area for data R/W - ## - def SetWindows(self, x_start, y_start, x_end, y_end): - self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - -## - # @brief: specify the start point for data R/W - ## - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER - self.send_data(y & 0xFF) - self.send_data((y >> 8) & 0xFF) - self.ReadBusy() - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - # x = imwidth - x - buf[x / 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - # newy = imwidth - newy - 1 - buf[newx / 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in13_V2.py b/Raspberry Pi/python2/lib/epd2in13_V2.py deleted file mode 100644 index aaeed0b..0000000 --- a/Raspberry Pi/python2/lib/epd2in13_V2.py +++ /dev/null @@ -1,315 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2018-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - FULL_UPDATE = 0 - PART_UPDATE = 1 - lut_full_update= [ - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x03,0x03,0x00,0x00,0x02, # TP0 A~D RP0 - 0x09,0x09,0x00,0x00,0x02, # TP1 A~D RP1 - 0x03,0x03,0x00,0x00,0x02, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - lut_partial_update = [ #20 bytes - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x80,0x00,0x00,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x40,0x00,0x00,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x0A,0x00,0x00,0x00,0x00, # TP0 A~D RP0 - 0x00,0x00,0x00,0x00,0x00, # TP1 A~D RP1 - 0x00,0x00,0x00,0x00,0x00, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - self.send_command(0x22) - self.send_data(0xC7) - self.send_command(0x20) - self.ReadBusy() - - def TurnOnDisplayPart(self): - self.send_command(0x22) - self.send_data(0x0c) - self.send_command(0x20) - self.ReadBusy() - - def init(self, update): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - if(update == self.FULL_UPDATE): - self.ReadBusy() - self.send_command(0x12) # soft reset - self.ReadBusy() - - self.send_command(0x74) #set analog block control - self.send_data(0x54) - self.send_command(0x7E) #set digital block control - self.send_data(0x3B) - - self.send_command(0x01) #Driver output control - self.send_data(0xF9) - self.send_data(0x00) - self.send_data(0x00) - - 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(0x0F) #0x0C-->(15+1)*8=128 - - self.send_command(0x45) #set Ram-Y address start/end position - self.send_data(0xF9) #0xF9-->(249+1)=250 - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x03) - - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x55) # - - self.send_command(0x03) - self.send_data(self.lut_full_update[70]) - - self.send_command(0x04) # - self.send_data(self.lut_full_update[71]) - self.send_data(self.lut_full_update[72]) - self.send_data(self.lut_full_update[73]) - - self.send_command(0x3A) #Dummy Line - self.send_data(self.lut_full_update[74]) - self.send_command(0x3B) #Gate time - self.send_data(self.lut_full_update[75]) - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_full_update[count]) - - 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 0X127 - self.send_data(0xF9) - self.send_data(0x00) - self.ReadBusy() - else: - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x26) - - self.ReadBusy() - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_partial_update[count]) - - self.send_command(0x37) - 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_command(0x22) - self.send_data(0xC0) - self.send_command(0x20) - self.ReadBusy() - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x01) - return 0 - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - x = imwidth - x - buf[x / 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - newy = imwidth - newy - 1 - buf[newx / 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def displayPartial(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - # self.send_command(0x26) - # for j in range(0, self.height): - # for i in range(0, linewidth): - # self.send_data(~image[i + j * linewidth]) - self.TurnOnDisplayPart() - - def displayPartBaseImage(self, image): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width/8 - else: - linewidth = self.width/8 + 1 - # print(linewidth) - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x22) #POWER OFF - self.send_data(0xC3) - self.send_command(0x20) - - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in13bc.py b/Raspberry Pi/python2/lib/epd2in13bc.py deleted file mode 100644 index 04f3512..0000000 --- a/Raspberry Pi/python2/lib/epd2in13bc.py +++ /dev/null @@ -1,158 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x8F) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0xF0) - - self.send_command(0x61) # RESOLUTION_SETTING - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) - self.send_data(self.height & 0xff) - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(imageblack[i]) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(imagered[i]) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x92) - - self.send_command(0x12) # REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in13d.py b/Raspberry Pi/python2/lib/epd2in13d.py deleted file mode 100644 index 30ebb77..0000000 --- a/Raspberry Pi/python2/lib/epd2in13d.py +++ /dev/null @@ -1,357 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in13d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) # PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print "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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print "Horizontal" - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (Image == None): - return - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - if (Image == None): - return - - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height / 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) # power off - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in7.py b/Raspberry Pi/python2/lib/epd2in7.py deleted file mode 100644 index 9d5fca6..0000000 --- a/Raspberry Pi/python2/lib/epd2in7.py +++ /dev/null @@ -1,258 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in7.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA0) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0xA1) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xAF) # KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.set_lut() - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - self.send_command(0x12) - self.ReadBusy() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in7b.py b/Raspberry Pi/python2/lib/epd2in7b.py deleted file mode 100644 index f8184e5..0000000 --- a/Raspberry Pi/python2/lib/epd2in7b.py +++ /dev/null @@ -1,268 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in7b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 176 -EPD_HEIGHT = 264 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom_dc = [ - 0x00, 0x00, - 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - lut_ww = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R22H r - lut_bw = [ - 0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0xB0, 0x04, 0x10, 0x00, 0x00, 0x05, - 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # R23H w - lut_bb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - # R24H b - lut_wb = [ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, - 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, - 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, - 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, - 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom_dc[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xaf) #KW-BF KWR-AF BWROTP 0f - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3a) #3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - self.send_data(0x09) # VDHR - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x17) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x60) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x89) - self.send_data(0xA5) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x90) - self.send_data(0x00) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x93) - self.send_data(0x2A) - - # Power optimization - self.send_command(0xF8) - self.send_data(0x73) - self.send_data(0x41) - - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x12) - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x87) # define by OTP - - self.set_lut() - - self.send_command(0x16) # PARTIAL_DISPLAY_REFRESH - self.send_data(0x00) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(~imageblack[i]) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~imagered[i]) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - self.send_command(0x11) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) - self.send_command(0X07) - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in9.py b/Raspberry Pi/python2/lib/epd2in9.py deleted file mode 100644 index 9e2bd6d..0000000 --- a/Raspberry Pi/python2/lib/epd2in9.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(200) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("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 - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - self.send_command(0x32) # WRITE_LUT_REGISTER - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width / 8): - self.send_data(image[i + j * (self.width / 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - self.SetWindow(0, 0, self.width - 1, self.height - 1) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) # WRITE_RAM - for i in range(0, self.width / 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in9bc.py b/Raspberry Pi/python2/lib/epd2in9bc.py deleted file mode 100644 index baee127..0000000 --- a/Raspberry Pi/python2/lib/epd2in9bc.py +++ /dev/null @@ -1,154 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - self.send_command(0X00) # PANEL_SETTING - self.send_data(0x8F) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - self.send_command(0x61) # TCON_RESOLUTION - self.send_data (0x80) - self.send_data (0x01) - self.send_data (0x28) - # self.send_command(VCM_DC_SETTING_REGISTER) - # self.send_data (0x0A) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, ryimage): # ryimage: red or yellow image - if (blackimage != None): - self.send_command(0X10) - for i in range(0, self.width * self.height / 8): - self.send_data(blackimage[i]) - if (ryimage != None): - self.send_command(0X13) - for i in range(0, self.width * self.height / 8): - self.send_data(ryimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0X10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xff) - self.send_command(0X13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xff) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd2in9d.py b/Raspberry Pi/python2/lib/epd2in9d.py deleted file mode 100644 index ab0212c..0000000 --- a/Raspberry Pi/python2/lib/epd2in9d.py +++ /dev/null @@ -1,350 +0,0 @@ -# /***************************************************************************** -# * | File : epd2in9d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V2.0 -# * | Date : 2019-06-19 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) #PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height / 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) #power off - self.send_command(0X07) #deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd4in2.py b/Raspberry Pi/python2/lib/epd4in2.py deleted file mode 100644 index 36c07b1..0000000 --- a/Raspberry Pi/python2/lib/epd4in2.py +++ /dev/null @@ -1,240 +0,0 @@ -# /***************************************************************************** -# * | File : epd4in2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [ - 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_ww = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_wb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - lut_bb = [ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, - 0x80, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def set_lut(self): - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom0[count]) - - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_wb[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(0x03) # VDS_EN, VDG_EN - self.send_data(0x00) # VCOM_HV, VGHL_LV[1], VGHL_LV[0] - self.send_data(0x2b) # VDH - self.send_data(0x2b) # VDL - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # KW-BF KWR-AF BWROTP 0f - self.send_data(0x0d) - - self.send_command(0x30) # PLL setting - self.send_data(0x3c) # 3A 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(0x01) - self.send_data(0x90) # 128 - self.send_data(0x01) - self.send_data(0x2c) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x97) # 97white border 77black border VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - - self.set_lut() - # EPD hardware init end - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print "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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print "Vertical" - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(image[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd4in2bc.py b/Raspberry Pi/python2/lib/epd4in2bc.py deleted file mode 100644 index 0760c48..0000000 --- a/Raspberry Pi/python2/lib/epd4in2bc.py +++ /dev/null @@ -1,147 +0,0 @@ -# /***************************************************************************** -# * | File : epd4in2bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) # 07 0f 17 1f 27 2F 37 2f - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x0F) # LUT from OTP - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(imageblack[i]) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(imagered[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height / 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd5in83.py b/Raspberry Pi/python2/lib/epd5in83.py deleted file mode 100644 index e309db0..0000000 --- a/Raspberry Pi/python2/lib/epd5in83.py +++ /dev/null @@ -1,199 +0,0 @@ -# /***************************************************************************** -# * | File : epd5in83.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xC0) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height / 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) / 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) / 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) / 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) / 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd5in83bc.py b/Raspberry Pi/python2/lib/epd5in83bc.py deleted file mode 100644 index 60ef7d6..0000000 --- a/Raspberry Pi/python2/lib/epd5in83bc.py +++ /dev/null @@ -1,199 +0,0 @@ -# /***************************************************************************** -# * | File : epd5in83b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - self.send_command(0X82) # VCOM VOLTAGE SETTING - self.send_data(0x28) # all temperature range - - self.send_command(0x06) # boost - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0X60) # TCON SETTING - self.send_data(0x22) - - self.send_command(0X65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # tres - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xc0) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd7in5.py b/Raspberry Pi/python2/lib/epd7in5.py deleted file mode 100644 index 6e5a70f..0000000 --- a/Raspberry Pi/python2/lib/epd7in5.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd7in5.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(EPD_WIDTH >> 8) #source 640 - self.send_data(EPD_WIDTH & 0xff) - self.send_data(EPD_HEIGHT >> 8) #gate 384 - self.send_data(EPD_HEIGHT & 0xff) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height / 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) / 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) / 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) / 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) / 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) / 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) / 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epd7in5bc.py b/Raspberry Pi/python2/lib/epd7in5bc.py deleted file mode 100644 index 58157f8..0000000 --- a/Raspberry Pi/python2/lib/epd7in5bc.py +++ /dev/null @@ -1,200 +0,0 @@ -# /***************************************************************************** -# * | File : epd7in5bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# * | Info : python2 demo -# ******************************************************************************/ -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x28) #all temperature range - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0x50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(self.width >> 8) # source 640 - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) # gate 384 - self.send_data(self.height & 0xff) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width/8) * self.height - buf = [0xFF] * ((self.width/8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) / 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) / 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width / 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python2/lib/epdconfig.py b/Raspberry Pi/python2/lib/epdconfig.py deleted file mode 100644 index 148f934..0000000 --- a/Raspberry Pi/python2/lib/epdconfig.py +++ /dev/null @@ -1,75 +0,0 @@ -# /***************************************************************************** -# * | File : epdconfig.py -# * | Author : Waveshare team -# * | Function : Hardware underlying interface -# * | Info : -# *---------------- -# * | This version: V1.0 -# * | Date : 2019-06-21 -# * | Info : -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import spidev -import RPi.GPIO as GPIO -import time - -# Pin definition -RST_PIN = 17 -DC_PIN = 25 -CS_PIN = 8 -BUSY_PIN = 24 - -# SPI device, bus = 0, device = 0 -SPI = spidev.SpiDev(0, 0) - -def digital_write(pin, value): - GPIO.output(pin, value) - -def digital_read(pin): - return GPIO.input(BUSY_PIN) - -def delay_ms(delaytime): - time.sleep(delaytime / 1000.0) - -def spi_writebyte(data): - SPI.writebytes(data) - -def module_init(): - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - GPIO.setup(RST_PIN, GPIO.OUT) - GPIO.setup(DC_PIN, GPIO.OUT) - GPIO.setup(CS_PIN, GPIO.OUT) - GPIO.setup(BUSY_PIN, GPIO.IN) - SPI.max_speed_hz = 2000000 - SPI.mode = 0b00 - return 0 - -def module_exit(): - print("spi end") - SPI.close() - - print("close 5V, Module enters 0 power consumption ...") - GPIO.output(RST_PIN, 0) - GPIO.output(DC_PIN, 0) - - GPIO.cleanup() -### END OF FILE ### diff --git a/Raspberry Pi/python2/pic/100x100.bmp b/Raspberry Pi/python2/pic/100x100.bmp deleted file mode 100644 index 70f4584..0000000 Binary files a/Raspberry Pi/python2/pic/100x100.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/1in54.bmp b/Raspberry Pi/python2/pic/1in54.bmp deleted file mode 100644 index a877bfa..0000000 Binary files a/Raspberry Pi/python2/pic/1in54.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/1in54b-b.bmp b/Raspberry Pi/python2/pic/1in54b-b.bmp deleted file mode 100644 index e992aea..0000000 Binary files a/Raspberry Pi/python2/pic/1in54b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/1in54b-r.bmp b/Raspberry Pi/python2/pic/1in54b-r.bmp deleted file mode 100644 index 68c339b..0000000 Binary files a/Raspberry Pi/python2/pic/1in54b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/1in54c-b.bmp b/Raspberry Pi/python2/pic/1in54c-b.bmp deleted file mode 100644 index 159795e..0000000 Binary files a/Raspberry Pi/python2/pic/1in54c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/1in54c-y.bmp b/Raspberry Pi/python2/pic/1in54c-y.bmp deleted file mode 100644 index fe37382..0000000 Binary files a/Raspberry Pi/python2/pic/1in54c-y.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in13-v2.bmp b/Raspberry Pi/python2/pic/2in13-v2.bmp deleted file mode 100644 index 5156852..0000000 Binary files a/Raspberry Pi/python2/pic/2in13-v2.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in13.bmp b/Raspberry Pi/python2/pic/2in13.bmp deleted file mode 100644 index a579e2a..0000000 Binary files a/Raspberry Pi/python2/pic/2in13.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in13bc-b.bmp b/Raspberry Pi/python2/pic/2in13bc-b.bmp deleted file mode 100644 index 6b70b26..0000000 Binary files a/Raspberry Pi/python2/pic/2in13bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in13bc-ry.bmp b/Raspberry Pi/python2/pic/2in13bc-ry.bmp deleted file mode 100644 index ec5cf02..0000000 Binary files a/Raspberry Pi/python2/pic/2in13bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in13d.bmp b/Raspberry Pi/python2/pic/2in13d.bmp deleted file mode 100644 index 6f0a83d..0000000 Binary files a/Raspberry Pi/python2/pic/2in13d.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in7.bmp b/Raspberry Pi/python2/pic/2in7.bmp deleted file mode 100644 index 48138bb..0000000 Binary files a/Raspberry Pi/python2/pic/2in7.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in7b-b.bmp b/Raspberry Pi/python2/pic/2in7b-b.bmp deleted file mode 100644 index d25dec3..0000000 Binary files a/Raspberry Pi/python2/pic/2in7b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in7b-r.bmp b/Raspberry Pi/python2/pic/2in7b-r.bmp deleted file mode 100644 index 66d51b1..0000000 Binary files a/Raspberry Pi/python2/pic/2in7b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in9.bmp b/Raspberry Pi/python2/pic/2in9.bmp deleted file mode 100644 index c3e0181..0000000 Binary files a/Raspberry Pi/python2/pic/2in9.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in9bc-b.bmp b/Raspberry Pi/python2/pic/2in9bc-b.bmp deleted file mode 100644 index d45ff48..0000000 Binary files a/Raspberry Pi/python2/pic/2in9bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in9bc-ry.bmp b/Raspberry Pi/python2/pic/2in9bc-ry.bmp deleted file mode 100644 index 402727c..0000000 Binary files a/Raspberry Pi/python2/pic/2in9bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/2in9d.bmp b/Raspberry Pi/python2/pic/2in9d.bmp deleted file mode 100644 index 61e0fd3..0000000 Binary files a/Raspberry Pi/python2/pic/2in9d.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/4in2.bmp b/Raspberry Pi/python2/pic/4in2.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Raspberry Pi/python2/pic/4in2.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/4in2b-b.bmp b/Raspberry Pi/python2/pic/4in2b-b.bmp deleted file mode 100644 index 7c537a4..0000000 Binary files a/Raspberry Pi/python2/pic/4in2b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/4in2b-r.bmp b/Raspberry Pi/python2/pic/4in2b-r.bmp deleted file mode 100644 index 3de854c..0000000 Binary files a/Raspberry Pi/python2/pic/4in2b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/4in2c-b.bmp b/Raspberry Pi/python2/pic/4in2c-b.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Raspberry Pi/python2/pic/4in2c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/4in2c-y.bmp b/Raspberry Pi/python2/pic/4in2c-y.bmp deleted file mode 100644 index cd5c0d6..0000000 Binary files a/Raspberry Pi/python2/pic/4in2c-y.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/5in83.bmp b/Raspberry Pi/python2/pic/5in83.bmp deleted file mode 100644 index 6b8f604..0000000 Binary files a/Raspberry Pi/python2/pic/5in83.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/5in83bc-b.bmp b/Raspberry Pi/python2/pic/5in83bc-b.bmp deleted file mode 100644 index 545e060..0000000 Binary files a/Raspberry Pi/python2/pic/5in83bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/5in83bc-ry.bmp b/Raspberry Pi/python2/pic/5in83bc-ry.bmp deleted file mode 100644 index 41884b3..0000000 Binary files a/Raspberry Pi/python2/pic/5in83bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/7in5.bmp b/Raspberry Pi/python2/pic/7in5.bmp deleted file mode 100644 index b997800..0000000 Binary files a/Raspberry Pi/python2/pic/7in5.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/7in5b-b.bmp b/Raspberry Pi/python2/pic/7in5b-b.bmp deleted file mode 100644 index 8f84025..0000000 Binary files a/Raspberry Pi/python2/pic/7in5b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/7in5b-r.bmp b/Raspberry Pi/python2/pic/7in5b-r.bmp deleted file mode 100644 index 3f81b2c..0000000 Binary files a/Raspberry Pi/python2/pic/7in5b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/7in5c-b.bmp b/Raspberry Pi/python2/pic/7in5c-b.bmp deleted file mode 100644 index a69ddbc..0000000 Binary files a/Raspberry Pi/python2/pic/7in5c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/pic/7in5c-r.bmp b/Raspberry Pi/python2/pic/7in5c-r.bmp deleted file mode 100644 index be84903..0000000 Binary files a/Raspberry Pi/python2/pic/7in5c-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python2/readme_CN.txt b/Raspberry Pi/python2/readme_CN.txt deleted file mode 100644 index e44f344..0000000 --- a/Raspberry Pi/python2/readme_CN.txt +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** -* | File : Readme_CN.txt -* | Author : Waveshare team -* | Function : Help with use -* | Info : -*---------------- -* | This version: V1.0 -* | Date : 2019-06-20 -* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 -******************************************************************************/ -这个文件是帮助您使用本例程。 -由于我们的墨水屏越来越多,不便于我们的维护,因此把所有的墨水屏程序做成一个工程。 -在这里简略的描述本工程的使用: - -1.基本信息: -本例程是基于2019-04-08-raspbian-stretch系统镜像而开发的, -本例程均在Raspberry Pi 3B+上进行了验证; -本例程使用e-paper Driver HAT模块进行了验证,你可以在工程的examples\中查看对应的测试例程; - -2.管脚连接: -管脚连接你可以在\lib\epdconfig.py中查看,这里也再重述一次: -EPD => Jetson Nano/RPI(BCM) -VCC -> 3.3 -GND -> GND -DIN -> 10(SPI0_MOSI) -CLK -> 11(SPI0_SCK) -CS -> 8(SPI0_CS0) -DC -> 25 -RST -> 17 -BUSY -> 24 - -3.安装库: - sudo apt-get update - sudo apt-get install python-pip - sudo apt-get install python-pil - sudo apt-get install python-numpy - sudo pip install RPi.GPIO - -4.基本使用: -由于本工程是一个综合工程,对于使用而言,你可能需要阅读以下内容: -你可以在examples\目录中查看测试程序 -请注意你购买的是哪一款的墨水屏。 -栗子1: - 如果你购买的5.83inch e-paper,那么你应该执行命令: - sudo python epd_5in83_test.py -栗子2: - 如果你购买的2.9inch e-paper (B),由于2.9寸的B型和C型是公用的驱动代码, - 那么你应该执行命令: - sudo python epd_2in9bc_test.py - -注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 \ No newline at end of file diff --git a/Raspberry Pi/python2/readme_EN.txt b/Raspberry Pi/python2/readme_EN.txt deleted file mode 100644 index e83e35b..0000000 --- a/Raspberry Pi/python2/readme_EN.txt +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** -* | File : Readme_CN.txt -* | Author : Waveshare team -* | Function : Help with use -* | Info : -*---------------- -* | This version: V1.0 -* | Date : 2019-06-20 -* | Info : Here is an English version of the documentation for your quick use. -******************************************************************************/ -This file is to help you use this Demo. -Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project. -A brief description of the use of this project is here: - -1. Basic information: -This Demo was developed based on the 2019-04-08-raspbian-stretch system image; -This Demo has been verified on the Raspberry Pi 3B+; -This Demo has been verified using the e-paper Driver HAT module. -You can view the corresponding test routines in the examples\ of the project; - -2. Pin connection: -Pin connections can be viewed in \lib\epdconfig.py and will be repeated here: -EPD => Jetson Nano/RPI(BCM) -VCC -> 3.3 -GND -> GND -DIN -> 10(SPI0_MOSI) -CLK -> 11(SPI0_SCK) -CS -> 8(SPI0_CS0) -DC -> 25 -RST -> 17 -BUSY -> 24 - -3.Installation library - sudo apt-get update - sudo apt-get install python-pip - sudo apt-get install python-pil - sudo apt-get install python-numpy - sudo pip install RPi.GPIO - -4. Basic use: -Since this project is a comprehensive project, you may need to read the following for use: -You can view the test program in the examples\ directory. -Please note which ink screen you purchased. -Chestnut 1: -     If you purchased 5.83inch e-paper, then you should execute the command: -     Sudo python epd_5in83_test.py -Chestnut 2: -     If you buy a 2.9inch e-paper (B), since the 2.9-inch Type B and Type C are common driver codes, -     Then you should execute the command: -     Sudo python epd_2in9bc_test.py -     -Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. \ No newline at end of file diff --git a/Raspberry Pi/python3/examples/epd_1in54_V2_test.py b/Raspberry Pi/python3/examples/epd_1in54_V2_test.py deleted file mode 100644 index 2e51114..0000000 --- a/Raspberry Pi/python3/examples/epd_1in54_V2_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54_V2 Demo") - - epd = epd1in54_V2.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - image = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - draw = ImageDraw.Draw(image) - font = ImageFont.truetype('../lib/Font.ttc', 24) - draw.rectangle((0, 10, 200, 34), fill = 0) - draw.text((8, 12), 'hello world', font = font, fill = 255) - draw.text((8, 36), u'微雪电子', font = font, fill = 0) - draw.line((16, 60, 56, 60), fill = 0) - draw.line((56, 60, 56, 110), fill = 0) - draw.line((16, 110, 56, 110), fill = 0) - draw.line((16, 110, 16, 60), fill = 0) - draw.line((16, 60, 56, 110), fill = 0) - draw.line((56, 60, 16, 110), fill = 0) - draw.arc((90, 60, 150, 120), 0, 360, fill = 0) - draw.rectangle((16, 130, 56, 180), fill = 0) - draw.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(image.rotate(90))) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/1in54.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - epd.Clear(0xFF) - image1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (50,50)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # partial update - print("4.show time...") - time_image = Image.new('1', (epd.width, epd.height), 255) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.displayPart(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init() - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() \ No newline at end of file diff --git a/Raspberry Pi/python3/examples/epd_1in54b_test.py b/Raspberry Pi/python3/examples/epd_1in54b_test.py deleted file mode 100644 index d48b8e2..0000000 --- a/Raspberry Pi/python3/examples/epd_1in54b_test.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54b Demo") - - epd = epd1in54b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawred = ImageDraw.Draw(redimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font18, fill = 0) - drawblack.line((16, 60, 56, 60), fill = 0) - drawblack.line((56, 60, 56, 110), fill = 0) - drawblack.line((16, 110, 56, 110), fill = 0) - drawred.line((16, 110, 16, 60), fill = 0) - drawred.line((16, 60, 56, 110), fill = 0) - drawred.line((56, 60, 16, 110), fill = 0) - drawred.arc((90, 60, 150, 120), 0, 360, fill = 0) - drawred.rectangle((16, 130, 56, 180), fill = 0) - drawred.chord((90, 130, 150, 190), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54b-b.bmp') - redimage = Image.open('../pic/1in54b-r.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(redimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_1in54c_test.py b/Raspberry Pi/python3/examples/epd_1in54c_test.py deleted file mode 100644 index 7374e6d..0000000 --- a/Raspberry Pi/python3/examples/epd_1in54c_test.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd1in54c -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd1in54c Demo") - - epd = epd1in54c.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("1.Drawing on the image...") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - drawblack = ImageDraw.Draw(blackimage) - drawyellow = ImageDraw.Draw(yellowimage) - drawblack.rectangle((0, 10, 200, 34), fill = 0) - drawblack.text((8, 12), 'hello world', font = font, fill = 255) - drawblack.text((8, 36), u'微雪电子', font = font, fill = 0) - drawblack.line((10, 100, 70, 100), fill = 0) - drawblack.line((40, 70, 40, 130), fill = 0) - - drawyellow.rectangle((10, 70, 70, 130), outline = 0) - drawyellow.arc((80, 70, 140, 130), 0, 360, fill = 0) - drawyellow.chord((90, 80, 130, 120), 0, 360, fill = 0) - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file - print("2.read bmp file...") - blackimage = Image.open('../pic/1in54c-b.bmp') - yellowimage = Image.open('../pic/1in54c-y.bmp') - epd.display(epd.getbuffer(blackimage),epd.getbuffer(yellowimage)) - time.sleep(1) - - # read bmp file on window - print("3.read bmp file on window...") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - yellowimage2 = Image.new('1', (epd.width, epd.height), 255) - - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,50)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(yellowimage2)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in13_V2_test.py b/Raspberry Pi/python3/examples/epd_2in13_V2_test.py deleted file mode 100644 index 85f5ee7..0000000 --- a/Raspberry Pi/python3/examples/epd_2in13_V2_test.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13_V2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13_V2 Demo") - - epd = epd2in13_V2.EPD() - print("init and Clear") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - - epd.init(epd.FULL_UPDATE) - epd.displayPartBaseImage(epd.getbuffer(time_image)) - - epd.init(epd.PART_UPDATE) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.displayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.FULL_UPDATE) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in13_test.py b/Raspberry Pi/python3/examples/epd_2in13_test.py deleted file mode 100644 index 1081d79..0000000 --- a/Raspberry Pi/python3/examples/epd_2in13_test.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13 Demo") - - epd = epd2in13.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - # Drawing on the image - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - - print("1.Drawing on the image...") - image = Image.new('1', (epd.height, 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) - draw.text((120, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 90), u'微雪电子', font = font24, fill = 0) - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file - print("2.read bmp file...") - image = Image.open('../pic/2in13.bmp') - epd.display(epd.getbuffer(image)) - time.sleep(2) - - # read bmp file on window - print("3.read bmp file on window...") - # epd.Clear(0xFF) - image1 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - image1.paste(bmp, (2,2)) - epd.display(epd.getbuffer(image1)) - time.sleep(2) - - # # partial update - print("4.show time...") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((120, 80, 220, 105), fill = 255) - time_draw.text((120, 80), time.strftime('%H:%M:%S'), font = font24, fill = 0) - epd.display(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in13bc_test.py b/Raspberry Pi/python3/examples/epd_2in13bc_test.py deleted file mode 100644 index ad24c87..0000000 --- a/Raspberry Pi/python3/examples/epd_2in13bc_test.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13bc Demo") - - epd = epd2in13bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font20 = ImageFont.truetype('../lib/Font.ttc', 20) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font20, fill = 0) - drawblack.text((10, 20), '2.13inch e-Paper bc', font = font20, fill = 0) - drawblack.text((120, 0), u'微雪电子', font = font20, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((85, 55, 125, 95), 0, 360, fill =1) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.13 epd b', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.arc((15, 95, 55, 135), 0, 360, fill = 0) - drawry.chord((15, 155, 55, 195), 0, 360, fill =1) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in13bc-b.bmp') - HRYimage = Image.open('../pic/2in13bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (10,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in13d_test.py b/Raspberry Pi/python3/examples/epd_2in13d_test.py deleted file mode 100644 index 883ccb3..0000000 --- a/Raspberry Pi/python3/examples/epd_2in13d_test.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in13d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in13d Demo") - - epd = epd2in13d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font15 = ImageFont.truetype('../lib/Font.ttc', 15) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - 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) - draw.text((110, 60), 'e-Paper demo', font = font15, fill = 0) - draw.text((110, 80), u'微雪电子', font = font15, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in13d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (20,20)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), time.strftime('%H:%M:%S'), font = font24, fill = 0) - newimage = time_image.crop([10, 10, 120, 50]) - time_image.paste(newimage, (10,10)) - epd.DisplayPartial(epd.getbuffer(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in7_test.py b/Raspberry Pi/python3/examples/epd_2in7_test.py deleted file mode 100644 index 24a7c43..0000000 --- a/Raspberry Pi/python3/examples/epd_2in7_test.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7 Demo") - - epd = epd2in7.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in7.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in7b_test.py b/Raspberry Pi/python3/examples/epd_2in7b_test.py deleted file mode 100644 index ece7390..0000000 --- a/Raspberry Pi/python3/examples/epd_2in7b_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in7b -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in7b Demo") - - epd = epd2in7b.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - blackimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - redimage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - - drawblack = ImageDraw.Draw(HBlackimage) - drawred = ImageDraw.Draw(HRedimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawred.line((165, 50, 165, 100), fill = 0) - drawred.line((140, 75, 190, 75), fill = 0) - drawred.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawred.rectangle((80, 50, 130, 100), fill = 0) - drawred.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRedimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawred = ImageDraw.Draw(LRedimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawred.line((95, 90, 95, 140), fill = 0) - drawred.line((70, 115, 120, 115), fill = 0) - drawred.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawred.rectangle((10, 150, 60, 200), fill = 0) - drawred.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRedimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in7b-b.bmp') - HRedimage = Image.open('../pic/2in7b-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in9_test.py b/Raspberry Pi/python3/examples/epd_2in9_test.py deleted file mode 100644 index 59c7ca1..0000000 --- a/Raspberry Pi/python3/examples/epd_2in9_test.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9 Demo") - - epd = epd2in9.EPD() - print("init and Clear") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # partial update - print("5.show time") - epd.init(epd.lut_partial_update) - epd.Clear(0xFF) - time_image = Image.new('1', (epd.height, epd.width), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.init(epd.lut_full_update) - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in9bc_test.py b/Raspberry Pi/python3/examples/epd_2in9bc_test.py deleted file mode 100644 index b16809d..0000000 --- a/Raspberry Pi/python3/examples/epd_2in9bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9bc Demo") - - epd = epd2in9bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 - HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '2.9inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '2.9inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/2in9bc-b.bmp') - HRYimage = Image.open('../pic/2in9bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - redimage1 = Image.new('1', (epd.height, epd.width), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_2in9d_test.py b/Raspberry Pi/python3/examples/epd_2in9d_test.py deleted file mode 100644 index 34f5f71..0000000 --- a/Raspberry Pi/python3/examples/epd_2in9d_test.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd2in9d -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd2in9d Demo") - - epd = epd2in9d.EPD() - print("init and Clear") - epd.init() - epd.Clear(0xFF) - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '2.9inch e-Paper d', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '2.9inch epd d', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/2in9d.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - # # partial update - print("5.show time...") - epd.init() - epd.Clear(0xFF) - - time_image = Image.new('1', (epd.width, epd.height), 255) - time_draw = ImageDraw.Draw(time_image) - num = 0 - while (True): - time_draw.rectangle((10, 10, 120, 50), fill = 255) - time_draw.text((10, 10), 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(time_image)) - num = num + 1 - if(num == 10): - break - - print("Clear...") - epd.Clear(0xFF) - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_4in2_test.py b/Raspberry Pi/python3/examples/epd_4in2_test.py deleted file mode 100644 index 6343f58..0000000 --- a/Raspberry Pi/python3/examples/epd_4in2_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2 Demo") - - epd = epd4in2.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '4.2inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '4.2inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/4in2.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_4in2bc_test.py b/Raspberry Pi/python3/examples/epd_4in2bc_test.py deleted file mode 100644 index ad1abda..0000000 --- a/Raspberry Pi/python3/examples/epd_4in2bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd4in2bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd4in2bc Demo") - - epd = epd4in2bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '4.2inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '4.2inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/4in2b-b.bmp') - HRYimage = Image.open('../pic/4in2b-r.bmp') - # HBlackimage = Image.open('../pic/4in2c-b.bmp') - # HRYimage = Image.open('../pic/4in2c-y.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_5in83_test.py b/Raspberry Pi/python3/examples/epd_5in83_test.py deleted file mode 100644 index cb7858c..0000000 --- a/Raspberry Pi/python3/examples/epd_5in83_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83 Demo") - - epd = epd5in83.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '5.83inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '5.83inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/5in83.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_5in83bc_test.py b/Raspberry Pi/python3/examples/epd_5in83bc_test.py deleted file mode 100644 index b5e3b39..0000000 --- a/Raspberry Pi/python3/examples/epd_5in83bc_test.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd5in83bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd5in83bc Demo") - - epd = epd5in83bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '5.83inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '5.83inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/5in83bc-b.bmp') - HRYimage = Image.open('../pic/5in83bc-ry.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_7in5_test.py b/Raspberry Pi/python3/examples/epd_7in5_test.py deleted file mode 100644 index eaf11ec..0000000 --- a/Raspberry Pi/python3/examples/epd_7in5_test.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5 -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5 Demo") - - epd = epd7in5.EPD() - print("init and Clear") - epd.init() - epd.Clear() - - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame - draw = ImageDraw.Draw(Himage) - draw.text((10, 0), 'hello world', font = font24, fill = 0) - draw.text((10, 20), '7.5inch e-Paper', font = font24, fill = 0) - draw.text((150, 0), u'微雪电子', font = font24, fill = 0) - draw.line((20, 50, 70, 100), fill = 0) - draw.line((70, 50, 20, 100), fill = 0) - draw.rectangle((20, 50, 70, 100), outline = 0) - draw.line((165, 50, 165, 100), fill = 0) - draw.line((140, 75, 190, 75), fill = 0) - draw.arc((140, 50, 190, 100), 0, 360, fill = 0) - draw.rectangle((80, 50, 130, 100), fill = 0) - draw.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - draw = ImageDraw.Draw(Limage) - draw.text((2, 0), 'hello world', font = font18, fill = 0) - draw.text((2, 20), '7.5inch epd', font = font18, fill = 0) - draw.text((20, 50), u'微雪电子', font = font18, fill = 0) - draw.line((10, 90, 60, 140), fill = 0) - draw.line((60, 90, 10, 140), fill = 0) - draw.rectangle((10, 90, 60, 140), outline = 0) - draw.line((95, 90, 95, 140), fill = 0) - draw.line((70, 115, 120, 115), fill = 0) - draw.arc((70, 90, 120, 140), 0, 360, fill = 0) - draw.rectangle((10, 150, 60, 200), fill = 0) - draw.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(Limage)) - time.sleep(2) - - print("3.read bmp file") - Himage = Image.open('../pic/7in5.bmp') - epd.display(epd.getbuffer(Himage)) - time.sleep(2) - - print("4.read bmp file on window") - Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame - bmp = Image.open('../pic/100x100.bmp') - Himage2.paste(bmp, (50,10)) - epd.display(epd.getbuffer(Himage2)) - time.sleep(2) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/examples/epd_7in5bc_test.py b/Raspberry Pi/python3/examples/epd_7in5bc_test.py deleted file mode 100644 index 82153b4..0000000 --- a/Raspberry Pi/python3/examples/epd_7in5bc_test.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- -import sys -sys.path.append(r'../lib') - -import epd7in5bc -import epdconfig -import time -from PIL import Image,ImageDraw,ImageFont -import traceback - -try: - print("epd7in5bc Demo") - - epd = epd7in5bc.EPD() - print("init and Clear") - epd.init() - epd.Clear() - time.sleep(1) - - # Drawing on the image - print("Drawing") - font24 = ImageFont.truetype('../lib/Font.ttc', 24) - font18 = ImageFont.truetype('../lib/Font.ttc', 18) - - # Drawing on the Horizontal image - print("1.Drawing on the Horizontal image...") - HBlackimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 - HRYimage = Image.new('1', (epd.width, epd.height), 255) # 298*126 ryimage: red or yellow image - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) - drawblack.text((10, 0), 'hello world', font = font24, fill = 0) - drawblack.text((10, 20), '7.5inch e-Paper bc', font = font24, fill = 0) - drawblack.text((150, 0), u'微雪电子', font = font24, fill = 0) - drawblack.line((20, 50, 70, 100), fill = 0) - drawblack.line((70, 50, 20, 100), fill = 0) - drawblack.rectangle((20, 50, 70, 100), outline = 0) - drawry.line((165, 50, 165, 100), fill = 0) - drawry.line((140, 75, 190, 75), fill = 0) - drawry.arc((140, 50, 190, 100), 0, 360, fill = 0) - drawry.rectangle((80, 50, 130, 100), fill = 0) - drawry.chord((200, 50, 250, 100), 0, 360, fill = 0) - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - # Drawing on the Vertical image - print("2.Drawing on the Vertical image...") - LBlackimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - LRYimage = Image.new('1', (epd.height, epd.width), 255) # 126*298 - drawblack = ImageDraw.Draw(LBlackimage) - drawry = ImageDraw.Draw(LRYimage) - - drawblack.text((2, 0), 'hello world', font = font18, fill = 0) - drawblack.text((2, 20), '7.5inch epd bc', font = font18, fill = 0) - drawblack.text((20, 50), u'微雪电子', font = font18, fill = 0) - drawblack.line((10, 90, 60, 140), fill = 0) - drawblack.line((60, 90, 10, 140), fill = 0) - drawblack.rectangle((10, 90, 60, 140), outline = 0) - drawry.line((95, 90, 95, 140), fill = 0) - drawry.line((70, 115, 120, 115), fill = 0) - drawry.arc((70, 90, 120, 140), 0, 360, fill = 0) - drawry.rectangle((10, 150, 60, 200), fill = 0) - drawry.chord((70, 150, 120, 200), 0, 360, fill = 0) - epd.display(epd.getbuffer(LBlackimage), epd.getbuffer(LRYimage)) - time.sleep(2) - - print("3.read bmp file") - HBlackimage = Image.open('../pic/7in5b-b.bmp') - HRYimage = Image.open('../pic/7in5b-r.bmp') - # HBlackimage = Image.open('../pic/7in5c-b.bmp') - # HRYimage = Image.open('../pic/7in5c-r.bmp') - epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) - time.sleep(2) - - print("4.read bmp file on window") - blackimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - redimage1 = Image.new('1', (epd.width, epd.height), 255) # 298*126 - newimage = Image.open('../pic/100x100.bmp') - blackimage1.paste(newimage, (50,10)) - epd.display(epd.getbuffer(blackimage1), epd.getbuffer(redimage1)) - - print("Clear...") - epd.init() - epd.Clear() - - print("Goto Sleep...") - epd.sleep() - -except IOError as e: - print(e) - -except KeyboardInterrupt: - print("ctrl + c:") - epdconfig.module_exit() - exit() diff --git a/Raspberry Pi/python3/lib/Font.ttc b/Raspberry Pi/python3/lib/Font.ttc deleted file mode 100644 index 4cbb7c5..0000000 Binary files a/Raspberry Pi/python3/lib/Font.ttc and /dev/null differ diff --git a/Raspberry Pi/python3/lib/epd1in54.py b/Raspberry Pi/python3/lib/epd1in54.py deleted file mode 100644 index 54a21e4..0000000 --- a/Raspberry Pi/python3/lib/epd1in54.py +++ /dev/null @@ -1,254 +0,0 @@ -# ***************************************************************************** -# * | File : epd1in54.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V3.1 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# V3.1(2019-06-18): -# 2.remove commands define: -# #define PANEL_SETTING 0x00 -# #define POWER_SETTING 0x01 -# #define POWER_OFF 0x02 -# #define POWER_OFF_SEQUENCE_SETTING 0x03 -# #define POWER_ON 0x04 -# #define POWER_ON_MEASURE 0x05 -# #define BOOSTER_SOFT_START 0x06 -# #define DEEP_SLEEP 0x07 -# #define DATA_START_TRANSMISSION_1 0x10 -# #define DATA_STOP 0x11 -# #define DISPLAY_REFRESH 0x12 -# #define DATA_START_TRANSMISSION_2 0x13 -# #define PLL_CONTROL 0x30 -# #define TEMPERATURE_SENSOR_COMMAND 0x40 -# #define TEMPERATURE_SENSOR_CALIBRATION 0x41 -# #define TEMPERATURE_SENSOR_WRITE 0x42 -# #define TEMPERATURE_SENSOR_READ 0x43 -# #define VCOM_AND_DATA_INTERVAL_SETTING 0x50 -# #define LOW_POWER_DETECTION 0x51 -# #define TCON_SETTING 0x60 -# #define TCON_RESOLUTION 0x61 -# #define SOURCE_AND_GATE_START_SETTING 0x62 -# #define GET_STATUS 0x71 -# #define AUTO_MEASURE_VCOM 0x80 -# #define VCOM_VALUE 0x81 -# #define VCM_DC_SETTING_REGISTER 0x82 -# #define PROGRAM_MODE 0xA0 -# #define ACTIVE_PROGRAM 0xA1 -# #define READ_OTP_DATA 0xA2 -# ----------------------------------------------------------------------------- -# V3.0(2018-11-01): -# # 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 = epd1in54.EPD() -# epd.init(epd.lut_full_update) -# image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) -# ... -# drawing ...... -# ... -# epd.display(getbuffer(image)) -# ******************************************************************************// -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, - 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, - 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 - ] - - lut_partial_update = [ - 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - 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.ReadBusy() - - 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 - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - - 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, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0x11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment Y increment - - # set the look-up table register - self.send_command(0x32) - for i in range(0, len(lut)): - self.send_data(lut[i]) - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0xFF] * ((self.width // 8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - self.TurnOnDisplay() - - def Clear(self, color): - # self.SetWindow(0, 0, self.width - 1, self.height - 1) - # send the color data - self.SetWindow(0, 0, self.width, self.height) - for j in range(0, self.height): - self.SetCursor(0, j) - self.send_command(0x24) - for i in range(0, self.width // 8): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd1in54_V2.py b/Raspberry Pi/python3/lib/epd1in54_V2.py deleted file mode 100644 index 76136ed..0000000 --- a/Raspberry Pi/python3/lib/epd1in54_V2.py +++ /dev/null @@ -1,206 +0,0 @@ -# ***************************************************************************** -# * | File : epd1in54_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V1 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 1): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x22) # DISPLAY_UPDATE_CONTROL_2 - self.send_data(0xF7) - 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_command(0x20) # MASTER_ACTIVATION - - self.ReadBusy() - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - # EPD hardware init start - self.reset() - - 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) - - self.send_command(0x3C) # BorderWavefrom - self.send_data(0x01) - - 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(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() - - def Clear(self, color): - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(color) - self.TurnOnDisplay() - - def getbuffer(self, image): - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - self.TurnOnDisplay() - - def displayPartBaseImage(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.TurnOnDisplayPart() - - def displayPart(self, image): - if (image == None): - return - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, self.width // 8): - self.send_data(image[i + j * (self.width // 8)]) - - self.TurnOnDisplayPart() - - def sleep(self): - self.send_command(0x10) # DEEP_SLEEP_MODE - self.send_data(0x01) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd1in54b.py b/Raspberry Pi/python3/lib/epd1in54b.py deleted file mode 100644 index e35014c..0000000 --- a/Raspberry Pi/python3/lib/epd1in54b.py +++ /dev/null @@ -1,218 +0,0 @@ -# ***************************************************************************** -# * | File : epd1in54b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 200 -EPD_HEIGHT = 200 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcom0 = [0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A, 0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00] - lut_w = [0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04] - lut_b = [0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04] - lut_g1 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_g2 = [0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04] - lut_vcom1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red0 = [0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - lut_red1 = [0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) # module reset - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def set_lut_bw(self): - self.send_command(0x20) # vcom - for count in range(0, 15): - self.send_data(self.lut_vcom0[count]) - self.send_command(0x21) # ww -- - for count in range(0, 15): - self.send_data(self.lut_w[count]) - self.send_command(0x22) # bw r - for count in range(0, 15): - self.send_data(self.lut_b[count]) - self.send_command(0x23) # wb w - for count in range(0, 15): - self.send_data(self.lut_g1[count]) - self.send_command(0x24) # bb b - for count in range(0, 15): - self.send_data(self.lut_g2[count]) - - def set_lut_red(self): - self.send_command(0x25) - for count in range(0, 15): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x26) - for count in range(0, 15): - self.send_data(self.lut_red0[count]) - self.send_command(0x27) - for count in range(0, 15): - self.send_data(self.lut_red1[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(0x00) - self.send_data(0x08) - self.send_data(0x00) - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0x07) - self.send_data(0x07) - self.send_data(0x07) - self.send_command(0x04) # POWER_ON - - self.ReadBusy() - - self.send_command(0X00) # PANEL_SETTING - self.send_data(0xCF) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x39) - self.send_command(0x61) # TCON_RESOLUTION set x and y - self.send_data(0xC8) - self.send_data(0x00) - self.send_data(0xC8) - self.send_command(0x82) # VCM_DC_SETTING_REGISTER - self.send_data(0x0E) - - self.set_lut_bw() - self.set_lut_red() - return 0 - - def getbuffer(self, image): - buf = [0xFF] * (self.width * self.height // 8) - # Set buffer to value of Python Imaging Library image. - # Image must be in mode 1. - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display \ - ({0}x{1}).' .format(self.width, self.height)) - - pixels = image_monocolor.load() - for y in range(self.height): - for x in range(self.width): - # Set the bits for the column of pixels at the current position. - if pixels[x, y] == 0: - buf[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - return buf - - def display(self, blackimage, redimage): - # send black data - if (blackimage != None): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height // 8): - temp = 0x00 - for bit in range(0, 4): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> (bit * 2) - self.send_data(temp) - temp = 0x00 - for bit in range(4, 8): - if (blackimage[i] & (0x80 >> bit) != 0): - temp |= 0xC0 >> ((bit - 4) * 2) - self.send_data(temp) - - # send red data - if (redimage != None): - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height // 8): - self.send_data(redimage[i]) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) # DATA_START_TRANSMISSION_1 - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_data(0xFF) - - self.send_command(0x13) # DATA_START_TRANSMISSION_2 - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x12) # DISPLAY_REFRESH - self.ReadBusy() - - def sleep(self): - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x17) - self.send_command(0x82) # to solve Vcom drop - self.send_data(0x00) - self.send_command(0x01) # power setting - self.send_data(0x02) # gate switch to external - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - self.ReadBusy() - - self.send_command(0x02) # power off - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd1in54c.py b/Raspberry Pi/python3/lib/epd1in54c.py deleted file mode 100644 index 2880b1c..0000000 --- a/Raspberry Pi/python3/lib/epd1in54c.py +++ /dev/null @@ -1,152 +0,0 @@ -# ***************************************************************************** -# * | File : epd1in54c.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -import epdconfig - -# Display resolution -EPD_WIDTH = 152 -EPD_HEIGHT = 152 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(1) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(10) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost soft start - self.send_data(0x17) - self.send_data(0x17) - self.send_data(0x17) - self.send_command(0x04) # power on - - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0x0f) # LUT from OTP,160x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x61) # resolution setting - self.send_data(0x98) - self.send_data(0x00) - self.send_data(0x98) - - self.send_command(0x50) - self.send_data(0x77) - - def getbuffer(self, image): - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, yellowimage): - self.send_command(0x10) - print("blackimage") - for i in range(0, self.width * self.height // 8): - self.send_data(blackimage[i]) - self.send_command(0x13) - print("yellowimage") - for i in range(0, self.width * self.height // 8): - self.send_data(yellowimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - # after this, call epd.init() to awaken the module - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd2in13.py b/Raspberry Pi/python3/lib/epd2in13.py deleted file mode 100644 index 9424d9a..0000000 --- a/Raspberry Pi/python3/lib/epd2in13.py +++ /dev/null @@ -1,224 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in13.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_full_update = [ - 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - lut_partial_update = [ - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - 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 - - print("e-Paper busy") - self.ReadBusy() - print("e-Paper busy release") - - def init(self, lut): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - self.send_command(0x01) # DRIVER_OUTPUT_CONTROL - self.send_data((EPD_HEIGHT - 1) & 0xFF) - self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF) - self.send_data(0x00) # GD = 0 SM = 0 TB = 0 - - self.send_command(0x0C) # BOOSTER_SOFT_START_CONTROL - self.send_data(0xD7) - self.send_data(0xD6) - self.send_data(0x9D) - - self.send_command(0x2C) # WRITE_VCOM_REGISTER - self.send_data(0xA8) # VCOM 7C - - self.send_command(0x3A) # SET_DUMMY_LINE_PERIOD - self.send_data(0x1A) # 4 dummy lines per gate - - self.send_command(0x3B) # SET_GATE_TIME - self.send_data(0x08) # 2us per line - - self.send_command(0X3C) # BORDER_WAVEFORM_CONTROL - self.send_data(0x03) - - self.send_command(0X11) # DATA_ENTRY_MODE_SETTING - self.send_data(0x03) # X increment; Y increment - - # WRITE_LUT_REGISTER - self.send_command(0x32) - for count in range(30): - self.send_data(lut[count]) - - return 0 - -## - # @brief: specify the memory area for data R//W - ## - def SetWindows(self, x_start, y_start, x_end, y_end): - self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION - self.send_data((x_start >> 3) & 0xFF) - self.send_data((x_end >> 3) & 0xFF) - self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(y_start & 0xFF) - self.send_data((y_start >> 8) & 0xFF) - self.send_data(y_end & 0xFF) - self.send_data((y_end >> 8) & 0xFF) - -## - # @brief: specify the start point for data R//W - ## - def SetCursor(self, x, y): - self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER - # x point must be the multiple of 8 or the last 3 bits will be ignored - self.send_data((x >> 3) & 0xFF) - self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER - self.send_data(y & 0xFF) - self.send_data((y >> 8) & 0xFF) - self.ReadBusy() - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - # x = imwidth - x - buf[x // 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - # newy = imwidth - newy - 1 - buf[newx // 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.SetWindows(0, 0, self.width, self.height); - for j in range(0, self.height): - self.SetCursor(0, j); - self.send_command(0x24); - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd2in13_V2.py b/Raspberry Pi/python3/lib/epd2in13_V2.py deleted file mode 100644 index f4407ff..0000000 --- a/Raspberry Pi/python3/lib/epd2in13_V2.py +++ /dev/null @@ -1,315 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in13_V2.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -import numpy as np - -# Display resolution -EPD_WIDTH = 122 -EPD_HEIGHT = 250 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - FULL_UPDATE = 0 - PART_UPDATE = 1 - lut_full_update= [ - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x03,0x03,0x00,0x00,0x02, # TP0 A~D RP0 - 0x09,0x09,0x00,0x00,0x02, # TP1 A~D RP1 - 0x03,0x03,0x00,0x00,0x02, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - lut_partial_update = [ #20 bytes - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT0: BB: VS 0 ~7 - 0x80,0x00,0x00,0x00,0x00,0x00,0x00, #LUT1: BW: VS 0 ~7 - 0x40,0x00,0x00,0x00,0x00,0x00,0x00, #LUT2: WB: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, #LUT4: VCOM: VS 0 ~7 - - 0x0A,0x00,0x00,0x00,0x00, # TP0 A~D RP0 - 0x00,0x00,0x00,0x00,0x00, # TP1 A~D RP1 - 0x00,0x00,0x00,0x00,0x00, # TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, # TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, # TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, # TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, # TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy - epdconfig.delay_ms(100) - - def TurnOnDisplay(self): - self.send_command(0x22) - self.send_data(0xC7) - self.send_command(0x20) - self.ReadBusy() - - def TurnOnDisplayPart(self): - self.send_command(0x22) - self.send_data(0x0c) - self.send_command(0x20) - self.ReadBusy() - - def init(self, update): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - if(update == self.FULL_UPDATE): - self.ReadBusy() - self.send_command(0x12) # soft reset - self.ReadBusy() - - self.send_command(0x74) #set analog block control - self.send_data(0x54) - self.send_command(0x7E) #set digital block control - self.send_data(0x3B) - - self.send_command(0x01) #Driver output control - self.send_data(0xF9) - self.send_data(0x00) - self.send_data(0x00) - - 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(0x0F) #0x0C-->(15+1)*8=128 - - self.send_command(0x45) #set Ram-Y address start//end position - self.send_data(0xF9) #0xF9-->(249+1)=250 - self.send_data(0x00) - self.send_data(0x00) - self.send_data(0x00) - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x03) - - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x55) # - - self.send_command(0x03) - self.send_data(self.lut_full_update[70]) - - self.send_command(0x04) # - self.send_data(self.lut_full_update[71]) - self.send_data(self.lut_full_update[72]) - self.send_data(self.lut_full_update[73]) - - self.send_command(0x3A) #Dummy Line - self.send_data(self.lut_full_update[74]) - self.send_command(0x3B) #Gate time - self.send_data(self.lut_full_update[75]) - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_full_update[count]) - - 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 0X127 - self.send_data(0xF9) - self.send_data(0x00) - self.ReadBusy() - else: - self.send_command(0x2C) #VCOM Voltage - self.send_data(0x26) - - self.ReadBusy() - - self.send_command(0x32) - for count in range(70): - self.send_data(self.lut_partial_update[count]) - - self.send_command(0x37) - 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_command(0x22) - self.send_data(0xC0) - self.send_command(0x20) - self.ReadBusy() - - self.send_command(0x3C) #BorderWavefrom - self.send_data(0x01) - return 0 - - def getbuffer(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - buf = [0xFF] * (linewidth * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - - if(imwidth == self.width and imheight == self.height): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - if pixels[x, y] == 0: - x = imwidth - x - buf[x // 8 + y * linewidth] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - newy = imwidth - newy - 1 - buf[newx // 8 + newy*linewidth] &= ~(0x80 >> (y % 8)) - return buf - - - def display(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def displayPartial(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - # self.send_command(0x26) - # for j in range(0, self.height): - # for i in range(0, linewidth): - # self.send_data(~image[i + j * linewidth]) - self.TurnOnDisplayPart() - - def displayPartBaseImage(self, image): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - - - self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - self.TurnOnDisplay() - - def Clear(self, color): - if self.width%8 == 0: - linewidth = self.width//8 - else: - linewidth = self.width//8 + 1 - # print(linewidth) - - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(color) - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0x22) #POWER OFF - self.send_data(0xC3) - self.send_command(0x20) - - self.send_command(0x10) #enter deep sleep - self.send_data(0x01) - epdconfig.delay_ms(100) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd2in13d.py b/Raspberry Pi/python3/lib/epd2in13d.py deleted file mode 100644 index 30b4fa0..0000000 --- a/Raspberry Pi/python3/lib/epd2in13d.py +++ /dev/null @@ -1,357 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in13d.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig -from PIL import Image -import RPi.GPIO as GPIO - -# Display resolution -EPD_WIDTH = 104 -EPD_HEIGHT = 212 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_vcom1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - ] - - lut_ww1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bw1 = [ - 0x80, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_wb1 = [ - 0x40, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - lut_bb1 = [ - 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71) - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def TurnOnDisplay(self): - self.send_command(0x12) - epdconfig.delay_ms(10) - self.ReadBusy() - - 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(0x03) - self.send_data(0x00) - self.send_data(0x2b) - self.send_data(0x2b) - self.send_data(0x03) - - self.send_command(0x06) # boost soft start - self.send_data(0x17) # A - self.send_data(0x17) # B - self.send_data(0x17) # C - - self.send_command(0x04) - self.ReadBusy() - - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 - self.send_data(0x0d) # VCOM to 0V fast - - self.send_command(0x30) # PLL setting - self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - self.send_command(0x61) # resolution setting - self.send_data(self.width) - self.send_data((self.height >> 8) & 0xff) - self.send_data(self.height& 0xff) - - self.send_command(0x82) # vcom_DC setting - self.send_data(0x28) - return 0 - - def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) - - def SetPartReg(self): - self.send_command(0x82) - self.send_data(0x03) - self.send_command(0X50) - self.send_data(0x47) - - self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) - self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) - self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) - self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) - self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print "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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print "Horizontal" - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, image): - if (Image == None): - return - - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def DisplayPartial(self, image): - if (Image == None): - return - - self.SetPartReg() - self.send_command(0x91) - self.send_command(0x90) - self.send_data(0) - self.send_data(self.width - 1) - - self.send_data(0) - self.send_data(0) - self.send_data(self.height // 256) - self.send_data(self.height % 256 - 1) - self.send_data(0x28) - - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(image[i]) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(~image[i]) - epdconfig.delay_ms(10) - - self.TurnOnDisplay() - - def Clear(self, color): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0x00) - epdconfig.delay_ms(10) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - epdconfig.delay_ms(10) - - self.SetFullReg() - self.TurnOnDisplay() - - def sleep(self): - self.send_command(0X50) - self.send_data(0xf7) - self.send_command(0X02) # power off - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd2in9bc.py b/Raspberry Pi/python3/lib/epd2in9bc.py deleted file mode 100644 index fdf7817..0000000 --- a/Raspberry Pi/python3/lib/epd2in9bc.py +++ /dev/null @@ -1,154 +0,0 @@ -# ***************************************************************************** -# * | File : epd2in9bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 128 -EPD_HEIGHT = 296 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(200) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - # EPD hardware init start - self.reset() - - self.send_command(0x06) # boost - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) - self.send_command(0x04) # POWER_ON - self.ReadBusy() - self.send_command(0X00) # PANEL_SETTING - self.send_data(0x8F) - self.send_command(0X50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - self.send_command(0x61) # TCON_RESOLUTION - self.send_data (0x80) - self.send_data (0x01) - self.send_data (0x28) - # self.send_command(VCM_DC_SETTING_REGISTER) - # self.send_data (0x0A) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Horizontal") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, blackimage, ryimage): # ryimage: red or yellow image - if (blackimage != None): - self.send_command(0X10) - for i in range(0, self.width * self.height // 8): - self.send_data(blackimage[i]) - if (ryimage != None): - self.send_command(0X13) - for i in range(0, self.width * self.height // 8): - self.send_data(ryimage[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0X10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xff) - self.send_command(0X13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xff) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0X02) # power off - self.ReadBusy() - self.send_command(0X07) # deep sleep - self.send_data(0xA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd4in2bc.py b/Raspberry Pi/python3/lib/epd4in2bc.py deleted file mode 100644 index 637be5c..0000000 --- a/Raspberry Pi/python3/lib/epd4in2bc.py +++ /dev/null @@ -1,147 +0,0 @@ -# ***************************************************************************** -# * | File : epd4in2bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import epdconfig - -# Display resolution -EPD_WIDTH = 400 -EPD_HEIGHT = 300 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data (0x17) - self.send_data (0x17) - self.send_data (0x17) # 07 0f 17 1f 27 2F 37 2f - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0x0F) # LUT from OTP - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(imageblack[i]) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(imagered[i]) - - self.send_command(0x12) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x13) - for i in range(0, self.width * self.height // 8): - self.send_data(0xFF) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd5in83.py b/Raspberry Pi/python3/lib/epd5in83.py deleted file mode 100644 index e108d73..0000000 --- a/Raspberry Pi/python3/lib/epd5in83.py +++ /dev/null @@ -1,199 +0,0 @@ -# ***************************************************************************** -# * | File : epd5in83.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xC0) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height // 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) // 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) // 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) // 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) // 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() - -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd5in83bc.py b/Raspberry Pi/python3/lib/epd5in83bc.py deleted file mode 100644 index c9457d5..0000000 --- a/Raspberry Pi/python3/lib/epd5in83bc.py +++ /dev/null @@ -1,199 +0,0 @@ -# ***************************************************************************** -# * | File : epd5in83b.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 600 -EPD_HEIGHT = 448 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - self.send_command(0X82) # VCOM VOLTAGE SETTING - self.send_data(0x28) # all temperature range - - self.send_command(0x06) # boost - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0X60) # TCON SETTING - self.send_data(0x22) - - self.send_command(0X65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # tres - self.send_data(0x02) # source 600 - self.send_data(0x58) - self.send_data(0x01) # gate 448 - self.send_data(0xc0) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0xA5) # check code - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd7in5.py b/Raspberry Pi/python3/lib/epd7in5.py deleted file mode 100644 index a03e62a..0000000 --- a/Raspberry Pi/python3/lib/epd7in5.py +++ /dev/null @@ -1,200 +0,0 @@ -# ***************************************************************************** -# * | File : epd7in5.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - 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(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x28) - - self.send_command(0x04) # POWER_ON - self.ReadBusy() - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3c) - - self.send_command(0x41) # TEMPERATURE_CALIBRATION - self.send_data(0x00) - - self.send_command(0x50) # VCOM_AND_DATA_INTERVAL_SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(EPD_WIDTH >> 8) #source 640 - self.send_data(EPD_WIDTH & 0xff) - self.send_data(EPD_HEIGHT >> 8) #gate 384 - self.send_data(EPD_HEIGHT & 0xff) - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x1E) # decide by LUT file - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - # EPD hardware init end - return 0 - - def getbuffer(self, image): - buf = [0x00] * (self.width * self.height // 4) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - print("imwidth = ", imwidth, "imheight = ", imheight) - 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. - if pixels[x, y] < 64: # black - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(x + y * self.width) // 4] &= ~(0xC0 >> (x % 4 * 2)) - buf[(x + y * self.width) // 4] |= 0x40 >> (x % 4 * 2) - else: # white - buf[(x + y * self.width) // 4] |= 0xC0 >> (x % 4 * 2) - 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 - if pixels[x, y] < 64: # black - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - elif pixels[x, y] < 192: # convert gray to red - buf[(newx + newy*self.width) // 4] &= ~(0xC0 >> (y % 4 * 2)) - buf[(newx + newy*self.width) // 4] |= 0x40 >> (y % 4 * 2) - else: # white - buf[(newx + newy*self.width) // 4] |= 0xC0 >> (y % 4 * 2) - return buf - - def display(self, image): - self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): - temp1 = image[i] - j = 0 - while (j < 4): - if ((temp1 & 0xC0) == 0xC0): - temp2 = 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 = 0x00 - else: - temp2 = 0x04 - temp2 = (temp2 << 4) & 0xFF - temp1 = (temp1 << 2) & 0xFF - j += 1 - if((temp1 & 0xC0) == 0xC0): - temp2 |= 0x03 - elif ((temp1 & 0xC0) == 0x00): - temp2 |= 0x00 - else: - temp2 |= 0x04 - temp1 = (temp1 << 2) & 0xFF - self.send_data(temp2) - j += 1 - - self.send_command(0x12) - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width // 4 * self.height): - for j in range(0, 4): - self.send_data(0x33) - - self.send_command(0x12) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epd7in5bc.py b/Raspberry Pi/python3/lib/epd7in5bc.py deleted file mode 100644 index bd7d047..0000000 --- a/Raspberry Pi/python3/lib/epd7in5bc.py +++ /dev/null @@ -1,200 +0,0 @@ -# ***************************************************************************** -# * | File : epd7in5bc.py -# * | Author : Waveshare team -# * | Function : Electronic paper driver -# * | Info : -# *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 -# # | Info : python3 demo -# ----------------------------------------------------------------------------- -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and//or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -import epdconfig - -# Display resolution -EPD_WIDTH = 640 -EPD_HEIGHT = 384 - -class EPD: - def __init__(self): - self.reset_pin = epdconfig.RST_PIN - self.dc_pin = epdconfig.DC_PIN - self.busy_pin = epdconfig.BUSY_PIN - self.cs_pin = epdconfig.CS_PIN - self.width = EPD_WIDTH - self.height = EPD_HEIGHT - - # Hardware reset - def reset(self): - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(10) - epdconfig.digital_write(self.reset_pin, 1) - epdconfig.delay_ms(200) - - def send_command(self, command): - epdconfig.digital_write(self.dc_pin, 0) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([command]) - epdconfig.digital_write(self.cs_pin, 1) - - def send_data(self, data): - epdconfig.digital_write(self.dc_pin, 1) - epdconfig.digital_write(self.cs_pin, 0) - epdconfig.spi_writebyte([data]) - epdconfig.digital_write(self.cs_pin, 1) - - def ReadBusy(self): - print("e-Paper busy") - while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - epdconfig.delay_ms(100) - print("e-Paper busy release") - - def init(self): - if (epdconfig.module_init() != 0): - return -1 - - self.reset() - - self.send_command(0x01) # POWER_SETTING - self.send_data(0x37) - self.send_data(0x00) - - self.send_command(0x00) # PANEL_SETTING - self.send_data(0xCF) - self.send_data(0x08) - - self.send_command(0x30) # PLL_CONTROL - self.send_data(0x3A) # PLL: 0-15:0x3C, 15+:0x3A - - self.send_command(0x82) # VCM_DC_SETTING - self.send_data(0x28) #all temperature range - - self.send_command(0x06) # BOOSTER_SOFT_START - self.send_data(0xc7) - self.send_data(0xcc) - self.send_data(0x15) - - self.send_command(0x50) # VCOM AND DATA INTERVAL SETTING - self.send_data(0x77) - - self.send_command(0x60) # TCON_SETTING - self.send_data(0x22) - - self.send_command(0x65) # FLASH CONTROL - self.send_data(0x00) - - self.send_command(0x61) # TCON_RESOLUTION - self.send_data(self.width >> 8) # source 640 - self.send_data(self.width & 0xff) - self.send_data(self.height >> 8) # gate 384 - self.send_data(self.height & 0xff) - - self.send_command(0xe5) # FLASH MODE - self.send_data(0x03) - - return 0 - - def getbuffer(self, image): - # print "bufsiz = ",(self.width//8) * self.height - buf = [0xFF] * ((self.width//8) * self.height) - image_monocolor = image.convert('1') - imwidth, imheight = image_monocolor.size - pixels = image_monocolor.load() - # print "imwidth = %d, imheight = %d",imwidth,imheight - if(imwidth == self.width and imheight == self.height): - print("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[(x + y * self.width) // 8] &= ~(0x80 >> (x % 8)) - elif(imwidth == self.height and imheight == self.width): - print("Vertical") - for y in range(imheight): - for x in range(imwidth): - newx = y - newy = self.height - x - 1 - if pixels[x, y] == 0: - buf[(newx + newy*self.width) // 8] &= ~(0x80 >> (y % 8)) - return buf - - def display(self, imageblack, imagered): - self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): - temp1 = imageblack[i] - temp2 = imagered[i] - j = 0 - while (j < 8): - if ((temp2 & 0x80) == 0x00): - temp3 = 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 = 0x00 #black - else: - temp3 = 0x03 #white - - temp3 = (temp3 << 4) & 0xFF - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - j += 1 - if((temp2 & 0x80) == 0x00): - temp3 |= 0x04 #red - elif ((temp1 & 0x80) == 0x00): - temp3 |= 0x00 #black - else: - temp3 |= 0x03 #white - temp1 = (temp1 << 1) & 0xFF - temp2 = (temp2 << 1) & 0xFF - self.send_data(temp3) - j += 1 - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def Clear(self): - self.send_command(0x10) - for i in range(0, self.width // 8 * self.height): - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - self.send_data(0x33) - - self.send_command(0x04) # POWER ON - self.ReadBusy() - self.send_command(0x12) # display refresh - epdconfig.delay_ms(100) - self.ReadBusy() - - def sleep(self): - self.send_command(0x02) # POWER_OFF - self.ReadBusy() - - self.send_command(0x07) # DEEP_SLEEP - self.send_data(0XA5) - - epdconfig.module_exit() -### END OF FILE ### - diff --git a/Raspberry Pi/python3/lib/epdconfig.py b/Raspberry Pi/python3/lib/epdconfig.py deleted file mode 100644 index 148f934..0000000 --- a/Raspberry Pi/python3/lib/epdconfig.py +++ /dev/null @@ -1,75 +0,0 @@ -# /***************************************************************************** -# * | File : epdconfig.py -# * | Author : Waveshare team -# * | Function : Hardware underlying interface -# * | Info : -# *---------------- -# * | This version: V1.0 -# * | Date : 2019-06-21 -# * | Info : -# ****************************************************************************** -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import spidev -import RPi.GPIO as GPIO -import time - -# Pin definition -RST_PIN = 17 -DC_PIN = 25 -CS_PIN = 8 -BUSY_PIN = 24 - -# SPI device, bus = 0, device = 0 -SPI = spidev.SpiDev(0, 0) - -def digital_write(pin, value): - GPIO.output(pin, value) - -def digital_read(pin): - return GPIO.input(BUSY_PIN) - -def delay_ms(delaytime): - time.sleep(delaytime / 1000.0) - -def spi_writebyte(data): - SPI.writebytes(data) - -def module_init(): - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - GPIO.setup(RST_PIN, GPIO.OUT) - GPIO.setup(DC_PIN, GPIO.OUT) - GPIO.setup(CS_PIN, GPIO.OUT) - GPIO.setup(BUSY_PIN, GPIO.IN) - SPI.max_speed_hz = 2000000 - SPI.mode = 0b00 - return 0 - -def module_exit(): - print("spi end") - SPI.close() - - print("close 5V, Module enters 0 power consumption ...") - GPIO.output(RST_PIN, 0) - GPIO.output(DC_PIN, 0) - - GPIO.cleanup() -### END OF FILE ### diff --git a/Raspberry Pi/python3/pic/100x100.bmp b/Raspberry Pi/python3/pic/100x100.bmp deleted file mode 100644 index 70f4584..0000000 Binary files a/Raspberry Pi/python3/pic/100x100.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/1in54.bmp b/Raspberry Pi/python3/pic/1in54.bmp deleted file mode 100644 index a877bfa..0000000 Binary files a/Raspberry Pi/python3/pic/1in54.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/1in54b-b.bmp b/Raspberry Pi/python3/pic/1in54b-b.bmp deleted file mode 100644 index e992aea..0000000 Binary files a/Raspberry Pi/python3/pic/1in54b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/1in54b-r.bmp b/Raspberry Pi/python3/pic/1in54b-r.bmp deleted file mode 100644 index 68c339b..0000000 Binary files a/Raspberry Pi/python3/pic/1in54b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/1in54c-b.bmp b/Raspberry Pi/python3/pic/1in54c-b.bmp deleted file mode 100644 index 159795e..0000000 Binary files a/Raspberry Pi/python3/pic/1in54c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/1in54c-y.bmp b/Raspberry Pi/python3/pic/1in54c-y.bmp deleted file mode 100644 index fe37382..0000000 Binary files a/Raspberry Pi/python3/pic/1in54c-y.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in13-v2.bmp b/Raspberry Pi/python3/pic/2in13-v2.bmp deleted file mode 100644 index 5156852..0000000 Binary files a/Raspberry Pi/python3/pic/2in13-v2.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in13.bmp b/Raspberry Pi/python3/pic/2in13.bmp deleted file mode 100644 index a579e2a..0000000 Binary files a/Raspberry Pi/python3/pic/2in13.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in13bc-b.bmp b/Raspberry Pi/python3/pic/2in13bc-b.bmp deleted file mode 100644 index 6b70b26..0000000 Binary files a/Raspberry Pi/python3/pic/2in13bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in13bc-ry.bmp b/Raspberry Pi/python3/pic/2in13bc-ry.bmp deleted file mode 100644 index ec5cf02..0000000 Binary files a/Raspberry Pi/python3/pic/2in13bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in13d.bmp b/Raspberry Pi/python3/pic/2in13d.bmp deleted file mode 100644 index 6f0a83d..0000000 Binary files a/Raspberry Pi/python3/pic/2in13d.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in7.bmp b/Raspberry Pi/python3/pic/2in7.bmp deleted file mode 100644 index 48138bb..0000000 Binary files a/Raspberry Pi/python3/pic/2in7.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in7b-b.bmp b/Raspberry Pi/python3/pic/2in7b-b.bmp deleted file mode 100644 index d25dec3..0000000 Binary files a/Raspberry Pi/python3/pic/2in7b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in7b-r.bmp b/Raspberry Pi/python3/pic/2in7b-r.bmp deleted file mode 100644 index 66d51b1..0000000 Binary files a/Raspberry Pi/python3/pic/2in7b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in9.bmp b/Raspberry Pi/python3/pic/2in9.bmp deleted file mode 100644 index c3e0181..0000000 Binary files a/Raspberry Pi/python3/pic/2in9.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in9bc-b.bmp b/Raspberry Pi/python3/pic/2in9bc-b.bmp deleted file mode 100644 index d45ff48..0000000 Binary files a/Raspberry Pi/python3/pic/2in9bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in9bc-ry.bmp b/Raspberry Pi/python3/pic/2in9bc-ry.bmp deleted file mode 100644 index 402727c..0000000 Binary files a/Raspberry Pi/python3/pic/2in9bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/2in9d.bmp b/Raspberry Pi/python3/pic/2in9d.bmp deleted file mode 100644 index 61e0fd3..0000000 Binary files a/Raspberry Pi/python3/pic/2in9d.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/4in2.bmp b/Raspberry Pi/python3/pic/4in2.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Raspberry Pi/python3/pic/4in2.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/4in2b-b.bmp b/Raspberry Pi/python3/pic/4in2b-b.bmp deleted file mode 100644 index 7c537a4..0000000 Binary files a/Raspberry Pi/python3/pic/4in2b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/4in2b-r.bmp b/Raspberry Pi/python3/pic/4in2b-r.bmp deleted file mode 100644 index 3de854c..0000000 Binary files a/Raspberry Pi/python3/pic/4in2b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/4in2c-b.bmp b/Raspberry Pi/python3/pic/4in2c-b.bmp deleted file mode 100644 index b380a1c..0000000 Binary files a/Raspberry Pi/python3/pic/4in2c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/4in2c-y.bmp b/Raspberry Pi/python3/pic/4in2c-y.bmp deleted file mode 100644 index cd5c0d6..0000000 Binary files a/Raspberry Pi/python3/pic/4in2c-y.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/5in83.bmp b/Raspberry Pi/python3/pic/5in83.bmp deleted file mode 100644 index 6b8f604..0000000 Binary files a/Raspberry Pi/python3/pic/5in83.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/5in83bc-b.bmp b/Raspberry Pi/python3/pic/5in83bc-b.bmp deleted file mode 100644 index 545e060..0000000 Binary files a/Raspberry Pi/python3/pic/5in83bc-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/5in83bc-ry.bmp b/Raspberry Pi/python3/pic/5in83bc-ry.bmp deleted file mode 100644 index 41884b3..0000000 Binary files a/Raspberry Pi/python3/pic/5in83bc-ry.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/7in5.bmp b/Raspberry Pi/python3/pic/7in5.bmp deleted file mode 100644 index b997800..0000000 Binary files a/Raspberry Pi/python3/pic/7in5.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/7in5b-b.bmp b/Raspberry Pi/python3/pic/7in5b-b.bmp deleted file mode 100644 index 8f84025..0000000 Binary files a/Raspberry Pi/python3/pic/7in5b-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/7in5b-r.bmp b/Raspberry Pi/python3/pic/7in5b-r.bmp deleted file mode 100644 index 3f81b2c..0000000 Binary files a/Raspberry Pi/python3/pic/7in5b-r.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/7in5c-b.bmp b/Raspberry Pi/python3/pic/7in5c-b.bmp deleted file mode 100644 index a69ddbc..0000000 Binary files a/Raspberry Pi/python3/pic/7in5c-b.bmp and /dev/null differ diff --git a/Raspberry Pi/python3/pic/7in5c-r.bmp b/Raspberry Pi/python3/pic/7in5c-r.bmp deleted file mode 100644 index be84903..0000000 Binary files a/Raspberry Pi/python3/pic/7in5c-r.bmp and /dev/null differ