Example #1
0
def display_state(rpi_id, pidi_status_dir):
    global last_state

    try:
        dir_file_list = os.listdir(pidi_status_dir)
    except FileNotFoundError:
        flp.scroll_print('ERROR - REMOTE DIR NOT FOUND!')
        return
    except PermissionError:
        flp.scroll_print('ERROR - REMOTE DIR NOT PERMITTED!')
        return

    instructions = get_device_instructions(rpi_id, dir_file_list)
    if not instructions:
        if last_state is None:
            flp.scroll_print('ERROR - FILE FOR THIS RASPBERRY NOT FOUND!')
            return
        else:
            instructions = [last_state]

    if len(instructions) > 1:
        flp.scroll_print('ERROR - TOO MANY INSTRUCTIONS')
        return

    instr = instructions[0]
    flp.print_str(instr)
    flp.show()

    rename_instruction(rpi_id, instr, pidi_status_dir)
    last_state = instr
Example #2
0
def main():
    global last_state
    last_state = None

    rpi_id = constants.rpi_id
    pidi_status_dir = constants.pidi_status_dir

    flp.clear()

    flp.scroll_print("START")
    time.sleep(2)

    while True:
        display_state(rpi_id, pidi_status_dir)
        time.sleep(2)
Example #3
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()
Example #4
0
def time_string():
	return time.strftime("%H%M")







while True:
	flp.clear()
	try:
		if (time.strftime("%S") == "00"):
			ctr = 1
			str_time = full_string()

			flp.scroll_print(str_time,0.5)
		else:

			str_time = time_string()
			flp.print_number_str(str_time)
			flp.set_decimal(1, int(time.time() % 2))
			flp.show()
			time.sleep(0.1)
	except:
		print('Error at{}'.format(full_string))# if exception 1 raised do this



Example #5
0
import speedtest
import fourletterphat as flp

servers = []

flp.scroll_print("STARTING TEST")
flp.show()

s = speedtest.Speedtest()
s.get_servers(servers)
s.get_best_server()

flp.print_str("DOWN")
flp.show()

s.download()

flp.print_str("UP")
flp.show()

s.upload()

result = s.results

down_mb = result.download / 1024 / 1024
up_mb = result.upload / 1024 / 1024

print("Download: " + "{:.2f}".format(down_mb))
print("Download: " + "{:.2f}".format(up_mb))
Example #6
0
#!/usr/bin/env python

import fourletterphat as flp

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

This example will scroll a message at different speeds.

Press Ctrl+C to exit.
""")

while True:
    flp.clear()
    flp.scroll_print("DEFAULT SCROLLING SPEED")
    flp.scroll_print("1 SECOND PERIOD SCROLLING", 1)
    flp.scroll_print("1/10 SECOND PERIOD SCROLLING", 0.1)
Example #7
0
  flp.print_str('SCAN')
  flp.show()

  camera.capture('image.jpg')

  print("Picture taken")

  result = decode(Image.open('image.jpg'))

  if len(result) > 0:
    print("Found QR Code")

    qr_code = result[0].data.decode("utf-8")
    print(qr_code)
    flp.scroll_print(qr_code.upper(), tempo=0.11)

    if len(qr_code) > 0:
        if qr_code[3] == ":":
           qr_code = qr_code[4:]

    #send_xrb(qr_code)

    print("Insert Coins")

    flp.print_str('GO!')
    flp.show()

    #Here we can count coins
    start_time = time.time() + timeout
    GPIO.add_event_detect(channel1, GPIO.RISING)
Example #8
0
#!/usr/bin/env python

import fourletterphat

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

This example will scroll a message at different speeds.

Press Ctrl+C to exit.
""")

while True:
    fourletterphat.clear()
    fourletterphat.scroll_print("DEFAULT SCROLLING SPEED")
    fourletterphat.scroll_print("1 SECOND PERIOD SCROLLING", 1)
    fourletterphat.scroll_print("1/10 SECOND PERIOD SCROLLING", 0.1)