assets added

This commit is contained in:
pepev-nrt 2025-01-26 17:17:16 +01:00
parent 67b3c0e2d8
commit dc3337d22b
9 changed files with 49 additions and 23 deletions

BIN
assets/cal-icon.aseprite Normal file

Binary file not shown.

BIN
assets/cal-icon.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/output.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
assets/test2.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
assets/test3.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
assets/test4.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
assets/wavesharefont.ttc Normal file

Binary file not shown.

View file

@ -1,9 +1,9 @@
{ {
"displayTZ": "Spain/Madrid", "isDisplayConected": false,
"isDisplayConected": true,
"screenWidth": 250, "screenWidth": 250,
"screenHeight": 122, "screenHeight": 122,
"imageWidth": 250, "imageWidth": 250,
"imageHeight": 122, "imageHeight": 122,
"rotateAngle": 180 "rotateAngle": 180,
"hourFormat": "12h"
} }

View file

@ -9,6 +9,7 @@ There will also be work needed to adjust the calendar rendering for different sc
CSS stylesheets in the "render" folder. CSS stylesheets in the "render" folder.
""" """
import datetime as dt import datetime as dt
import os
import sys import sys
@ -16,43 +17,68 @@ from display.display import DisplayHelper
import json import json
import logging import logging
from PIL import Image,ImageDraw,ImageFont from PIL import Image,ImageDraw,ImageFont
import time
def main(): def main():
# Basic configuration settings (user replaceable) # Basic configuration settings (user replaceable)
configFile = open('config.json') # config.json is in the root folder
configFile = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.json'))
config = json.load(configFile) config = json.load(configFile)
displayTZ = config['displayTZ'] # list of timezones - print(pytz.all_timezones)
isDisplayConected = config['isDisplayConected'] # set to true when debugging rendering without displaying to screen isDisplayConected = config['isDisplayConected'] # set to true when debugging rendering without displaying to screen
screenWidth = config['screenWidth'] # Width of E-Ink display. Default is landscape. Need to rotate image to fit. screenWidth = config['screenWidth'] # Width of E-Ink display. Default is landscape. Need to rotate image to fit.
screenHeight = config['screenHeight'] # Height of E-Ink display. Default is landscape. Need to rotate image to fit. screenHeight = config['screenHeight'] # Height of E-Ink display. Default is landscape. Need to rotate image to fit.
imageWidth = config['imageWidth'] # Width of image to be generated for display. imageWidth = config['imageWidth'] # Width of image to be generated for display.
imageHeight = config['imageHeight'] # Height of image to be generated for display. imageHeight = config['imageHeight'] # Height of image to be generated for display.
rotateAngle = config['rotateAngle'] # If image is rendered in portrait orientation, angle to rotate to fit screen rotateAngle = config['rotateAngle'] # If image is rendered in portrait orientation, angle to rotate to fit screen
hourFormat = config['hourFormat'] # The format the hour will be displayed. eg. 13:02 or 01:02 PM
# Set the hour, this is important to see what time the e-Paper has been syncronized
if hourFormat == "12h":
time = dt.datetime.now().strftime("%I:%M %p")
else:
time = dt.datetime.now().strftime("%H:%M")
assets = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets')
# Drawing on the image
font15 = ImageFont.truetype(os.path.join(assets, 'wavesharefont.ttc'), 15)
font24 = ImageFont.truetype(os.path.join(assets, 'wavesharefont.ttc'), 24)
#image = Image.open('assets/test4.bmp')
image = Image.new('1', (imageWidth, imageHeight), 255) # 255: clear the frame
draw = ImageDraw.Draw(image)
draw.text((0, 0), time, font = font15, fill = 0) # draw the current time in the top left corner
draw.line([(0,20),(250,20)], fill = 0,width = 2)
draw.line([(125,20),(125,122)], fill = 0,width = 2)
cal_icon = Image.open(os.path.join(assets, "cal-icon.bmp"))
image.paste(cal_icon, (129,24))
draw.text((160, 26), 'Agenda', font = font15, fill = 0)
# 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.rectangle([(0,0),(50,50)],outline = 0)
image.save(os.path.join(assets, 'output.bmp'))
if isDisplayConected: if isDisplayConected:
from display.display import DisplayHelper from display.display import DisplayHelper
displayService = DisplayHelper(screenWidth, screenHeight) displayService = DisplayHelper(screenWidth, screenHeight)
displayService.update(image.rotate(rotateAngle)) # go to sleep
image = Image.open('assets/test.bmp')
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)
displayService.update(image) # go to sleep
displayService.clear() displayService.clear()
displayService.sleep() # go to sleep displayService.sleep() # go to sleep