Exemplo n.º 1
0
    def __init__(self, observable, mode):
        super().__init__(observable=observable)
        self.epd = epd2in13b_V3.EPD()

        self.epd.init()
        self.image_black = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
        self.image_ry = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
        self.draw_black = ImageDraw.Draw(self.image_black)
        self.draw_ry = ImageDraw.Draw(self.image_ry)
        self.mode = mode
Exemplo n.º 2
0
def json():
    logging.basicConfig(level=logging.DEBUG)
    epd = epd2in13b_V3.EPD()
    epd.init()
    epd.Clear()
    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
    drawblack = ImageDraw.Draw(HBlackimage)
    drawry = ImageDraw.Draw(HRYimage)

    content = request.json

    for i in content["operations"]:
        color = drawry
        image = HRYimage
        if i['color'] == 'BLACK':
            color = drawblack
            image = HBlackimage
        if i['type'] == 'TEXT':
            text(color, i)
        if i['type'] == 'LINE':
            line(color, i)
        if i['type'] == 'RECTANGLE':
            rectangle(color, i)
        if i['type'] == 'ARC':
            arc(color, i)
        if i['type'] == 'CHORD':
            chord(color, i)
        if i['type'] == 'POLYGON':
            polygon(color, i)
        if i['type'] == 'IMG':
            img(image, i)

    #newimage = Image.open(os.path.join(picdir, 'ardbeg.bmp'))
    #HBlackimage.paste(newimage, (85,30))
    if (content["flip"]):
        HBlackimage = HBlackimage.transpose(Image.ROTATE_180)
        HRYimage = HRYimage.transpose(Image.ROTATE_180)
    epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
    return 'OK'
Exemplo n.º 3
0
    def __init__(self, blank_size_x, blank_size_y, render_target='screen'):
        self.blank_size_x = blank_size_x
        self.blank_size_y = blank_size_y
        self.render_target = render_target

        if (self.render_target == 'screen'):
            if os.path.exists(libdir):
                sys.path.append(libdir)
                from waveshare_epd import epd2in13b_V3

                self.epd = epd2in13b_V3.EPD()
                logging.info("init and Clear")
                self.epd.init()
                self.epd.Clear()
                time.sleep(1)
                self.blank_size_y = self.epd.width
                self.blank_size_x = self.epd.height

        if (self.render_target == 'image'):
            self.blank_size_x = blank_size_x
            self.blank_size_y = blank_size_y

        self.createNewBlank()
Exemplo n.º 4
0
from waveshare_epd import epd2in13b_V3 as epdriver

epd = epdriver.EPD()
Exemplo n.º 5
0
libdir = os.path.join(
    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 epd2in13b_V3
import time
from PIL import Image, ImageDraw, ImageFont

logging.basicConfig(level=logging.DEBUG)

try:
    logging.info("epd2in13b_V3 Demo")

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

    # Drawing on the image
    logging.info("Drawing")
    font20 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 20)
    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
Exemplo n.º 6
0
def clear():
    epd = epd2in13b_V3.EPD()
    epd.init()
    epd.Clear()
    return ''
Exemplo n.º 7
0
        drawblack.rectangle((0, 0, self._screen.height, self._screen.width),
                            fill=0)
        drawblack.text((10, 0), "IP:", font=self._font, fill=1)
        drawblack.text((10, 30), self._ip, font=self._font, fill=1)
        if (self._switchState):
            drawblack.text((10, 60), "SSH: On", font=self._font, fill=1)
        else:
            drawblack.text((10, 60), "SSH: Off", font=self._font, fill=1)
        # Screen Displaying
        self._screen.display(self._screen.getbuffer(HBlackimage),
                             self._screen.getbuffer(HRedimage))

    def update(self):
        if (not (GPIO.input(self._switchPin)) != self._switchState):
            self._switchState = not (GPIO.input(self._switchPin))
            if (self._switchState):
                enableSSH()
            else:
                disableSSH()
            self.updateScreen()
        if (self._ip != getIP()):
            self._ip = getIP()
            self.updateScreen()


supervisor = Supervisor(epd2in13b_V3.EPD(), getenv('SSH_SWITCH_PIN'),
                        path.join(path.dirname(__file__), getenv('FONT_PATH')))

# LOOP
while True:
    supervisor.update()