Ejemplo n.º 1
0
    def __init__(self, debug_mode=False):
        self._debug_mode = debug_mode

        if not debug_mode:
            self._display_type = os.environ.get("EPAPER_TYPE", "epd2in7")
            if self._display_type == "epd2in7":
                import epd2in7
                self._display_width = epd2in7.EPD_HEIGHT  # inversed
                self._display_height = epd2in7.EPD_WIDTH
                self._epd = epd2in7.EPD()
                self._epd.init()
            elif self._display_type == "epd4in2":
                import epd4in2
                self._display_width = epd4in2.EPD_WIDTH
                self._display_height = epd4in2.EPD_HEIGHT
                self._epd = epd4in2.EPD()
                self._epd.init()
            else:
                raise "Invalid display config"
        else:
            self._display_width = EPD_WIDTH
            self._display_height = EPD_HEIGHT

        self._time_zone = tzlocal.get_localzone()
        self._str_time = "XXXX"
        self._drawing = drawing.Drawing(self._display_width,
                                        self._display_height)
Ejemplo n.º 2
0
def main():
    epd = epd2in7.EPD()
    epd.init()

    imagefile = raw_input(
        "Please name the file you want to draw to screen (for a list of files in the current directory enter bmplist): "
    )

    while imagefile == "bmplist":

        bmpfiles = os.listdir('.')
        pattern = "*.bmp"
        for entry in bmpfiles:
            if fnmatch.fnmatch(entry, pattern):
                print(entry)
        imagefile = raw_input(
            "Please name the file you want to draw to screen (for a list of files in the current directory enter bmplist): "
        )

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT),
                      255)  # 255: clear the image with white
    draw = ImageDraw.Draw(image)

    epd.display_frame(epd.get_frame_buffer(image))

    # display images
    epd.display_frame(epd.get_frame_buffer(Image.open(imagefile)))
Ejemplo n.º 3
0
def bildZeichner(name = "unbekannt", anwesenheit = "ist nicht da", raum ="", vorlage = "vorlagen/nachricht_vorlage.bmp",fontpfad = "font/VertigoPlusFLF-Bold.ttf", büro = "unbkt"):
    epd = epd2in7.EPD()
    epd.init()

    if raum == büro:
        raum = ""
        anwesenheit = "ist da"

    elif raum:
        print("yes")
        raum = "ist im Raum: {}".format(raum)

    # Lädt die vorlage (Hinweis : sie muss horizontal 264px breit und 176px hoch sein)
    mask = Image.open(vorlage)  
    #Erstellt ein Draw Objekt mit dem man dann aus mask rumschreiben kann. 
    schreib = ImageDraw.Draw(mask)
    größen = großBestimm('Prof. {}:'.format(name), fontpfad, schreib)

    #Schrift wird ausgesucht inkl. schriftgröße
    font = ImageFont.truetype(fontpfad, größen[0])
    schreib.text((10,10), 'Prof. {}:'.format(name),font = font, fill = 0)
    font = ImageFont.truetype(fontpfad, 45)
    schreib.multiline_text((10,größen[1]), '{}!\n{}'.format(anwesenheit, raum ),font = font, fill = 0)

    # Erstellt ein neues Bild aber mit umgekehrten Größen
    neu = Image.new('1',(176, 264),255)
    # Die horizontale Maske wird nun um 90 Grad gedreht und auf das neue Bild geschrieben 
    neu = mask.transpose(Image.ROTATE_90)
    neu.save('nachricht.bmp',"bmp")
    neu.show()
    # Stellt das Bild dar
    epd.display_frame(epd.get_frame_buffer(Image.open('nachricht.bmp')))
Ejemplo n.º 4
0
def main(data):
    epd = epd2in7.EPD()
    epd.init()

    #Trent Test
    #image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)    # 255: clear the image with white
    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH),
                      255)  # 255: clear the image with white

    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 24)

    total = 0
    for d in data:
        total += d["totalLitres"]
    total = float(total)

    i = 0
    for d in data:
        k = float(d["totalLitres"]) / total

        draw.rectangle((125, 28 * i, 125 + 125 * k, 28 * i + 20), fill=0)
        draw.text((20, 0 + 28 * i), d["name"], font=font, fill=0)
        draw.text((210, 0 + 28 * i),
                  str(d["totalLitres"]) + " L",
                  font=font,
                  fill=0)
        i = i + 1

    #Trent Test
    #epd.display_frame(epd.get_frame_buffer(image))
    epd.display_frame(epd.get_frame_buffer(image.rotate(90, expand=True)))
