54 lines
1.3 KiB
Python
Executable File
54 lines
1.3 KiB
Python
Executable File
#! /usr/bin/python
|
|
import os
|
|
import time
|
|
import logging
|
|
from logging import config
|
|
import json
|
|
import epd4in0e
|
|
|
|
from PIL import Image,ImageDraw,ImageFont
|
|
|
|
# Auflösung des ePaper
|
|
EPD_WIDTH = 400
|
|
EPD_HEIGHT = 600
|
|
|
|
#Verzeichnis für Grafikdaten
|
|
picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic')
|
|
|
|
# Logging Konfiguration laden.
|
|
with open('logging_config.json') as file_config:
|
|
config.dictConfig(json.load(file_config))
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def main():
|
|
logger.info('initalisiere Display')
|
|
|
|
epd = epd4in0e.EPD()
|
|
epd.init()
|
|
epd.Clear()
|
|
img = Image.new('RGB', (epd.width, epd.height), epd.WHITE) # 255: clear the frame
|
|
draw = ImageDraw.Draw(img)
|
|
logger.info('zeichne blaue Linie')
|
|
draw.line((0,0, 115, 255), width=3, fill = epd.BLUE)
|
|
|
|
logger.info('zeichne gefülltes Quadrat')
|
|
draw.rectangle((0,170, 75, 245), fill = epd.RED)
|
|
|
|
|
|
logger.info('zeichne gefüllten Kreis')
|
|
draw.circle((105,180),20,fill=epd.YELLOW)
|
|
# Erst, wenn alles gezeichnet ist, aktualisieren wir das Display.
|
|
epd.display(epd.getbuffer(img))
|
|
|
|
# speichern des Bilds im akzuellen Verzeichnis
|
|
img.save('spi_demo.jpg')
|
|
|
|
time.sleep(5)
|
|
logger.info('cleanup')
|
|
epd4in0e.epdconfig.module_exit(cleanup=True)
|
|
exit()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|