49 lines
1.2 KiB
Python
49 lines
1.2 KiB
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()
|
|
# font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)
|
|
Himage = Image.new('RGB', (epd.width, epd.height), epd.WHITE) # 255: clear the frame
|
|
draw = ImageDraw.Draw(Himage)
|
|
# draw.text((5, 0), 'hello world', font = font18, fill = epd.RED)
|
|
|
|
logger.info('zeichne blaue Linie')
|
|
draw.line((0,0, 80, 245), fill = epd.BLUE)
|
|
epd.display(epd.getbuffer(Himage))
|
|
|
|
logger.info('zeichne gefülltes Rechteck')
|
|
draw.rectangle((90, 170, 165, 245), fill = epd.RED)
|
|
epd.display(epd.getbuffer(Himage))
|
|
|
|
time.sleep(5)
|
|
logger.info('cleanup')
|
|
epd4in0e.epdconfig.module_exit(cleanup=True)
|
|
exit()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|