Ejemplo n.º 5
0
def main():
    epd = epd2in7.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT),
                      255)  # 255: clear the image with white
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 18)
    draw.text((20, 50), 'e-Paper demo', font=font, fill=0)
    draw.rectangle((0, 76, 176, 96), fill=0)
    draw.text((18, 80), 'Hello world!', font=font, fill=255)
    draw.line((10, 130, 10, 180), fill=0)
    draw.line((10, 130, 50, 130), fill=0)
    draw.line((50, 130, 50, 180), fill=0)
    draw.line((10, 180, 50, 180), fill=0)
    draw.line((10, 130, 50, 180), fill=0)
    draw.line((50, 130, 10, 180), fill=0)
    draw.arc((90, 190, 150, 250), 0, 360, fill=0)
    draw.chord((90, 120, 150, 180), 0, 360, fill=0)
    draw.rectangle((10, 200, 50, 250), fill=0)

    epd.display_frame(epd.get_frame_buffer(image))

    # display images
    epd.display_frame(epd.get_frame_buffer(Image.open('monocolor.bmp')))
Ejemplo n.º 6
0
def displayInit():
    print("Init Display")
    epd = epd2in7.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    print(epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT)
    # 255: clear the image with white
    # image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    # draw = ImageDraw.Draw(image)
    # font = ImageFont.truetype(
    #     '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 18)
    # draw.text((20, 106), 'Max Mustermann', font=font, fill=0)
    # draw.text((44, 106), 'Musterstrasse 23', font=font, fill=0)
    # draw.text((68, 88), '12345 Musterstadt', font=font, fill=0)
    # draw.line((105, 265, 105, 0), fill=0)
    # draw.line((104, 66, 0, 66), fill=0)
    # draw.text((20, 50), 'e-Paper demo', font=font, fill=0)
    # draw.rectangle((0, 76, 176, 96), fill=0)
    # draw.text((18, 80), 'Hello world!', font=font, fill=255)
    # draw.line((10, 130, 10, 180), fill=0)
    # draw.line((10, 130, 50, 130), fill=0)
    # draw.line((50, 130, 50, 180), fill=0)
    # draw.line((10, 180, 50, 180), fill=0)
    # draw.line((10, 130, 50, 180), fill=0)
    # draw.line((50, 130, 10, 180), fill=0)
    # draw.arc((90, 190, 150, 250), 0, 360, fill=0)
    # draw.chord((90, 120, 150, 180), 0, 360, fill=0)
    # draw.rectangle((10, 200, 50, 250), fill=0)

    # epd.display_frame(epd.get_frame_buffer(image))

    # display images
    epd.display_frame(epd.get_frame_buffer(Image.open('img/ParcelKey.bmp')))
Ejemplo n.º 7
0
def main():
    epd = epd2in7.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_HEIGHT), 255)    # 255: clear the image with white
    draw = ImageDraw.Draw(image)

    # Current time
    now = datetime.now()
    # time
    draw.text((0, 0), now.strftime("%b,%d"), font = font48, fill = 0)
    # date
    draw.text((0, 48), now.strftime("%A, WW%W"), font = font22, fill = 0)

    # get weather from Yahoo!
    (today, day1, day2) = weather()

    # Today's weather condition
    image.paste(weather_cond(today['text']), (200, 0))
    print "Today weather: "+today['text']

    # Today's temperature
    draw.text((200, 64), today['high']+'-'+today['low'], font = font22, fill = 0)
    print "Today temperature range: "+today['high']+'-'+today['low']

    # Inter-section bar
    draw.line((0, 90, 264, 90), fill = 0)

    # Day+1
    image.paste(weather_cond(day1['text']), (0, 94))
    nextday = now + timedelta(1)
    draw.text((64+2, 94), nextday.strftime('%a%d'), font = font22, fill = 0)
    draw.text((64+2, 94+32), day1['high']+'-'+day1['low'], font = font22, fill = 0)
    draw.text((2, 94+32+22+8), day1['text'][:10], font = font22, fill = 0)
    print "Tomorrow weather: "+day1['text']
    print "Tomorrow temperature range: "+day1['high']+'-'+day1['low']

    # Day+2
    image.paste(weather_cond(day2['text']), (132+2, 94))
    nextday = now + timedelta(2)
    draw.text((64+2+132, 94), nextday.strftime('%a%d'), font = font22, fill = 0)
    draw.text((64+2+132, 94+32), day2['high']+'-'+day2['low'], font = font22, fill = 0)
    draw.text((132+2, 94+32+22+8), day2['text'][:10], font = font22, fill = 0)
    print nextday.strftime('%a%d')+" weather: "+day2['text']
    print nextday.strftime('%a%d')+" temperature range: "+day2['high']+'-'+day2['low']

    # Inter-section bar
    draw.line((132, 90, 132, 184), fill = 0)
    draw.line((0, 184, 264, 184), fill = 0)

    # others
    #draw.arc((90, 190, 150, 250), 0, 360, fill = 0)
    #draw.chord((90, 120, 150, 180), 0, 360, fill = 0)
    #draw.rectangle((10, 200, 50, 250), fill = 0)

    #image.resize((epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH)).save('result.bmp')
    image = image.rotate(90).resize((epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT))

    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 8
