|
@@ -2,7 +2,7 @@
|
|
|
import os as _os
|
|
import os as _os
|
|
|
fontpath = _os.path.realpath(_os.path.join(__file__,"..","..","wavesharelib","pic", 'Font.ttc'))
|
|
fontpath = _os.path.realpath(_os.path.join(__file__,"..","..","wavesharelib","pic", 'Font.ttc'))
|
|
|
|
|
|
|
|
-def update_qr(args):
|
|
|
|
|
|
|
+def eink_qr(args):
|
|
|
from waveshare_epd import epd2in13_V2
|
|
from waveshare_epd import epd2in13_V2
|
|
|
from PIL import Image,ImageDraw
|
|
from PIL import Image,ImageDraw
|
|
|
import qrcode
|
|
import qrcode
|
|
@@ -18,38 +18,40 @@ def update_qr(args):
|
|
|
epd.sleep()
|
|
epd.sleep()
|
|
|
epd.Dev_exit()
|
|
epd.Dev_exit()
|
|
|
|
|
|
|
|
-def update_quote(args):
|
|
|
|
|
- import logging
|
|
|
|
|
- from waveshare_epd import epd2in13_V2
|
|
|
|
|
- from PIL import Image,ImageDraw
|
|
|
|
|
- import simpilib
|
|
|
|
|
|
|
+def eink_quote_qr(args):
|
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
|
+def eink_quote(args):
|
|
|
|
|
+ import simpilib
|
|
|
quote = simpilib.getQuote()
|
|
quote = simpilib.getQuote()
|
|
|
if not quote:
|
|
if not quote:
|
|
|
return
|
|
return
|
|
|
- pic = simpilib.convert_qr(quote)
|
|
|
|
|
- text = quote["content"]
|
|
|
|
|
|
|
+ args.text = quote["content"] + ' - ' + quote["author"]
|
|
|
|
|
+ eink_text(args)
|
|
|
|
|
+
|
|
|
|
|
+def eink_text(args):
|
|
|
|
|
+ from waveshare_epd import epd2in13_V2
|
|
|
|
|
+ from PIL import Image,ImageDraw
|
|
|
|
|
+ import simpilib
|
|
|
|
|
|
|
|
epd = epd2in13_V2.EPD()
|
|
epd = epd2in13_V2.EPD()
|
|
|
- logging.info("init and Clear")
|
|
|
|
|
|
|
+ print("init and Clear")
|
|
|
epd.init(epd.FULL_UPDATE)
|
|
epd.init(epd.FULL_UPDATE)
|
|
|
# epd.Clear(0xFF)
|
|
# epd.Clear(0xFF)
|
|
|
image = Image.new('1', (epd.height, epd.width), 0)
|
|
image = Image.new('1', (epd.height, epd.width), 0)
|
|
|
- image.paste(pic, (int(epd.height-pic.width),0), pic)
|
|
|
|
|
draw = ImageDraw.Draw(image)
|
|
draw = ImageDraw.Draw(image)
|
|
|
|
|
|
|
|
- text, longline = simpilib.wrapText(text, line_width_factor=3)
|
|
|
|
|
|
|
+ text, longline = simpilib.wrapText(args.text, line_width_factor=5)
|
|
|
font = simpilib.loadFontSize(text, draw, image, fontpath)
|
|
font = simpilib.loadFontSize(text, draw, image, fontpath)
|
|
|
|
|
|
|
|
w, h = draw.textsize(text, font=font)
|
|
w, h = draw.textsize(text, font=font)
|
|
|
|
|
|
|
|
# epd parameters are rotated 90°
|
|
# epd parameters are rotated 90°
|
|
|
center = [
|
|
center = [
|
|
|
- int((epd.height - pic.width - w)/2),
|
|
|
|
|
- int((epd.width-h)/2),
|
|
|
|
|
|
|
+ int((epd.height - w)/2),
|
|
|
|
|
+ int((epd.width-h)/2) - 3,
|
|
|
]
|
|
]
|
|
|
- # leave some space for low characters
|
|
|
|
|
- center[1] = center[1] - 3
|
|
|
|
|
|
|
+ # -3 px to leave some space for low characters
|
|
|
|
|
|
|
|
print("Drawing:", (w, h), (epd.height, epd.width), center)
|
|
print("Drawing:", (w, h), (epd.height, epd.width), center)
|
|
|
draw.text(center, text, align="center", font = font, fill = 255)
|
|
draw.text(center, text, align="center", font = font, fill = 255)
|