Exemple #1
0
def showtime():
    global debug
    global fourchar_flag
    global fourchar_payload

    # old logic actually worked, to a point
    fourchar_flag = False
    str_time = time.strftime("%H%M")
    flp.print_number_str(str_time)
    if int(time.time()) % 2 == 0:
        flp.set_decimal(1, 1)
    else:
        flp.set_decimal(1, 0)
    flp.show()
    time.sleep(0.1)
    # new logic
    #    flp.print_str("    ")
    #    flp.show
    #    float_temp = float(fourchar_payload)
    #    flp.print_float(float_temp, decimal_digits=1, justify_right=True)
    #    flp.show()
    #    time.sleep(2)

    # old logic
    if fourchar_flag == True:
        flp.print_str("    ")
        flp.show
        float_temp = float(fourchar_payload)
        flp.print_float(float_temp, decimal_digits=1, justify_right=True)
        flp.show()
        time.sleep(2)
Exemple #2
0
def display_message(titles,
                    numbers,
                    show_title_at_end=False,
                    number_type='str',
                    float_decimal_digits=1,
                    number_sleep=1,
                    title_sleep=.5):
    """Display messaages with different timings for titles vs numbers."""

    for title in titles:
        flp.clear()
        flp.print_str(title)
        flp.show()
        time.sleep(title_sleep)

    for number in numbers:
        flp.clear()
        flp.print_number_str(str(number))
        flp.show()
        time.sleep(number_sleep)

    if (show_title_at_end):
        for title in titles:
            flp.clear()
            flp.print_str(title)
            flp.show()
            time.sleep(title_sleep)
Exemple #3
0
def scroll_print_float_str(strn, interval=0.3):
    if (len(strn) > 0):
        time.sleep(interval * 3.0)

        for ln in [
                strn[x:x + 5] if ('.' in strn[x:x + 5]) else strn[x:x + 4]
                for x in xrange(0,
                                len(strn) - 3)
        ]:
            if (ln[0] != '.'):
                flp.print_number_str(ln)
                flp.show()
                time.sleep(interval)

        time.sleep(interval * 2.0)
Exemple #4
0
def monitor(url):
    response = requests.get(url)
    status_code = response.status_code

    fourletterphat.clear()

    fourletterphat.print_str(str(status_code))
    fourletterphat.show()
    time.sleep(5)

    fourletterphat.scroll_print(str(status_code) + ' ' + url + ' ' + str(status_code), 0.1 if (200 == status_code) else 1 )

    fourletterphat.print_number_str(str(status_code))
    fourletterphat.show()
    time.sleep(5)

    fourletterphat.clear()
Exemple #5
0
		current_condition = "C"
    elif current_condition == "Mist":
        current_condition = "M"
    elif current_condition == "Clouds":
        current_condition = "C"
    elif current_condition in ("Haze", "Fog"):
        current_condition = "H"
    elif current_condition in ("Dust"):
        current_condition = "D"
    elif current_condition in ("Tornado"):
        current_condition = "T"
	else: 
		current condition = "F" #Farenheit default
	#str_current_temp = "%s F" %(current_temp)
	str_current_temp = "%s %s" %(current_temp, current_condition)
	flp.print_number_str(str_current_temp)
	flp.show()
	time.sleep(900)