0
def main(data):
    epd = epd2in7.EPD()
    epd.init()

    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH),
                      255)  # 255: clear the image with white

    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 24)
    #finding total water used among all users
    total = 0
    for d in data:
        total += d["totalLitres"]
    total = float(total)

    #finding each persons percentage of total water usage
    i = 0
    for d in data:
        k = float(d["totalLitres"]) / total
        #displaying the bars for each person by extending it proportionally to their percentage
        draw.rectangle((103, 28 * i, 103 + 125 * k, 28 * i + 20), fill=0)
        #displaying each persons name
        draw.text((2, 28 * i), d["name"], font=font, fill=0)
        #display each persons water consumption
        draw.text((175, 28 * i),
                  str(round(d["totalLitres"] / 3.85, 1)) + " Gal",
                  font=font,
                  fill=0)

        i = i + 1

    epd.display_frame(epd.get_frame_buffer(image.rotate(90, expand=True)))
Ejemplo n.º 9
0
    def __init__(self):
        '''
        Initializes a new object with the relevant parameters
        '''
        # Setup the image canvas and the display driver
        self.image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT),
                               255)
        self.draw = ImageDraw.Draw(self.image)
        self.epd = epd2in7.EPD()
        self.epd.init()

        # Define constants
        self.axisend = 5
        self.axisoffset = 20
        self.yaxisoffset = 25
        self.xend = 176
        self.yend = 264
        self.xzero = self.xend - self.axisoffset
        self.yzero = self.yend - self.yaxisoffset
        self.ymax = self.axisend
        self.xmax = self.axisend
        self.axisthickness = 2
        self.roundToBase = [5, 5]
        self.page = 0
        self.maxPages = 100

        # Define flags
        self.dataPlotted = False
Ejemplo n.º 10
0
def main():
    #Init driver
    epd = epd2in7.EPD()
    epd.init()
    # Image with screen size
    #255: clear the image with white
    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)
    #Object image on which we will draw
    draw = ImageDraw.Draw(image)

    #draw.rectangle((0, 0, 264, 49), fill = 0) #rectangle behind bdays and date
    #draw.rectangle((0, 48, 264, 71), fill = 0) #rectangle behind track ID
    draw.text((0, -4),
              str(Datum) + str(' ') + str(countdown) + str(geb),
              font=fontXL,
              fill=0)  # Date + next bday
    draw.line((5, 33, 259, 33), fill=0)
    #draw.text((0, 45), trackIDString, font = fontM, fill = 1)       # volumio track ID
    #draw.text((-4, 53), Uhrzeit, font = fontXXL, fill = 0)           # time alte version unter track ID
    draw.text((-4, 16), Uhrzeit, font=fontXXL, fill=0)
    draw.line((0, 125, 264, 125), fill=0)
    draw.text((120, 80), str(t), font=fontXS, fill=0)  #cpu temp
    #draw.text((0, 159), 'i:'+str(tempPi1)+'°|'+str(humiPi1)+str('%  o:')+str(tempD1)+'°|'+str(humiD1)+str('%  Δt:' )+str(deltaT)+str('°|ΔH:' )+str(deltaH)+str('%'), font = fontXS, fill = 0)       #temps alte version bei nutzung der Track ID
    draw.text((0, 130),
              'i:' + str(tempPi1) + '°|' + str(humiPi1) + str('% o:') +
              str(tempD1) + '°|' + str(humiD1),
              font=fontL2,
              fill=0)  #temps

    #Update display
    epd.display(epd.getbuffer(image))
    #sleep display
    epd.sleep()
Ejemplo n.º 11
0
def kontaktUpdate():
    print("Init KontaktUpdate")
    epd = epd2in7.EPD()
    epd.init()

    # image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    epd.display_frame(
        epd.get_frame_buffer(Image.open('img/acceptedContact.bmp')))
Ejemplo n.º 12
0
def main():
    epd = epd2in7.EPD()
    epd.init()

    callSubprocess('python ' + basedir + '/qr-invoice.py')

    # display QR code
    epd.display_frame(
        epd.get_frame_buffer(Image.open('' + basedir + '/tmp/qr_176x264.bmp')))
