Example #1
0
    def __init__(self, modules):
        assert len(modules) > 0

        self.epd = epd2in13.EPD()

        self.modules = cycle(
            map(lambda m: (m[0], m[1]((self.epd.height, self.epd.width))),
                modules))

        self.state = self.STATE_INIT_FULL_UPDATE

        self.last_switch = datetime.min
        self.active_module = None
Example #2
0
def draw_aqi(inside, outside):
    epd = epd2in13.EPD()
    epd.init(epd.FULL_UPDATE)

    image = Image.new('1', (epd2in13.EPD_HEIGHT, epd2in13.EPD_WIDTH), WHITE)
    draw = ImageDraw.Draw(image)
    draw_data(draw, inside, 'INSIDE [%]', 0, 1.2)

    draw_data(draw, outside, 'OUTSIDE [%]', 120, 1.2)
    draw_footer(draw)
    # draw.line([(0, 180), (epd2in13.EPD_WIDTH, 180)], fill=BLACK, width=1)

    epd.displayPartial(epd.getbuffer(image))
def draw_aqi(inside, outside, luczyce):
    epd = epd2in13.EPD()
    epd.init(epd.FULL_UPDATE)

    image = Image.new('1', (epd2in13.EPD_WIDTH, epd2in13.EPD_HEIGHT), WHITE)
    draw = ImageDraw.Draw(image)
    draw_data(draw, inside, 'INSIDE', 0)
    draw.line([(0, 90), (epd2in13.EPD_WIDTH, 90)], fill=BLACK, width=1)
    draw_data(draw, outside, 'OUTSIDE', 95)
    draw_footer(draw)
    draw.line([(0, 180), (epd2in13.EPD_WIDTH, 180)], fill=BLACK, width=1)

    draw_in_line(draw, 'Ɓuczyce: {}% '.format(luczyce), 185, 14)

    epd.displayPartial(epd.getbuffer(image))
Example #4
0
def main():
    counterChecks = 0
    counter = 0
    try:
        logging.info("Skimbuster v1.0 Demo")
        epd = epd_driver.EPD()
        logging.info("init and Clear")

        #epd.init()
        epd.init(epd.lut_full_update)
        epd.Clear(0xFF)

        time.sleep(1)
        font16 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 16)
        font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)
        HBlackimage = Image.new('1', (epd.EPD_HEIGHT, epd.EPD_WIDTH),
                                255)  # 298*126
        #HRYimage = Image.new('1', (epd.EPD_HEIGHT, epd.EPD_WIDTH), 255)  # 298*126  ryimage: red or yellow image
        drawblack = ImageDraw.Draw(HBlackimage)
        #drawry = ImageDraw.Draw(HRYimage)
        #drawry.text((2, 0), 'Skimbuster', font = font18, fill = 0)
        drawblack.text((2, 0), 'Skimbuster', font=font18, fill=0)
        drawblack.text((175, 1), 'v1.0', font=font18, fill=0)
        drawblack.text((35, 85), 'stutm @ SensePost', font=font16, fill=0)
        drawblack.line((0, 20, 298, 20), fill=0)
        drawblack.line((0, 85, 298, 85), fill=0)
        #nearby_devices = bluetooth.discover_devices(lookup_names = True, lookup_class = True)
        nearby_devices = bluetooth.discover_devices(lookup_names=True)
        #for addr, name, cod in nearby_devices:
        for addr, name in nearby_devices:
            counter = counter + 1
            if name in listOfNames:
                deviceName = name
                counterChecks = counterChecks + 1

            #if(hex(cod) == '0x1f00'):
            #	deviceCod = hex(cod)
            #	counterChecks = counterChecks+1

            if addr[:8] in listOfPrefix:
                deviceMac = addr
                counterChecks = counterChecks + 1

        drawblack.text((2, 20),
                       'Scanned devices:' + str(counter),
                       font=font18,
                       fill=0)
        if (counterChecks <= 3 and counterChecks != 0):
            drawblack.text((2, 42),
                           'Skimmer found: ' + deviceName,
                           font=font18,
                           fill=0)
            drawblack.text((2, 65), 'MAC: ' + deviceMac, font=font18, fill=0)
        else:
            drawblack.text((2, 42),
                           'No skimmer found. :)',
                           font=font18,
                           fill=0)

        epd.display(epd.getbuffer(HBlackimage))
        #epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
        time.sleep(20)
        logging.info("Clear...")

        #epd.Clear()
        epd.init(epd.lut_full_update)
        epd.Clear(0xFF)

        epd.sleep()
        #command = "/usr/bin/sudo /sbin/shutdown -r now"
        #process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
        #output = process.communicate()[0]
    except IOError as e:
        logging.info(e)

    except KeyboardInterrupt:
        logging.info("ctrl + c:")
        epd_driver.module_exit()
        exit()
Example #5
0
# -*- coding:utf-8 -*-

import os
import logging
from lib import epd2in13
import time
from PIL import Image, ImageDraw, ImageFont
from lib import epd2in13

picdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic')
logging.basicConfig(level=logging.DEBUG)

try:
    logging.info("epd2in13 Demo")

    epd = epd2in13.EPD()
    logging.info("init and Clear")
    epd.init(epd.lut_full_update)
    epd.Clear(0xFF)

    # Drawing on the image
    font15 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 15)
    font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)

    logging.info("1.Drawing on the image...")
    image = Image.new('1', (epd.EPD_HEIGHT, epd.EPD_WIDTH),
                      255)  # 255: clear the frame
    draw = ImageDraw.Draw(image)

    draw.rectangle([(0, 0), (50, 50)], outline=0)
    draw.rectangle([(55, 0), (100, 50)], fill=0)