|
@@ -2,47 +2,23 @@
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
def main():
|
|
def main():
|
|
|
- import logging
|
|
|
|
|
- from waveshare_epd import epd2in13_V2
|
|
|
|
|
- import time
|
|
|
|
|
- from PIL import Image,ImageDraw
|
|
|
|
|
- import simpilib
|
|
|
|
|
|
|
+ p = parser()
|
|
|
|
|
+ args = p.parse_args()
|
|
|
|
|
+ if "func" in args:
|
|
|
|
|
+ return args.func(args)
|
|
|
|
|
|
|
|
- import os
|
|
|
|
|
- fontpath = os.path.realpath(os.path.join(__file__,"..","..","wavesharelib","pic", 'Font.ttc'))
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- text = simpilib.getQuote()
|
|
|
|
|
-
|
|
|
|
|
- epd = epd2in13_V2.EPD()
|
|
|
|
|
- logging.info("init and Clear")
|
|
|
|
|
- epd.init(epd.FULL_UPDATE)
|
|
|
|
|
- epd.Clear(0xFF)
|
|
|
|
|
- image = Image.new('1', (epd.height, epd.width), 255)
|
|
|
|
|
- draw = ImageDraw.Draw(image)
|
|
|
|
|
-
|
|
|
|
|
- text, longline = simpilib.wrapText(text)
|
|
|
|
|
- font = simpilib.loadFontSize(text, draw, image, fontpath)
|
|
|
|
|
-
|
|
|
|
|
- w, h = draw.textsize(text, font=font)
|
|
|
|
|
-
|
|
|
|
|
- # epd parameters are rotated 90°
|
|
|
|
|
- center = [
|
|
|
|
|
- int((epd.height-w)/2),
|
|
|
|
|
- int((epd.width-h)/2)
|
|
|
|
|
- ]
|
|
|
|
|
- # leave some space for low characters
|
|
|
|
|
- center[1] = center[1] - 5
|
|
|
|
|
-
|
|
|
|
|
- print("Drawing:", (w, h), (epd.height, epd.width))
|
|
|
|
|
- draw.text(center, text, align="center", font = font, fill = 0)
|
|
|
|
|
-
|
|
|
|
|
- # epd.display(epd.getbuffer(image.rotate(180)))
|
|
|
|
|
- epd.display(epd.getbuffer(image))
|
|
|
|
|
- epd.sleep()
|
|
|
|
|
- epd.Dev_exit()
|
|
|
|
|
|
|
+ from simpilib.eink import update_quote
|
|
|
|
|
+ return update_quote(args)
|
|
|
|
|
|
|
|
def parser():
|
|
def parser():
|
|
|
from argparse import ArgumentParser
|
|
from argparse import ArgumentParser
|
|
|
|
|
+ from simpilib.install import install
|
|
|
|
|
+ from simpilib.eink import update_quote
|
|
|
p = ArgumentParser()
|
|
p = ArgumentParser()
|
|
|
|
|
+ sub = p.add_subparsers()
|
|
|
|
|
+ install_parser = sub.add_parser("update_quote")
|
|
|
|
|
+ install_parser.set_defaults(func=update_quote)
|
|
|
|
|
+ install_parser = sub.add_parser("install")
|
|
|
|
|
+ install_parser.set_defaults(func=install)
|
|
|
return p
|
|
return p
|
|
|
|
|
+
|