Ejemplo n.º 13
0
def parcelCat():
    print("Init ParcelCat")
    epd = epd2in7.EPD()
    epd.init()

    # image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    epd.display_frame(epd.get_frame_buffer(Image.open('img/cat.bmp')))
    epd.display_frame(epd.get_frame_buffer(Image.open('img/Cat2.bmp')))

    epd.display_frame(epd.get_frame_buffer(Image.open('img/ParcelKey.bmp')))
Ejemplo n.º 14
0
def parcelkey():
    print("Init Annahme")
    epd = epd2in7.EPD()
    epd.init()

    # image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    epd.display_frame(
        epd.get_frame_buffer(Image.open('img/paketangenommen.bmp')))

    epd.display_frame(epd.get_frame_buffer(Image.open('img/ParcelKey.bmp')))
def display_Charts():
    epd = epd2in7.EPD()
    epd.init()
    #epd.rotate(3) # Rotate the Display by 270 degree
    from coinmarketcap import Market
    coinmarketcap = Market()
    CurrencyData = coinmarketcap.ticker(start=0, limit=5, convert='EUR')
    LINEHEIGHT = 20
    price = 0
    currency_symbol = '€'

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT),
                      255)  # 255: clear the image with white
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 18)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 12)
    font_table_title = ImageFont.truetype('fonts/Grand9KPixel.ttf', 10)
    font_titles = ImageFont.truetype('fonts/slkscr.ttf', 16)
    font_num = ImageFont.truetype('fonts/PixelSplitter-Bold.ttf', 14)
    font_date = ImageFont.truetype('fonts/PixelSplitter-Bold.ttf', 12)

    draw.rectangle((0, 0, 264, 28), fill=0)
    draw.rectangle((0, 160, 264, 176), fill=0)
    draw.rectangle((0, 28, 264, 50), fill=0)
    draw.text((2, 8), " Cryptocurrency Market ", font=font_titles, fill=255)
    draw.text((5, 32),
              "NAME          PRICE                           CHANGE(24h)",
              font=font_table_title,
              fill=255)
    for item in CurrencyData:
        #price=round(float(),4)
        draw.text((5, 40 + LINEHEIGHT),
                  item['symbol'],
                  font=font_titles,
                  fill=0)
        draw.text((60, 40 + LINEHEIGHT),
                  "€" + item['price_eur'],
                  font=font_num,
                  fill=0)
        draw.text((200, 40 + LINEHEIGHT),
                  item['percent_change_24h'] + "%",
                  font=font_num,
                  fill=0)
        LINEHEIGHT += 20

    draw.text((0, 160),
              str(" UPDATED ON:" + time.strftime("%c")),
              font=font_date,
              fill=255)

    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 16
0
 def __init__(self):
     self.ready = False
     try:
         self.epd = epd2in7.EPD()
         self.epd.init()
         self.epd.Clear(0xFF)
         self.lines = []
         self.show()
         self.ready = True
     except:
         pass
Ejemplo n.º 17
0
def display_weather(today, sunrise, sunset, hightemp, lowtemp, ico_path,
                    tide_stat, tide_height, tide_time, moon_ico_path, wind,
                    gust):
    # initialize the display
    epd = epd2in7.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    # 255: clear the image with white
    image = Image.new('1', (264, 176), 255)
    draw = ImageDraw.Draw(image)

    # pick a font for the text
    font = ImageFont.truetype('Lato-Bold.ttf', 18)
    font_med = ImageFont.truetype('Lato-Bold.ttf', 14)

    # now do some drawing, working roughly from top left to bottom right...

    # add weather icon
    image.paste(transparent_to_white(ico_path), (-5, -5))

    # date
    draw.text((70, 2), today, font=font, fill=0)

    # moon phase icon
    image.paste(transparent_to_white(moon_ico_path), (220, 0))

    # sunrise/sunset
    image.paste(transparent_to_white("icons/sunrise.png"), (70, 25))
    draw.text((98, 30), sunrise, font=font_med, fill=0)
    image.paste(transparent_to_white("icons/sunset.png"), (140, 25))
    draw.text((170, 30), sunset, font=font_med, fill=0)

    ## temperature
    # graphic pre-generated in R
    image.paste(transparent_to_white('Rtmp/temp.png'), (0, 95))

    ## wind
    image.paste(transparent_to_white('icons/wind.png'), (5, 60))
    draw.text((40, 60), wind, font=font_med, fill=0)
    draw.text((40, 75), gust, font=font_med, fill=0)

    ## tides
    for i in range(len(tide_stat)):
        image.paste(transparent_to_white("icons/water.png"), (95 + i * 80, 65))
        image.paste(
            transparent_to_white("icons/arrow.png").rotate(tide_stat[i]),
            (115 + i * 80, 65))
        draw.text((137 + i * 80, 67), tide_time[i], font=font_med, fill=0)

    # we've built a landscape image, need to rotate it into place
    image = image.rotate(270, expand=1)
    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 18
