コード例 #1
0
def txtToDisplay(txt, fontSize, img):
    try:
        epd = epd2in9bc.EPD()
        epd.init()
        epd.Clear()

        #rectangle
        HBlackimage = Image.new('1', (epd.height, epd.width), 255)  # 298*126
        drawblack = ImageDraw.Draw(HBlackimage)
        drawblack.rectangle((100, 4, 292, 124), outline=0)
        #text
        fontCustom = ImageFont.truetype(os.path.join(picdir, 'DejaVuSans.ttf'),
                                        fontSize)
        drawblack.text((105, 9), txt, font=fontCustom, fill=0)
        #logo
        HRYimage = Image.new('1', (epd.height, epd.width),
                             255)  # 298*126  ryimage: red or yellow image
        logo = Image.open(os.path.join(picdir, img))
        HRYimage.paste(logo, (0, 0))

        epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))

        epd.sleep()
        time.sleep(3)

    except IOError as e:
        logging.info(e)

    except KeyboardInterrupt:
        logging.info("ctrl + c:")
        epd2in9bc.epdconfig.module_exit()
        exit()
コード例 #2
0
 def __init__(self):
     self.epd = epd2in9bc.EPD()
     super().__init__(
         self.epd.height,
         self.epd.width)  # Display always used horizontal (H x W)
     self.log = logging
     self.log.basicConfig(level=logging.DEBUG)
     self.is_initialized = False
コード例 #3
0
    os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')
if os.path.exists(libdir):
    sys.path.append(libdir)

import logging
from waveshare_epd import epd2in9bc
import time
from PIL import Image, ImageDraw, ImageFont
import traceback

logging.basicConfig(level=logging.DEBUG)

try:
    logging.info("epd2in9bc Demo")

    epd = epd2in9bc.EPD()
    logging.info("init and Clear")
    epd.init()
    epd.Clear()
    time.sleep(1)

    # Drawing on the image
    logging.info("Drawing")
    font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
    font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)

    # Drawing on the Horizontal image
    logging.info("1.Drawing on the Horizontal image...")
    HBlackimage = Image.new('1', (epd.height, epd.width), 255)  # 298*126
    HRYimage = Image.new('1', (epd.height, epd.width),
                         255)  # 298*126  ryimage: red or yellow image