Пример #1
0
     first_run = False
     diff = 2.0
 if diff < 1.5:
     time.sleep(2)
     continue
 tunnel_up = False
 wifi_up = False
 try:
     result = subprocess.check_output('/sbin/iwgetid -r', shell=True)
     disp_text = 'wifi- ' + str(result.decode('utf-8'))
     wifi_up = True
 except:
     disp_text = 'wifi- Please Configure'
 finally:
     if console_display: print(disp_text)
     text.RemoveText("wifi")
     text.AddText(disp_text,
                  0,
                  vert_spacing * 1,
                  font_size,
                  Id="wifi",
                  invert=inv)
 for ifaceName in interfaces():
     if ifaceName == "lo": continue
     addresses = [
         i['addr'] for i in ifaddresses(ifaceName).setdefault(
             AF_INET, [{
                 'addr': 'No IP addr'
             }])
     ]
     if ifaceName == "tun0":
Пример #2
0
def main():
    # TODO: load config from somewhere - config.py? Path from environment variable?
    # TODO: concept of ... pages? tabs? that are loaded in and registered.
    # TODO: instead of trying to use the tiny buttons on the papirus, is there
    #       like a row of 5 keyboard keys? maybe nice cherry switches.

    # TODO: Parameterize lat/long in config; this is Ann Arbor, MI.
    latitude = 42.22
    longitude = -83.74

    timezone = tzlocal()

    rotation = 180
    text = PapirusTextPos(autoUpdate=False, rotation=rotation)

    # TODO: Bitmap support requires using PapirusComposite instead of
    #       PapirusTextPos.
    text.AddText("Today is", 0, 0, size=17, Id="date")
    text.AddText("Startup...", 93, 20, size=19, Id="startup")
    text.AddText("\u2600rise:", 0, 35, size=23, Id="sunrise_label")
    text.AddText("\u2600set:", 0, 57, size=23, Id="sunset_label")
    text.AddText("", 87, 35, size=23, Id="sunrise")
    text.AddText("", 87, 57, size=23, Id="sunset")
    text.AddText("Temp", 0, 80, size=14, Id="temp")
    text.WriteAll()

    text.RemoveText("startup")

    first_display = True
    while True:
        today = datetime.date.today()

        # TODO: Accommodate lack of sunrise/sunset like as far north as
        #       Utqiaġvik - the city formerly known as Barrow, Alaska.
        #       get_sunrise_sunset() returns those as None.
        sunrise_time, sunset_time = get_sunrise_sunset(latitude, longitude,
                                                       today, timezone)

        text.UpdateText("date",
                        "Today is {}".format(today.strftime("%A, %Y-%m-%d")))
        text.UpdateText("sunrise", sunrise_time.strftime("%I:%M %p"))
        text.UpdateText("sunset", sunset_time.strftime("%I:%M %p"))
        # For testing the longest English day name.
        #text.UpdateText("date", "Today is {}".format(today.strftime("Wednesday, %Y-%m-%d")))

        text.UpdateText(
            "temp",
            "Temp {}".format(get_temperature_forecast(latitude, longitude)))

        # Do a partial update on startup, and a full update each following hour.
        text.WriteAll(first_display)
        first_display = False

        # Wait until the next hour.
        now = datetime.datetime.now()
        next_hour = (now + datetime.timedelta(hours=1)).replace(microsecond=0,
                                                                second=0,
                                                                minute=0)
        wait_seconds = (next_hour - now).total_seconds()
        print("waiting {} seconds until next hour".format(wait_seconds))
        time.sleep(wait_seconds)
Пример #3
0
    weekday = date.today()
    day_Name = date.strftime(weekday, '%A')
    day_month_year = date.strftime(weekday, '%Y %b %-d')

    weekday2 = datetime.date.today() + datetime.timedelta(days=1)
    day2 = date.strftime(weekday2, '%A')

    try:
        screen.clear()
        print("Summary: "+currentCondFormatted+"\nTemperture: "+temp+" ")
        text.AddText((day_Name) + ' ' + (day_month_year), 0, 0, 18, Id="Line1", fontPath='/home/pi/weather-pi-data/fonts/Roboto-Black.ttf')
        text.AddText((temp) + ' ' + (humidity) + '\n' + (tempsToday), 0, 19, 14, Id="Line2", fontPath='/home/pi/weather-pi-data/fonts/Roboto-Bold.ttf')
        text.AddText((daily_conditions) + '\n' + (day2) + ' - ' + (tempsTomorrow) + ' ' + (summary2), 0, 53, 10, Id="Lin3", fontPath='/home/pi/weather-pi-data/fonts/ElecSign.ttf')

    except:
        text.UpdateText("Line1", "Connection Error!")

try:
    while True:
        display()
        sleep(300)  # 5 minutes
        text.Clear()
except (KeyboardInterrupt, SystemExit):
    text.RemoveText("Line2")
    text.RemoveText("Line3")
    screen.clear()
    text.UpdateText("Line1", "Exiting...\nGoodbye!")
    sleep(2)
    screen.clear()
    os._exit(1)