Added first e-paper support

This commit is contained in:
Justus Kuhlmann 2021-10-24 21:36:08 +02:00
commit 80c7291408

View file

@ -6,9 +6,11 @@ import numpy as np
import requests import requests
import sys, os import sys, os
sys.path.insert(0, './caldav') sys.path.insert(0, './caldav')
sys.path.insert(0, './e-Paper/RaspberryPi_JetsonNano/python/lib')
import caldav import caldav
from caldav.lib.error import AuthorizationError from caldav.lib.error import AuthorizationError
caldav_url = '' caldav_url = ''
username = '' username = ''
password = '' password = ''
@ -52,6 +54,10 @@ if (os.path.isfile("./config")):
if l[10:] == "2color": if l[10:] == "2color":
has_color = True has_color = True
on_e_paper = False
if(on_e_paper):
from waveshare_epd import epd7in5b_V2
#print(selected_cals) #print(selected_cals)
#look if server and user are set #look if server and user are set
if(len(caldav_url) == 0): if(len(caldav_url) == 0):
@ -211,6 +217,12 @@ eventfont = ImageFont.truetype("./resource/bf_mnemonika_regular.ttf", 16)
weekdayfont = ImageFont.truetype("./resource/bf_mnemonika_regular.ttf", 16) weekdayfont = ImageFont.truetype("./resource/bf_mnemonika_regular.ttf", 16)
timefont = ImageFont.truetype("./resource/bf_mnemonika_regular.ttf", 12) timefont = ImageFont.truetype("./resource/bf_mnemonika_regular.ttf", 12)
birthdayfont = weekdayfont birthdayfont = weekdayfont
if(on_e_paper):
#initialise epd for the e-ink display
epd = epd7in5b_V2.EPD()
epd.init()
epd.Clear()
#create image buffer #create image buffer
Himage = Image.new('1', (800,480), 255) # 255: clear the frame Himage = Image.new('1', (800,480), 255) # 255: clear the frame
draw = ImageDraw.Draw(Himage) draw = ImageDraw.Draw(Himage)
@ -415,3 +427,6 @@ if(not client_established):
Himage.paste(Image.open("./resource/unauthorized.png"), (right_border_grid-40,lower_border_grid-40)) Himage.paste(Image.open("./resource/unauthorized.png"), (right_border_grid-40,lower_border_grid-40))
Himage.save("./canvas.bmp") Himage.save("./canvas.bmp")
HRimage.save("./r_canvas.bmp") HRimage.save("./r_canvas.bmp")
if(on_e_paper):
epd.display(epd.getbuffer(Himage), epd.getbuffer(HRimage))