0
def draw(imgfile):
    epd = epd2in7.EPD()
    epd.init()
    epd.Clear(0xFF)

    Himage = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH),
                       255)  # 255: clear the frame

    Himage = Image.open(imgfile)
    epd.display(epd.getbuffer(Himage))

    epd.sleep()
Ejemplo n.º 19
0
def main():
    epd = epd2in7.EPD()
    epd.init()

    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    #image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)    # 255: clear the image with white
    draw = ImageDraw.Draw(image)

    #draw_rectangle(draw, 0, 100, 50 , 100, color=0)

    draw_rect_border(draw, 0, 23, 112, 90, border=2, color=0)
    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 20
0
    def __init__(self):
        locale.setlocale(locale.LC_ALL, '')
        self.fonts = Fonts(timefont_size=75,
                           datefont_size=26,
                           infofont_size=18,
                           smallfont_size=16)

        with open(NOBELPRIZE_JSON) as f:
            self.nobeldata = json.load(f)

        self.epd = epd2in7.EPD()
        self.epd.init()
        self.read_buttons()
Ejemplo n.º 21
0
def displayText(text):
    epd = epd2in7.EPD()
    epd.init()

    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH),
                      255)  # 255: clear the image with white

    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 18)
    draw.text((20, 100), text, font=font, fill=0)

    epd.display_frame(epd.get_frame_buffer(image.rotate(90, expand=True)))
Ejemplo n.º 22
0
def main():
    # API to get ISS Current Location
    URL = 'http://api.open-notify.org/iss-now.json'

    # Initialize and clear the 2in7 (black/white) display
    epd = epd2in7.EPD()

    display = Display(epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH)

    # Store positions in list
    positions = []

    while (True):
        t0 = time()
        try:
            r = requests.get(url=URL)

            # extracting data in json format
            data = r.json()
            print(data)
        except:
            print(
                "error getting data.... might be a temporary hiccup so continuing"
            )
            continue

        lat = float(data['iss_position']['latitude'])
        lon = float(data['iss_position']['longitude'])
        if len(positions) > (DATA_LIMIT - 1):
            del positions[0]
        positions.append((lat, lon))
        print(positions)

        # Refresh the display on the first fetch and then on every DISPLAY_REFRESH_INTERVAL fetch
        if ((len(positions) >= 1)
                and ((len(positions) - 1) % DISPLAY_REFRESH_INTERVAL)):
            epd.init()
            (imageBlack, imageRed) = display.drawISS(positions)
            # We're drawing the map in black and the ISS location and trajectory in red
            # Swap it around if you'd like the inverse color scheme
            epd.display(epd.getbuffer(imageBlack), epd.getbuffer(imageRed))
            sleep(2)
            epd.sleep()

        t1 = time()
        sleepTime = max(DATA_INTERVAL - (t1 - t0), 0)
        sleep(
            sleepTime
        )  # sleep for 30 seconds minus duration of get request and display refresh
Ejemplo n.º 23
0
def displayTest():

    # Initialize
    epd = epd2in7.EPD()
    epd.init()

    # Clear screen (255 - fill with white, width x height of the screen)
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    draw = ImageDraw.Draw(image)

    # Square at the center
    draw.rectangle((epd2in7.EPD_WIDTH / 2 - 15, epd2in7.EPD_HEIGHT / 2 - 15,
                    epd2in7.EPD_WIDTH / 2 + 15, epd2in7.EPD_HEIGHT / 2 + 15),
                   fill=0)

    # Refresh
    epd.display(epd.getbuffer(image))
Ejemplo n.º 24
0
def main():
    #Init driver
    epd = epd2in7.EPD()
    epd.init()

    #Image de la dimension de l ecran - Image with screen size
    #255: fond blanc - clear the image with white
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)
    #Objet image sur lequel on va dessiner - Object image on which we will draw
    draw = ImageDraw.Draw(image)

    #Dessine un rectangle au centre de l ecran - draw a rectangle in the center of the screen
    draw.rectangle((epd2in7.EPD_WIDTH / 2 - 10, epd2in7.EPD_HEIGHT / 2 - 10,
                    epd2in7.EPD_WIDTH / 2 + 10, epd2in7.EPD_HEIGHT / 2 + 10),
                   fill=0)

    #Actualise affichage - Update display
    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 25
0
def main():
    epd = epd2in7.EPD()
    epd.init()
    epd.Clear(0xFF)

    font24 = ImageFont.truetype('./lib/Font.ttc', 24)
    font10 = ImageFont.truetype('./lib/Font.ttc', 10)

    while True:
        himage = Image.new('1', (epd.height, epd.width),
                           255)  # 255: clear the frame
        draw = ImageDraw.Draw(himage)
        draw.text((10, 0), utils.get_ips(network_adaptor), font=font10, fill=0)
        draw.text((60, 20),
                  datetime.now().strftime('%Y-%m-%d %H:%M'),
                  font=font24,
                  fill=0)
        epd.display(epd.getbuffer(himage))

        time.sleep(30)
Ejemplo n.º 26
0
def main():
    #Init driver
    epd = epd2in7.EPD()
    epd.init()
    # Image with screen size
    #255: clear the image with white
    image = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)
    #Object image on which we will draw
    draw = ImageDraw.Draw(image)

    #draw.rectangle((0, 0, 264, 49), fill = 0) #rectangle behind bdays and date
    draw.rectangle((0, 48, 264, 71), fill=0)  #rectangle behind track ID
    draw.text((0, -8),
              str(Datum) + str(' ') + str(gebStringNext),
              font=fontXL,
              fill=0)  # Date + next bday
    #draw.text((75, -6), gebStringNext, font = fontL, fill = 0)     # bday1 old version, different size than date
    draw.line((5, 26, 259, 26), fill=0)
    draw.text((0, 23), gebStringUeberNext, font=fontS, fill=0)  #bday2
    #draw.line((0, 48, 264, 48), fill = 0) # black line below bday 2
    #draw.arc((70, 90, 120, 140), 0, 360, fill = 0)
    #draw.chord((70, 150, 120, 200), 0, 360, fill = 0)
    draw.text((0, 45), trackIDString, font=fontM, fill=1)  # volumio track ID
    #draw.line((0, 77, 264, 77), fill = 0)
    draw.text((-4, 53), Uhrzeit, font=fontXXL, fill=0)  # time
    draw.line((0, 160, 264, 160), fill=0)
    draw.text((120, 110), str(t), font=fontXS, fill=0)  #cpu temp
    draw.text((121, 125), str(d1_status_indicator), font=fontXS,
              fill=0)  #D1 Status Indicator (X or √)
    draw.text((0, 159),
              'i:' + str(tempPi1) + '°|' + str(humiPi1) + str('%  o:') +
              str(tempD1) + '°|' + str(humiD1) + str('%  Δt:') + str(deltaT) +
              str('°|ΔH:') + str(deltaH) + str('%'),
              font=fontXS,
              fill=0)  #temps

    #Update display
    epd.display(epd.getbuffer(image))
    #sleep display
    epd.sleep()
def display_Charts():
    epd = epd2in7.EPD()
    epd.init()
    #epd.rotate(3) # Rotate the Display by 270 degree 
    from coinmarketcap import Market
    coinmarketcap = Market()
    CurrencyData=coinmarketcap.ticker(start=0, limit=5, convert='EUR')
    LINEHEIGHT=20
    price=0
    currency_symbol=u'€'

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)    # 255: clear the image with white
    draw = ImageDraw.Draw(image)
# draw strings to the buffer
    font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 13)
    font_table_title = ImageFont.truetype('fonts/8bit.ttf', 12)
    font_titles = ImageFont.truetype('fonts/8bit.ttf', 13)
    font_num = ImageFont.truetype('fonts/BebasNeue-Regular.ttf', 20)
    font_date = ImageFont.truetype('fonts/BebasNeue-Regular.ttf',16)

    draw.rectangle((0, 0, 264, 28), fill = 0)
    draw.rectangle((0, 28, 264, 50), fill = 0)
    draw.rectangle((0, 220,176, 264), fill = 0)
    
    draw.text((0, 6)," Crypto Charts",  font = font_titles,  fill = 255)
    draw.text((5, 33), "NAME      PRICE                          CHANGE(24h)",font =font_table_title,  fill = 255)
    for item in CurrencyData:
        price=round(float(item['price_eur']),2)
        display_price= currency_symbol+ str(price)
        draw.text((5,40+LINEHEIGHT),item['name'],font =font_num,fill = 0)
        draw.text((100,40+LINEHEIGHT),display_price,font =font_num,fill = 0)
        #draw.text((200,40+LINEHEIGHT),item['percent_change_24h']+"%",font =font_num,fill = 0)
        LINEHEIGHT+=18
    
    draw.text((5,220),"Last updated on:",font =font_num,fill = 255)
    draw.text((5,240),time.strftime("%c"),font =font_num,fill = 255)

    epd.display_frame(epd.get_frame_buffer(image))
