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

80 lines
2.5 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.ImageWidget(cwidth, cheight, (0, 0), (3, 3), "mono", "fill", "forest.jpg"))
widgetList.append(widget.TrelloWidget(cwidth, cheight, (0, 0), (1, 3), "Organisation", "Plans"))
widgetList.append(widget.TrelloWidget(cwidth, cheight, (1, 0), (2, 3), "E-paper", "Done"))
#widgetList.append(widget.ImageWidget(cwidth, cheight, (1, 2), (2, 1), "mono", "fill", "forest.jpg"))
#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, (1, 0), (1, 3), "mono", "fill", "g.jpg"))
return widgetList
def drawWidget(w):
coordX = w.cellX*cwidth
coordY = w.cellY*cheight
image_black.paste(im=w.image_black, mask=w.mask_black, box=(coordX, coordY))
image_yellow.paste(w.image_yellow, (coordX, coordY))
def render(index):
if index is not 0:
for widg in widgetList:
widg.updateWidget()
draw_black.rectangle(xy=((0,0), image_black.size), fill=255)
draw_yellow.rectangle(xy=((0,0), image_yellow.size), fill=255)
for widg in widgetList:
drawWidget(widg)
if not testMode:
epd.display_frame(epd.get_frame_buffer(image_black),epd.get_frame_buffer(image_yellow))
else:
image_black.save("imgBlack.bmp")
image_yellow.save("imgYellow.bmp")
widgetList = initWidgets()
i = 0
while(True):
print("RENDERING "+str(i))
render(i)
i = (i + 1)
#time.sleep(10)