'''
#Auto start .py file on rPi boot
[Unit]
Description=My service
After=network.target

[Service]
ExecStart=/usr/bin/python3 -u flp.py
WorkingDirectory=/home/pi         
StandardOutput=inherit
StandardError=inherit
Exemple #6
0
words = ["AHOY", "YARR", "GROG"]
spinner = ["|", "/", "-", "\\"]

while True:
    for w in words:
        flp.clear()
        flp.print_str(w)
        flp.show()
        time.sleep(1)

    for i in range(4):
        for s in spinner:
            # Take the single character from the spinner and repeat it 4 times
            # This is a little weird because: 2 * 4 = 8
            # But "|" * 4 = "||||"
            # And "/" * 4 = "////"
            # etc.
            s = s * 4

            # Display our new 4 character long spinner
            flp.clear()
            flp.print_str(s)
            flp.show()
            time.sleep(1 / 16.0)

    # Count up to 9999 in increments of 25
    for i in range(0, 10000, 25):
        flp.clear()
        flp.print_number_str(str(i))
        flp.show()
        time.sleep(1 / 10000.0)
Exemple #7
0
def main(stdscr):
    # Clear screen
    s = State()
    seq = 0
    x = None
    stdscr.clear()
    stdscr.nodelay(1) # set getch() non-blocking
    s.message = "Tea?"
    quit = False
    flp.clear()
    flp.print_number_str('OHIO')
    flp.show()
    while not quit:
        v = stdscr.getch()
        if v != -1:
            if v >= ord('0') and v <= ord('9') and v-ord('0') in lookup:
               s.current_tea_index = v-ord('0')
               tea = lookup[s.current_tea_index]
               s.message = "{} ready in ????".format(tea)
               s.message_timeout = 120
               s.time_brewing_started = time.localtime()
               s.brewing = True
               s.reset_scroll()
            if v == curses.KEY_BACKSPACE:
                # Cancel
                s.message = "CANC"
                s.current_tea_index = None
                s.message_timeout = 20
                s.time_brewing_started = None
                s.brewing = False
                s.reset_scroll()
            x = v

        # Update curses display for debugging
        stdscr.addstr(0,0,"Last keypress: {}".format(x))
        stdscr.addstr(1,0,"Scrolling message: >{}<".format(s.message))
        stdscr.addstr(2,0,"Scroll position: >{}<".format(s.get_scroll_pos()))
        stdscr.addstr(3,0,"Message timeout: {}".format(s.message_timeout))
        if s.time_brewing_started:
            stdscr.addstr(4,0,"Brewing started: {}:{}:{}".format(s.time_brewing_started.tm_hour, s.time_brewing_started.tm_min, s.time_brewing_started.tm_sec))
            stdscr.addstr(5,0,"Brewing started: {}s".format(time.mktime(s.time_brewing_started)))
        else:
            stdscr.addstr(4,0,"Nothign brewing")
        stdscr.addstr(6,0,"Time now : {}s".format(time.mktime(time.localtime())))

        # Update tea time, if currently brewing
        if s.time_brewing_started:
            elapsed = time.mktime(time.localtime()) - time.mktime(s.time_brewing_started)
            remaining = int(TEA_BREWING_TIME-elapsed)
            if remaining > 0:
                s.message = s.message [:-4] + "{:1d}m{:02d}".format(int(remaining/60), remaining%60)
            else:
                if s.brewing:
                    s.reset_scroll()
                s.brewing = False
                tea = lookup[s.current_tea_index]
                s.message = "{} {:3d}m".format(tea, int((elapsed - TEA_BREWING_TIME)/60))

            if elapsed > MAX_TEA_AGE:
                s.time_brewing_started = None
                s.current_tea_index = None
                s.brewing = False
                s.message = "Tea?"                
                s.reset_scroll()

        # Update four-letter display
        if s.message_timeout > 0:
            flp.clear()
            if s.message:
                flp.print_str(s.message[s.get_scroll_pos():])
                if seq % 5 == 0 and s.scroll_position < len(s.message)-4:
                    s.scroll_position += 1
            flp.show()
            s.message_timeout -= 1
        else:
            if s.current_tea_index:
                s.reset_scroll()
                s.message_timeout = 120
            else:
                flp.clear()
                s.message = "Tea?"                
                flp.print_str(s.message)
                flp.show()
        seq += 1
        time.sleep(0.1)
Exemple #8
0
import os, time
import fourletterphat as flp

pipe_path = "/tmp/countpipe"
if not os.path.exists(pipe_path):
    os.mkfifo(pipe_path)

# Open the fifo. We need to open in non-blocking mode or it will stalls until
# someone opens it for writting
pipe_fd = os.open(pipe_path, os.O_RDONLY)
with os.fdopen(pipe_fd) as pipe:
    while True:
        message = pipe.read()
        if message:
            flp.print_number_str(message)
            flp.show()
Exemple #9
0
spinner = ["|", "/", "-", "\\"]

while True:
    for w in words:
        fourletterphat.clear()
        fourletterphat.print_str(w)
        fourletterphat.show()
        time.sleep(1)

    for i in range(4):
        for s in spinner:
            # Take the single character from the spinner and repeat it 4 times
            # This is a little weird because: 2 * 4 = 8
            # But "|" * 4 = "||||"
            # And "/" * 4 = "////"
            # etc.
            s = s * 4

            # Display our new 4 character long spinner
            fourletterphat.clear()
            fourletterphat.print_str(s)
            fourletterphat.show()
            time.sleep(1 / 16.0)

    # Count up to 9999 in increments of 25
    for i in range(0, 10000, 25):
        fourletterphat.clear()
        fourletterphat.print_number_str(str(i))
        fourletterphat.show()
        time.sleep(1 / 10000.0)
Exemple #10
0
    elif BTC_str[0:2] == '29':
      BTC_str_hex= 'T'
    elif BTC_str[0:2] == '30':
      BTC_str_hex= 'U'
    elif BTC_str[0:2] == '31':
      BTC_str_hex= 'V'
    elif BTC_str[0:2] == '32':
      BTC_str_hex= 'W'
    elif BTC_str[0:2] == '33':
      BTC_str_hex= 'X'
    elif BTC_str[0:2] == '34':
      BTC_str_hex= 'Y'
    elif BTC_str[0:2] == '35':
      BTC_str_hex= 'Z'   
    BTC_str_dec= BTC_str[2:5] #Last 3 digits left as decimal
    BTC_str= BTC_str_hex + BTC_str_dec
    fourletterphat.print_str(BTC_str)
  else:
    fourletterphat.print_number_str(BTC_in_USD)
  '''

    fourletterphat.print_number_str(BTC_in_USD)

    pixel_list = make_rise_fall_list(BTC_in_USD)
    for num in range(num_of_pixels):
        ledshim.set_pixel(num, *pixel_list[num])

    fourletterphat.show()
    ledshim.show()
    sleep(wait_secs)
