zeichnen des gelben Kreises und abspeichern des Ergebnis.

This commit is contained in:
2025-12-12 07:15:23 +01:00
parent 2e354de75f
commit 2c4ad47734
2 changed files with 15 additions and 10 deletions

25
spi_demo.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#! /usr/bin/python
import os
import time
import logging
@@ -26,18 +27,22 @@ def main():
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)
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, 80, 245), fill = epd.BLUE)
epd.display(epd.getbuffer(Himage))
draw.line((0,0, 115, 255), width=3, fill = epd.BLUE)
logger.info('zeichne gefülltes Rechteck')
draw.rectangle((90, 170, 165, 245), fill = epd.RED)
epd.display(epd.getbuffer(Himage))
logger.info('zeichne gefülltes Qudarat')
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')