cli.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. def main():
  2. import logging
  3. from waveshare_epd import epd2in13_V2
  4. import time
  5. from PIL import Image,ImageDraw
  6. import os
  7. fontpath = os.path.realpath(os.path.join(__file__,"..","..","wavesharelib","pic", 'Font.ttc'))
  8. import simpilib
  9. text = simpilib.getQuote()
  10. epd = epd2in13_V2.EPD()
  11. logging.info("init and Clear")
  12. epd.init(epd.FULL_UPDATE)
  13. epd.Clear(0xFF)
  14. image = Image.new('1', (epd.height, epd.width), 255)
  15. draw = ImageDraw.Draw(image)
  16. text, longline = simpilib.wrapText(text)
  17. font = simpilib.loadFontSize(text, draw, image, fontpath)
  18. w, h = draw.textsize(text, font=font)
  19. center = (
  20. int((epd.height-w)/2),
  21. int((epd.width-h)/2)
  22. )
  23. print("Drawing:", (w, h), (epd.height, epd.width))
  24. draw.text(center, text, align="center", font = font, fill = 0)
  25. # epd.display(epd.getbuffer(image.rotate(180)))
  26. epd.display(epd.getbuffer(image))
  27. epd.sleep()
  28. epd.Dev_exit()
  29. def parser():
  30. from argparse import ArgumentParser
  31. p = ArgumentParser()
  32. return p