eink-parade/image2eink.py

44 lines
1.1 KiB
Python
Raw Normal View History

2022-10-15 11:18:09 +03:00
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import os
picdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic')
libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')
if os.path.exists(libdir):
sys.path.append(libdir)
import logging
from waveshare_epd import epd5in65f
import time
from PIL import Image,ImageDraw,ImageFont
import traceback
logging.basicConfig(level=logging.DEBUG)
try:
logging.info("epd5in65f Demo")
epd = epd5in65f.EPD()
logging.info("Init")
epd.init()
#epd.Clear()
while True:
for root, directories, files in os.walk(picdir):
for f in files:
if(f.endswith("converted.bmp")) :
logging.info("Read bmp file "+f)
Himage = Image.open(os.path.join(picdir, f))
epd.display(epd.getbuffer(Himage))
time.sleep(30)
#epd.Clear()
logging.info("Goto Sleep...")
epd.sleep()
except IOError as e:
logging.info(e)
except KeyboardInterrupt:
logging.info("ctrl + c:")
epd5in65f.epdconfig.module_exit()
exit()