You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NotiFrame/EinkPaper.py

79 lines
2.3 KiB

from PIL import Image, ImageDraw, ImageFont, ImageOps
import re
import time
import widget
import argparse
try:
import epd7in5b
testMode = False
except:
testMode = True
parser = argparse.ArgumentParser(description="EinkPaper display")
parser.add_argument('-t', '--test', help='enable test mode', action='store_true')
args = parser.parse_args()
if args.test:
testMode = True
print("RUNNING IN TESTMODE: "+str(testMode))
if not testMode:
epd = epd7in5b.EPD()
epd.init()
width = 640
height = 384
cwidth = int(round(width/3))
cheight = int(round(height/3))
image_yellow = Image.new('1', (width, height), 255) # 255: clear the frame
draw_yellow = ImageDraw.Draw(image_yellow)
image_black = Image.new('1', (width, height), 255) # 255: clear the frame
draw_black = ImageDraw.Draw(image_black)
str1 = open("text.txt", "r").read()
str2 = open("text.txt", "r").read()
str3 = open("text.txt", "r").read()
strList = []
strList.append(str1)
strList.append(str2)
strList.append(str3)
def initWidgets():
widgetList = []
widgetList.append(widget.TrelloWidget(cwidth, cheight, (0, 0), (1, 3), "E-paper", "Done"))
#widgetList.append(widget.TextWidget(cwidth, cheight, (0, 0), (1, 3), str2))
#widgetList.append(widget.TextWidget(cwidth, cheight, (0, 0), (2, 3), str1))
widgetList.append(widget.ImageWidget(cwidth, cheight, (2, 0), (1, 1), "mono", "fill", "sun1.jpg"))
widgetList.append(widget.ImageWidget(cwidth, cheight, (2, 1), (1, 2), "mono", "fill", "folk.png"))
widgetList.append(widget.ImageWidget(cwidth, cheight, (1, 0), (1, 3), "mono", "fill", "staff.png"))
return widgetList
def drawWidget(w):
coordX = w.cellX*cwidth
coordY = w.cellY*cheight
image_black.paste(w.image_black, (coordX, coordY))
image_yellow.paste(w.image_yellow, (coordX, coordY))
def render(index):
for widg in widgetList:
drawWidget(widg)
if not testMode:
print("pushing to display frame")
epd.display_frame(epd.get_frame_buffer(image_black),epd.get_frame_buffer(image_yellow))
print("done")
else:
print("saving canvas images")
image_black.save("imgBlack.bmp")
image_yellow.save("imgYellow.bmp")
print("done")
widgetList = initWidgets()
i = 0
while(True):
render(i)
i = (i + 1)%3
time.sleep(10)