Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bitcoin price checker for Pimoroni Four Letter Phat / Raspberry Pi
import time
import string
from random import randint
import random
import fourletterphat as flp
import urllib2
import json
# String of numbers for display to cycle while loading. Can be any letters/numbers. It's random.
numbers = "1234567890"
while True:
# End time - number at end (2) is seconds for loading screen (random numbers) to show
t_end = time.time() + 2
while time.time() < t_end:
flp.set_digit(0, random.choice(numbers))
flp.set_digit(1, random.choice(numbers))
flp.set_digit(2, random.choice(numbers))
flp.set_digit(3, random.choice(numbers))
# Sleep for 0.05 seconds before choosing more random numbers
data = urllib2.urlopen("").read()
dataJSON = json.loads(data)
price = dataJSON["last"]
# Convert full number to XX.Xk
flp.set_digit(0, price[0])
flp.set_digit(1, price[1])
flp.set_digit(2, price[2])
# Display "K" (thousand) as 4th digit
flp.set_digit(3, "K")
# Show decimal
flp.set_decimal(1, True)
# Sleep for 500 seconds, then refresh it all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment