Пример #1
0
    def display_notification_message(self, data):

        message = data[0]
        message2 = data[1]
        message3 = data[2]

        inkyphat.set_colour("black")

        font = ImageFont.truetype(inkyphat.fonts.FredokaOne, 26)
        font2 = ImageFont.truetype(inkyphat.fonts.FredokaOne, 20)
        font3 = ImageFont.truetype(inkyphat.fonts.FredokaOne, 14)

        print(message)
        print(message2)
        print(message3)

        w, h = font.getsize(message)
        x = (inkyphat.WIDTH / 2) - (w / 2)
        y = (inkyphat.HEIGHT / 3) - (h / 1.5)
        inkyphat.text((x, y), message, inkyphat.BLACK, font)

        w, h = font2.getsize(message2)
        x = (inkyphat.WIDTH / 2) - (w / 2)
        y = (inkyphat.HEIGHT / 2) - 5
        inkyphat.text((x, y), message2, inkyphat.BLACK, font2)

        w, h = font2.getsize(message3)
        x = (inkyphat.WIDTH / 2) - (w / 2)
        y = (inkyphat.HEIGHT / 3) * 2
        inkyphat.text((x, y), message3, inkyphat.BLACK, font2)

        inkyphat.show()
Пример #2
0
def printBusTimes(times):
    prefix = ["82:", "Rosa:", bustimes.Either("158:", "82B:")]
    m = "min"
    op = []
    toL5 = lambda s: " " * (max(5 - len(s), 0)) + s
    for i, ts in enumerate(times):
        if type(ts) is bustimes.Either:
            pf = prefix[i].left if ts.left else prefix[i].right
            next_times = ts.left if ts.left else ts.right
        else:
            pf = prefix[i]
            next_times = ts
        s = [pf, "-", "-"]
        for j, t in enumerate(next_times):
            s[j + 1] = "Núna!" if t == 0 else str(t) + m
        op.append(" ".join(map(toL5, s)))
    bt = "\n".join(op)
    inkyphat.clear()
    td = datetime.now().strftime("%Y-%m-%d %H:%M")
    inkyphat.text(((inkyphat.WIDTH - 16 * fontwidth) // 2, 18), td,
                  inkyphat.RED, font)
    inkyphat.text((inkyphat.WIDTH // 2 - 14 * fontwidth // 2, 2),
                  "Strætóferðir", inkyphat.RED, bigfont)
    printlines(bt)
    vtc = ((inkyphat.WIDTH - 10 * 14 - vt.size[0] - 10) // 2,
           inkyphat.HEIGHT - 2 - 14)
    inkyphat.text((vtc[0] + vt.size[0] + 2, vtc[1] - 4), "Västtrafik",
                  inkyphat.RED, bigfont)
    inkyphat.paste(vt, ((vtc[0], vtc[1] - vt.size[1] + 14 - 2)))
    inkyphat.show()
Пример #3
0
def show_image(filepath):
    img = Image.open(filepath)

    pixel_font = get_font("SFPixelate.ttf", 9)
    medium_font = get_font("SFPixelate.ttf", 18)
    # large_font = get_font('SFPixelate.ttf', 36)

    d = ImageDraw.Draw(img)

    time_string = datetime.datetime.now().strftime("%H:%M")
    ip_address = check_output(["hostname", "-I"]).decode("utf-8").strip()
    info_string = f"{ip_address} / {time_string}"

    d.text((1, 95), info_string, font=pixel_font, fill=WHITE)

    quote_url = "https://notify.goude.se/quote"
    quote = requests.get(quote_url).text
    quote_font = pixel_font
    chunk_width = 35

    quote = "\n".join(chunkstring(quote, chunk_width))

    d.multiline_text((1, 1), quote, font=quote_font, fill=WHITE)

    inkyphat.set_colour("black")  # 'red' is much slower
    inkyphat.set_border(inkyphat.BLACK)
    inkyphat.set_image(img)
    inkyphat.show()
Пример #4
0
    def mode3(self):

        # background image
        img = Image.open(self.config.back_simple)
        inkyphat.set_image(img)

        # Add ranking text
        font = ImageFont.truetype(self.font, 22)
        inkyphat.text((45, 5), "#" + self.rank, inkyphat.WHITE, font)

        # Add the price text
        font = ImageFont.truetype(self.font, 48)
        price = str("%.3f" % self.price)
        inkyphat.text((44, 25), price, inkyphat.WHITE, font)

        # Add ROI Percentage
        actual_value = self.price * self.coin_amount
        percentage = (actual_value / self.coin_invest * 100) - 100
        font = ImageFont.truetype(self.font, 32)
        roistr = str("%.2f" % percentage + '%')
        if percentage > 0.0:
            inkyphat.text((44, 67), roistr, inkyphat.WHITE, font)
        else:
            inkyphat.text((44, 67), roistr, inkyphat.RED, font)

        inkyphat.show()
Пример #5
0
async def widget(loop):
    while True:
        accept_id = get_request_id()
        request_id = await queue.get()
        if accept_id < request_id:
            print("inkyphat_redraw: redraw")
            inkyphat.show()
Пример #6
0
def display_info(text, rotate = True):

	title = "%s %s" % (text, time.strftime('%d/%m %H:%M'))

	local_IP = "IP loc.: %s" % (read_local_ip())
	public_IP = "IP pub.: %s" % (read_public_ip())
	info_CPU = "CPU: T. {:2.0f} C, load {:2.0f} %".format(read_CPU_temp(), cpu_percent())

	if has_inky:
		inkyphat.clear()
		font18 = inkyphat.ImageFont.truetype(inkyphat.fonts.FredokaOne, 18)
		font20 = inkyphat.ImageFont.truetype(inkyphat.fonts.FredokaOne, 20)
		font24 = inkyphat.ImageFont.truetype(inkyphat.fonts.FredokaOne, 24)
		if rotate:
			inkyphat.set_rotation(180)

		inkyphat.rectangle((0, 0, 212, 30), red, red)
		width, height = font20.getsize(title)
		d, r = divmod(width, 2)
		inkyphat.text((106-d, 3), title, white, font=font20)
		inkyphat.rectangle((0, 31, 212, 104), white, white)

		inkyphat.text((5, 31), local_IP, black, font=font18)
		inkyphat.text((5, 53), public_IP, black, font=font18)
		inkyphat.text((5, 78), info_CPU, red, font=font18)
		inkyphat.show()
	else:
		print(title)
		print(local_IP)
		print(public_IP)
		print(temp_CPU)
	
	return local_IP, public_IP, info_CPU
Пример #7
0
def cleaner():
    colours = (inkyphat.RED, inkyphat.BLACK, inkyphat.WHITE)
    for c in enumerate(colours):
        inkyphat.set_border(c)
        for x in range(inkyphat.WIDTH):
            for y in range(inkyphat.HEIGHT):
                inkyphat.putpixel((x, y), c)
    inkyphat.show()
Пример #8
0
def finish_display():

    if not has_inky:
        return

    inkyphat.line((52, 30, 52, 104), inkyphat.BLACK)
    inkyphat.show()

    return True
Пример #9
0
def updateDisplay(sunrise,  sunset, weather):
    fontSize = 16
    # Load the built-in FredokaOne font
    font = ImageFont.truetype(inkyphat.fonts.FredokaOne, fontSize)
    inkyphat.set_border(inkyphat.BLACK)
    inkyphat.text((0, fontSize * 0), "Tank", inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 1), "Sunrise: " + sunrise.isoformat(), inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 2), "Sunset: " + sunset.isoformat(), inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 3), "Weather: " + weather, inkyphat.BLACK, font=font)
    
    # And show it!
    inkyphat.show()
Пример #10
0
def render(display):
    for x in range(inkyphat.WIDTH):
        for y in range(inkyphat.HEIGHT):
            inkyphat.putpixel((x, y), 0)

    for x in range(inkyphat.WIDTH):
        for y in range(inkyphat.HEIGHT):
            try:
                inkyphat.putpixel((x, y), display[y][x])
            except (IndexError):
                pass

    inkyphat.show()
Пример #11
0
def update_display():
    print("Getting train services...")
    services = national_rail_fetcher.get_next_services(station_from,
                                                       station_to)
    print("Got upcoming train services")

    print("Displaying results...")
    inkyphat.clear()
    inkyphat.set_border(inkyphat.WHITE)

    y = 0
    for service in services:
        render_service(service, y)
        y += LINE_HEIGHT

    inkyphat.show()
    print("Finished")
Пример #12
0
def printOutIP():  #for debugging, prints out wlan0 IP of Pi to screen
    out = subprocess.Popen(['hostname', '-I'],
                           stdout=subprocess.PIPE,
                           stderr=subprocess.STDOUT)

    img = Image.new("P", (inkyphat.WIDTH, inkyphat.HEIGHT))
    draw = ImageDraw.Draw(img)

    message = str(out.communicate()[0])

    w, h = font.getsize(message)
    x = (inkyphat.WIDTH / 2) - (w / 2)
    y = (inkyphat.HEIGHT / 2) - (h / 2)

    draw.text((x, y), message, inkyphat.BLACK, font)
    inkyphat.set_image(img)
    inkyphat.show()
Пример #13
0
def display_data(data):
    font_file = inkyphat.fonts.FredokaOne

    top = 0
    left = 0
    offset_left = 5

    text_lines = [
        "Ada's Adventures in Science", "Backers {}".format(data['backers']),
        "{} - {:.1f}%".format(data['pledged'], data['percent'])
    ]
    font = inkyphat.ImageFont.truetype(font_file, 20)
    for text in text_lines:
        width, height = font.getsize(text)
        inkyphat.text((0, top), text, 1, font=font)
        top += height + 1
    inkyphat.show()
    return
Пример #14
0
def main():
    mySettings = settingsClass()  # get settings from db

    mySunrise = sunRiseSet()  # Get sunrise and sunset from DB
    mySunrise.getSunriseset()

    myWeather = weather()
    myWeather.getWeather()

    #inkyphat.set_border(inkyphat.WHITE)
    if (myWeather.wind_dir in ('South')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_s.png")
    elif (myWeather.wind_dir in ('SW', 'SSW')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_sw.png")
    elif (myWeather.wind_dir in ('SE', 'SSE')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_se.png")
    elif (myWeather.wind_dir in ('North', 'NNW', 'NNE')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_n.png")
    elif (myWeather.wind_dir in ('West', 'WSW', 'WNW')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_w.png")
    elif (myWeather.wind_dir in ('East', 'ESE', 'ENE')):
        inkyphat.set_image("/home/pi/code/watertanks/resources/compass_e.png")
    else:  #if (myWeather.wind_dir in ('S', 'SE',  'SW',  'NE',  'N', 'NW', 'W',  'S')):
        imgFile = "/home/pi/code/watertanks/resources/compass_{0}.png".replace(
            '{0}', myWeather.wind_dir.lower())
        inkyphat.set_image(imgFile)

    printTitle("Tank")
    printText(1, "Sunrise:", mySunrise.sunrise.isoformat()[0:8], '')
    printText(2, "Sunset:", mySunrise.sunset.isoformat()[0:8], '')
    printText(3, "Water:", mySettings.settings["pumpduration"], 'min')
    temp_c = str(myWeather.temp_c)
    windchill_c = str(myWeather.windchill_c)
    printText(4, "Temp:", temp_c + 'c w/c ' + windchill_c, 'c')
    printText(5, "Weather:", myWeather.weather, '')
    wind_mph = str(myWeather.wind_mph)
    wind_gust_mph = str(myWeather.wind_gust_mph)
    printText(6, "Wind:",
              myWeather.wind_dir + " spd: " + wind_mph + 'g: ' + wind_gust_mph,
              '')

    inkyphat.show()  # And show it!
Пример #15
0
def displayStatus(statusString):
    # Prepare the String into two lines
    wrapped = textwrap.wrap(statusString, width=20)

    # Show the backdrop image
    inkyphat.set_colour(config["inkyphatConfig"]["colour"])
    inkyphat.set_border(inkyphat.RED)
    inkyphat.set_image("background.png")
    inkyphat.set_rotation(config["inkyphatConfig"]["rotation"])

    # Add the text
    font = ImageFont.truetype(inkyphat.fonts.FredokaOne, 21)

    # Title Line
    line_one = config["inkyphatConfig"]["line_one"]
    w, h = font.getsize(line_one)
    # Center the text and align it with the name strip
    x = (inkyphat.WIDTH / 2) - (w / 2)
    y = 18 - (h / 2)
    inkyphat.text((x, y), line_one, inkyphat.WHITE, font)

    if(len(wrapped) >= 1):
        # Status Line 1
        status_one = wrapped[0]
        w, h = font.getsize(status_one)
        # Center the text and align it with the name strip
        x = (inkyphat.WIDTH / 2) - (w / 2)
        y = 50 - (h / 2)
        inkyphat.text((x, y), status_one, inkyphat.BLACK, font)


    if(len(wrapped) >= 2):
        # Status Line 2
        status_two = wrapped[1]
        w, h = font.getsize(status_two)
        # Center the text and align it with the name strip
        x = (inkyphat.WIDTH / 2) - (w / 2)
        y = 80 - (h / 2)
        inkyphat.text((x, y), status_two, inkyphat.BLACK, font)


    inkyphat.show()
Пример #16
0
def main():
    fontSize = 16
    mySunrise = sunRiseSet() # Get sunrise and sunset from DB
    mySunrise.getSunriseset();
    
    myWeather  = weather()
    myWeather.getWeather()
    
    # Load the built-in FredokaOne font
    font = ImageFont.truetype(inkyphat.fonts.FredokaOne, fontSize)

    inkyphat.set_border(inkyphat.BLACK)
    
    inkyphat.text((0, fontSize * 0), "Tank", inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 1), "Sunrise: " + mySunrise.sunrise.isoformat(), inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 2), "Sunset: " + mySunrise.sunset.isoformat(), inkyphat.BLACK, font=font)
    inkyphat.text((0, fontSize * 3), "Weather: " + myWeather.weather, inkyphat.BLACK, font=font)
    
    # And show it!
    inkyphat.show()
Пример #17
0
def show_image(infile, temp_data=None, pressure_data=None, humidity_data=None):
    font = ImageFont.truetype("/usr/local/share/fonts/DejaVuSans.ttf", 14)

    temp_info = create_informatics(temp_data)
    press_info = create_informatics(pressure_data)
    humidity_info = create_informatics(humidity_data)

    inkyphat.set_image(Image.open(infile))
    inkyphat.text((110, 10), "{0:.1f}°F \n {1}".format(temp_data[-1],
                                                       temp_info),
                  inkyphat.BLACK, font)
    inkyphat.text((110, 40),
                  "{0:.0f} hPa \n {1}".format(pressure_data[-1], press_info),
                  inkyphat.BLACK, font)
    inkyphat.text((110, 70),
                  "{0:.0f} %RH \n {1}".format(humidity_data[-1],
                                              humidity_info), inkyphat.BLACK,
                  font)

    inkyphat.show()
Пример #18
0
def draw_weather():
    weather = get_weather()
    if weather == None:
        print 'No weather!'
        return

    if ROTATE_180 == True:
        inkyphat.set_rotation(180)
    # TODO configurable color
    inkyphat.set_colour('red')
    inkyphat.set_border(inkyphat.RED)

    # background
    inkyphat.rectangle((0, 0, inkyphat.WIDTH, inkyphat.HEIGHT), inkyphat.RED)

    # draw columns
    # (assuming get_weather has returned using NUM_COLS)
    for i in range(0, NUM_COLS):
        # draw time label
        time = weather['hours'][i]['time']
        w, h = timeFont.getsize(time)
        draw_shadowed_text(get_x(w, i), 4, time, timeFont)

        # draw icon
        try:
            # This could be optimized to not load the same file more than once
            img = Image.open('assets/' + weather['hours'][i]['icon'] + '.png')
            inkyphat.paste(img, (get_x(30, i), 22))
            # drawing icons without transparency as it didn't work with whatever gimp was producing
        except:
            print 'Error with icon:' + weather['hours'][i]['icon']

        # draw temperature label
        temp = weather['hours'][i]['temperature']
        w, h = temperatureFont.getsize(temp)
        draw_shadowed_text(get_x(w, i), 56, temp, temperatureFont)

    # TODO multiple lines if too long
    draw_shadowed_text(5, 84, weather['summary'], summaryFont)

    inkyphat.show()
Пример #19
0
    def mode1(self):

        # background image
        img = Image.open(self.config.background)
        inkyphat.set_image(img)

        # Add the price text
        font = ImageFont.truetype(self.font, 36)
        price = str("%.3f" % self.price)
        inkyphat.text((4, 5), price, inkyphat.RED, font)

        # Add the day change text
        font = ImageFont.truetype(self.font, 22)
        day = "%.2f" % self.day
        if self.day > 0.0:
            inkyphat.text((7, 42), str(day), inkyphat.BLACK, font)
        if self.day < 0.0:
            inkyphat.text((7, 42), str(day), inkyphat.RED, font)

        # Add the ROI as FIAT
        if self.config.show_roi == True:

            font = ImageFont.truetype(self.font, 34)
            roi = self.price * self.coin_amount
            roistr = str("%.2f" % roi)
            inkyphat.text((4, 75), roistr, inkyphat.WHITE, font)

        # Add the ROI as percentage
        else:

            actual_value = self.price * self.coin_amount
            percentage = (actual_value / self.coin_invest * 100) - 100
            font = ImageFont.truetype(self.font, 34)
            roistr = str("%.2f" % percentage + '%')
            inkyphat.text((4, 75), roistr, inkyphat.WHITE, font)

        inkyphat.show()
Пример #20
0
    def mode2(self):

        # background image
        img = Image.open(self.config.back_simple)
        inkyphat.set_image(img)

        # Add ranking text
        font = ImageFont.truetype(self.font, 22)
        inkyphat.text((45, 5), "#" + self.rank, inkyphat.WHITE, font)

        # Add the price text
        font = ImageFont.truetype(self.font, 46)
        price = str("%.3f" % self.price)
        inkyphat.text((44, 25), price, inkyphat.WHITE, font)

        # Add the day change text
        font = ImageFont.truetype(self.font, 22)
        day = "%.2f" % self.day
        if self.day > 0.0:
            inkyphat.text((46, 62), "24h: " + str(day) + "%", inkyphat.WHITE,
                          font)
        if self.day < 0.0:
            inkyphat.text((46, 62), "24h: " + str(day) + "%", inkyphat.RED,
                          font)

        # Add the week change text
        font = ImageFont.truetype(self.font, 22)
        week = "%.2f" % self.week
        if self.week > 0.0:
            inkyphat.text((47, 82), "7d: " + str(week) + "%", inkyphat.WHITE,
                          font)
        if self.week < 0.0:
            inkyphat.text((47, 82), "7d: " + str(week) + "%", inkyphat.RED,
                          font)

        inkyphat.show()
Пример #21
0
def viv_display(th, tr, tc, hh):  # display readinga and any alerts on inkyphat
    #logger.debug("Setting inkyphat")
    iclear(0)

    # load background image
    inkyphat.set_image(Image.open("/home/pi/snake-back.png"))
    # set font sizes
    font = ImageFont.truetype(inkyphat.fonts.FredokaOne, 28)
    smallfont = ImageFont.truetype(inkyphat.fonts.FredokaOne, 10)
    midfont = ImageFont.truetype(inkyphat.fonts.FredokaOne, 16)

    # Top left box for hot-end temp
    inkyphat.rectangle([2, 2, 70, 25], fill=inkyphat.BLACK, outline=1)
    inkyphat.rectangle([2, 2, 70, 70], fill=None, outline=1)  #top left
    message = "HOT"
    inkyphat.text((20, 3), message, inkyphat.WHITE, midfont)
    if th > 28 and th < 31:
        inkyphat.text((8, 25), str(th), inkyphat.BLACK, font)
    else:
        inkyphat.text((8, 25), str(th), inkyphat.RED, font)

    #Middle box for roof temp
    inkyphat.rectangle([74, 2, 142, 25], fill=inkyphat.BLACK,
                       outline=1)  # top middle
    inkyphat.rectangle([74, 2, 142, 70], fill=None, outline=1)
    message = "ROOF"
    inkyphat.text((88, 3), message, inkyphat.WHITE, midfont)
    if tr > 34 and tr < 37:
        inkyphat.text((81, 25), str(tr), inkyphat.BLACK, font)
    else:
        inkyphat.text((81, 25), str(tr), inkyphat.RED, font)

    # Right box for cool end temp
    inkyphat.rectangle([146, 2, 210, 25], fill=inkyphat.BLACK,
                       outline=1)  # top middle
    inkyphat.rectangle([146, 2, 210, 70], fill=None, outline=1)
    message = "COOL"
    inkyphat.text((156, 3), message, inkyphat.WHITE, midfont)
    if tc > 21 and tc < 27:
        inkyphat.text((152, 25), str(tc), inkyphat.BLACK, font)
    else:
        inkyphat.text((152, 25), str(tc), inkyphat.RED, font)

    # Bottom left box for humidity
    inkyphat.rectangle([12, 74, 55, 100], fill=inkyphat.BLACK,
                       outline=1)  # top middle
    inkyphat.rectangle([12, 74, 102, 100], fill=None, outline=1)
    message = "Hum"
    inkyphat.text((16, 80), message, inkyphat.WHITE, midfont)
    if hh > 20 and hh < 75:
        inkyphat.text((62, 78), str(hh) + "%", inkyphat.BLACK, midfont)
    else:
        inkyphat.text((62, 78), str(hh) + "%", inkyphat.RED, midfont)

    # Bottom middle for time
    rightnow = dt.now()
    inkyphat.text((110, 70),
                  str("%02d" % (rightnow.hour, )) + ":" +
                  str("%02d" % (rightnow.minute, )), inkyphat.RED, font)

    #print("Displaying on inkyphat")
    inkyphat.show()
Пример #22
0
def iclearNow(col):  # claer inkyphat and refresh
    for x in range(212):
        for y in range(104):
            inkyphat.putpixel((x, y), col)
    inkyphat.show()
Пример #23
0
def text(text, colour):
    w, h = font.getsize(text)
    x = (inkyphat.WIDTH / 2) - (w / 2)
    y = (inkyphat.HEIGHT / 2) - (h / 2)
    inkyphat.text((x, y), text, colour, font)
    inkyphat.show()
Пример #24
0
 def show_slideshow(self, delay=30):
     for image in self.standing_images():
         inkyphat.set_image(image)
         inkyphat.show()
         time.sleep(delay)
Пример #25
0
def printQRcode(text):
    inkyphat.clear()
    qr.add_data("http://128.143.67.97:44104/link_your_id/" + text)
    qr.make(fit=True)
    qr.make_image()
    inkyphat.show()
    def on_status(self, tweet):

        tweet_to_check = tweet.text  # checks the tweet

        does_the_tweet_contain_key_word = tweet_to_check.find(
            "@Dan_Aldred")  ### find MENTIONS replace with your Twitter handle
        does_the_tweet_contain_STAR_WARS = tweet_to_check.find(
            "#StarWars")  ### find star wars hash tag

        print(does_the_tweet_contain_key_word)

        try:
            if does_the_tweet_contain_key_word >= 0:

                user = tweet.user.screen_name  #gets the user name
                print(user)  ###prints the user's name

                # responds to a mention @dan_aldred
                inkyphat.set_image(Image.open("/home/pi/StarWars/MENTION.png"))
                inkyphat.show()
                inkyphat.clear()

                ###### display message ####
                print(tweet_to_check)
                message = tweet_to_check
                txt = textwrap.fill(message, 31)
                w, h = inkyphat._draw.multiline_textsize(txt, font)
                x = (inkyphat.WIDTH / 2) - (w / 2)
                y = (inkyphat.HEIGHT / 2) - (h / 2)
                inkyphat._draw.multiline_text((x, y), txt, inkyphat.BLACK,
                                              font)
                inkyphat.show()

                time.sleep(2)
                inkyphat.clear()

            ### STAR WARS response
            elif does_the_tweet_contain_STAR_WARS >= 0:
                ### display SW intro picture ###
                print("star wars picture")
                print("star wars rleated tweet")
                inkyphat.set_image(Image.open("/home/pi/StarWars/STAR.png"))
                inkyphat.show()
                time.sleep(1)
                inkyphat.clear()

                # SHOW MESSAGE
                print(tweet_to_check)
                message = tweet_to_check
                txt = textwrap.fill(message, 31)
                w, h = inkyphat._draw.multiline_textsize(txt, font)
                x = (inkyphat.WIDTH / 2) - (w / 2)
                y = (inkyphat.HEIGHT / 2) - (h / 2)
                inkyphat._draw.multiline_text((x, y), txt, inkyphat.BLACK,
                                              font)
                inkyphat.show()

                time.sleep(10)
                inkyphat.clear()

            else:

                inkyphat.clear()
                pass

        except:  ### if there is an emoji and the tweet cannot be displayed
            print("Cannot render tweet")
            inkyphat.set_image(Image.open("/home/pi/StarWars/FAIL.png"))
            inkyphat.show()
            time.sleep(1)
            inkyphat.clear()
Пример #27
0
def image(file):
    inkyphat.clear()
    inkyphat.set_colour('red')
    inkyphat.set_image(Image.open(file))
    inkyphat.show()
Пример #28
0
    parser = SafeConfigParser()
    parser.read('/etc/pithermostat.conf')
    redishost=parser.get('redis','broker')
    redisport=int(parser.get('redis','port'))
    redisdb=parser.get('redis','db')
    redistimeout=float(parser.get('redis','timeout'))
    room_location = parser.get('locale','location')
    redthis=redis.StrictRedis(host=redishost,
                              port=redisport,  
                              db=redisdb, 
                              socket_timeout=redistimeout)
except:
    import inkyphat
    inkyphat.set_border(inkyphat.BLACK)
    inkyphat.text((36, 12), "No WiFi", inkyphat.WHITE, font=font)
    inkyphat.show()
    exit("Unable to read from /etc/pithermostat.conf")

try:
    import requests
except ImportError:
    exit("This script requires the requests module\nInstall with: sudo pip install requests")

import inkyphat


inkyphat.set_border(inkyphat.BLACK)

CITY = "Bradford"
COUNTRYCODE = "GB"
WARNING_TEMP = 30.0
Пример #29
0
def refresh():
    get_temp()
    draw_therm()
    fill_up()
    decorate()
    inkyphat.show()
Пример #30
0
    circle_x1 = MARGIN + right_offset
    circle_y1 = text_y + 2 - magic
    circle_x2 = MARGIN + FONT_SIZE - 2 + right_offset
    circle_y2 = text_y + FONT_SIZE - magic
    circle_fill = config['BACKGROUND_COLOR']

    if stream['online']:
        circle_fill = config['FOREGROUND_COLOR']
        viewers = str(stream['viewers'])
        viewers_text_w, viewers_text_h = fnt.getsize(viewers)
        viewers_x = right_offset - MARGIN - viewers_text_w
        viewers_y = text_y
        inkyphat.text((viewers_x, viewers_y),
                      viewers,
                      font=fnt,
                      fill=config['FOREGROUND_COLOR'])

    inkyphat.ellipse((circle_x1, circle_y1, circle_x2, circle_y2),
                     fill=circle_fill,
                     outline=config['FOREGROUND_COLOR'])
    inkyphat.text((text_x, text_y),
                  stream['channel'].upper(),
                  font=fnt,
                  fill=config['FOREGROUND_COLOR'])
    index += 1

print 'Printing...'
inkyphat.show()
print 'Done!'
Пример #31
0
with io.BytesIO() as f:
    fig.savefig(f,
                dpi=dpi,
                cmap="bwr",
                interpolation="none",
                origin="lower",
                pad_inches=0)  #bbox_inches='tight')
    f.seek(0)
    i = Image.open(f)  #.convert('P', palette=(0,1,2))
    d = ImageDraw.Draw(i)
    ypos = 0 if ymax - last_high > last_low - ymin else h - 6

    if not args.output:
        from inkyphat import RED, BLACK, text, set_image, set_rotation, show
        set_image(i)
        if args.flip:
            set_rotation(180)
    else:
        RED = (255, 0, 0)
        BLACK = (0, 0, 0)
        text = d.text

    text((148, ypos), '{:.2f}'.format(last_close), BLACK, font)
    text((176, ypos), args.pair, RED, font)

    if args.output:
        i.save(args.output)
        raise SystemExit

    show()