def download_blob(bucketName, sourceBlobName, destinationFileName):
    """Downloads a blob from the bucket."""
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucketName)
    blob = bucket.blob(sourceBlobName)

    blob.download_to_filename(destinationFileName)


download_blob(bucketName, sourceBlobName, destinationFileName)

#convert csv values into variables

with open('/home/pi/temperatuur/latest.csv', mode='r') as latest:
    csv_reader = csv.DictReader(latest)
    for row in csv_reader:
        temperature = int(round(float(row["temperature"])))
        humidity = int(round(float(row["humidity"])))

#   for row in csv_reader:
#     print(row["temperature"])

#display temperature and humidity

display_value = str(temperature) + str(humidity)

flp.print_number_str(display_value)
flp.show()
time.sleep(870)
Exemple #12
0
#!/usr/bin/env python

import time
import fourletterphat

print("""
Four Letter pHAT: clock.py

This example will display a simple HH/MM clock,
with a blinking decimal point to indicate seconds.

Press Ctrl+C to exit.
""")

while True:
    fourletterphat.clear()

    str_time = time.strftime("%H%M")

    # Display the time
    fourletterphat.print_number_str(str_time)

    # Blink the middle decimal point
    # int(time.time() % 2) will alternate 1 0 1 0
    # which we can use to directly set the point
    fourletterphat.set_decimal(1, int(time.time() % 2))

    fourletterphat.show()
    time.sleep(0.1)