Ejemplo n.º 28
0
def get_epd2in7():
    return epd2in7.EPD()
Ejemplo n.º 29
0
import traceback

ORIENTATION = "horizontal"

# This is a black and white display, 1-bit only
IMAGE_MODE = '1'

# degree symbol °

HEIGHT = 176
WIDTH = 264

CLEAR = 255
FONT_SIZE = 20

epd = epd2in7.EPD()

FONT = ImageFont.truetype(
    '/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf',
    FONT_SIZE)


def init():
    print("Hello main")
    epd.init()
    epd.clear(0xFF)

    image = blankCanvas()

    writeToDisplay()
Ejemplo n.º 30
0
def infiniteloop2():
    
    #variable for setup the fireBase app for sending notifications
    config = {
      "apiKey": "AIzaSyDTQfbN-Ag-GN1z0pI-kIRnc4LtUB83NPw",
      "authDomain": "csc354-a604d.firebaseapp.com",
      "databaseURL": "https://csc354-a604d.firebaseio.com",
      "projectId": "csc354-a604d",
      "storageBucket": "csc354-a604d.appspot.com",
      "messagingSenderId": "786974548917",
      "appId": "1:786974548917:web:504b52b9ef22062c9daffc",
      "measurementId": "G-8KLJLYJMS2"
    };
    #configuration
    fireBase = pyrebase.initialize_app(config)
    dbref = fireBase.database()
    
    #initiate and clear the display, set associated variables
    epd = epd2in7.EPD()
    epd.init()
    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)    # 255: clear the image with white
    #epd.Clear(0xFF)
    font15 = ImageFont.truetype('/usr/share/fonts/truetype/crosextra/Caladea-Regular.ttf', 15)
    font25 = ImageFont.truetype('/usr/share/fonts/truetype/crosextra/Caladea-Regular.ttf', 25)
    font30 = ImageFont.truetype('/usr/share/fonts/truetype/crosextra/Caladea-Regular.ttf', 30)
    # Drawing on the Horizontal image. We must create an image object for both the black layer
    # and the red layer, even if we are only printing to one layer
    HBlackImage = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)  # 298*126
    HRedImage = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)  # 298*126
    
    #browser firebase instance
    url = "https://csc354-a604d.firebaseio.com/"
    fb = firebase.FirebaseApplication(url, None)
    
    _patient_ID = input("enter patient ID: ")
    
    #create a draw object and the font object we will use for the display, and display an description.
    draw = ImageDraw.Draw(HBlackImage)
    draw.text((0, 0),"<<Done", font = font15, fill = 0)
    draw.text((20, 55), 'Heartrate Readings...', font = font25, fill = 0)
    epd.display(epd.getbuffer(HBlackImage))#, epd.getbuffer(HRedImage))
    
    adc = Adafruit_ADS1x15.ADS1015()
    
    # initialization 
    GAIN = 2/3  
    curState = 0
    thresh = 525  # mid point in the waveform
    P = 512
    T = 512
    stateChanged = 0
    sampleCounter = 0
    lastBeatTime = 0
    firstBeat = True
    secondBeat = False
    Pulse = False
    IBI = 600
    rate = [0]*10
    amp = 100 

    lastTime = int(time.time()*1000)
    
    # Main loop. use Ctrl-c to stop the code
    while True:
    
        # read from the ADC
        Signal = adc.read_adc(0, gain=GAIN)   #TODO: Select the correct ADC channel. I have selected A0 here
        curTime = int(time.time()*1000)
        
        tms = str(time.strftime("%H~%M~%S"))#hours, minutes, seconds
        dt = str(time.strftime("%Y-%m-%d"))#Year, month, day

        sampleCounter += (curTime - lastTime);     # keep track of the time in mS with this variable
        lastTime = curTime
        N = sampleCounter - lastBeatTime;        # monitor the time since the last beat to avoid nois

        #  find the peak and trough of the pulse wave
        if Signal < thresh and N > (IBI/5.0)*3.0 :  # avoid dichrotic noise by waiting 3/5 of last IBI
            if Signal < T :                         # T is the trough
              T = Signal;                           # keep track of lowest point in pulse wave 

        if Signal > thresh and  Signal > P:         # thresh condition helps avoid noise
            P = Signal;                             # P is the peak
                                                    # keep track of highest point in pulse wave

        #  NOW IT'S TIME TO LOOK FOR THE HEART BEAT
        # signal surges up in value every time there is a pulse
        if N > 250 :                                      # avoid high frequency noise
            if  (Signal > thresh) and  (Pulse == False) and  (N > (IBI/5.0)*3.0):       
                Pulse = True;                               # set the Pulse flag when we think there is a pulse
                IBI = sampleCounter - lastBeatTime;         # measure time between beats in mS
                lastBeatTime = sampleCounter;               # keep track of time for next pulse

                if secondBeat :                        # if this is the second beat, if secondBeat == TRUE
                    secondBeat = False;                  # clear secondBeat flag
                    for i in range(0,10):             # seed the running total to get a realisitic BPM at startup
                        rate[i] = IBI;                      

                if firstBeat :                        # if it's the first time we found a beat, if firstBeat == TRUE
                    firstBeat = False;                   # clear firstBeat flag
                    secondBeat = True;                   # set the second beat flag
                    continue                              # IBI value is unreliable so discard it

                # keep a running total of the last 10 IBI values
                runningTotal = 0;                  # clear the runningTotal variable    

                for i in range(0,9):                # shift data in the rate array
                    rate[i] = rate[i+1];                  # and drop the oldest IBI value 
                    #runningTotal += rate[i];              # add up the 9 oldest IBI values

                rate[9] = IBI;                          # add the latest IBI to the rate array
                #runningTotal += rate[9];                # add the latest IBI to runningTotal
                runningTotal = sum(rate)
                runningTotal /= 10;                     # average the last 10 IBI values 
                BPM = 60000/runningTotal;               # how many beats can fit into a minute? that's BPM!
              
			    #round the BPM to 2 decimal point for display on screen
                Round_BPM = str(round(BPM,2))
                #create a draw object and the font object we will use for the heartrate display.
                Limage = Image.new('1',(epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255) # 255: clear the frame
                draw = ImageDraw.Draw(Limage)
                draw.text((0, 0),"<<Done", font = font15, fill = 0)
              
                #send latest heart rate to Firebase
                fb.put("/Activities"+"/"+ str(_patient_ID) +"/"+ dt +"/AI" +"/HeartRate","LastestHeartRate/", (tms + "?" + "→" + "?"+ str(BPM)))
                #send heart rate to list of HR in Firebase
                fb.put("/Activities"+"/"+ str(_patient_ID) +"/"+ dt +"/AI"+"/HeartRateRecord",tms + "/",  BPM)
                
                #differentiate the BPM values and perform corresponding actions
                if (BPM>100): 
                    post_ref = dbref.child('Notifications')      #setup a post variable for sending data to specific branch in DB
                    htime = str(datetime.datetime.now())
                    #send notifications to database as high heart rate, and put a caution on display
                    post_key_ref = post_ref.push({
                        'Patient ID': _patient_ID,
                        'Datetime': htime,
                        'Status': 'High heart rate: ' + str(BPM) + " BPM"
                    })
                    #send notifications to CNA also
                    all_CNA = dbref.child("CNA").get() # get all CNA IDs
                    notID = list(post_key_ref.values())[0]
                    for cna in all_CNA.each():
                        loc = str(cna.key())
                        CNA_post = dbref.child('CNA').child(loc).child('Notifications')
                        CNA_post.update({
                            notID:{
                            'Viewed': 'False'}
                        })
                    #send notifications to CNO/Director also
                    all_AC = dbref.child("uAccount").get() # get all uAccount IDs
                    for account in all_AC.each():
                        ac_loc = str(account.key())
                        AC_post = dbref.child('uAccount').child(ac_loc).child('Notifications')
                        AC_post.update({
                            notID:{
                            'Viewed': 'False'}
                        })
                    draw.text((25, 55), Round_BPM + " BPM", font = font30, fill = 0)
                    draw.text((25, 90), "BPM is too high!", font = font30, fill = 0)
                    epd.display(epd.getbuffer(Limage))#, epd.getbuffer(HRedImage)
                else:
                    draw.text((25, 55), Round_BPM + " BPM", font = font30, fill = 0)
                    epd.display(epd.getbuffer(Limage))#, epd.getbuffer(HRedImage)
                
                print ('BPM: {}'.format(BPM)) #print on console
              
              
        if Signal < thresh and Pulse == True :   # when the values are going down, the beat is over
            Pulse = False;                         # reset the Pulse flag so we can do it again
            amp = P - T;                           # get amplitude of the pulse wave
            thresh = amp/2 + T;                    # set thresh at 50% of the amplitude
            P = thresh;                            # reset these for next time
            T = thresh;

        if N > 2500 :                          # if 2.5 seconds go by without a beat
            thresh = 512;                          # set thresh default
            P = 512;                               # set P default
            T = 512;                               # set T default
            lastBeatTime = sampleCounter;          # bring the lastBeatTime up to date        
            firstBeat = True;                      # set these to avoid noise
            secondBeat = False;                    # when we get the heartbeat back
            print ("no beats found")
            

        time.sleep(0.0005)