Skip to content

Commit c339c4d

Browse files
authored
Merge branch 'master' into patch-10
2 parents 585c5de + 9531f0a commit c339c4d

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Bitcoin_Matrix/bitcoin_background.bmp

6.05 KB
Binary file not shown.

Bitcoin_Matrix/bitcoin_matrix.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Run on Metro M4 Airlift w RGB Matrix shield and 64x32 matrix display
2+
# show current value of Bitcoin in USD
3+
4+
import time
5+
import board
6+
import terminalio
7+
from adafruit_matrixportal.matrixportal import MatrixPortal
8+
9+
# You can display in 'GBP', 'EUR' or 'USD'
10+
CURRENCY = "USD"
11+
# Set up where we'll be fetching data from
12+
DATA_SOURCE = "https://api.coindesk.com/v1/bpi/currentprice.json"
13+
DATA_LOCATION = ["bpi", CURRENCY, "rate_float"]
14+
15+
16+
def text_transform(val):
17+
if CURRENCY == "USD":
18+
return "$%d" % val
19+
if CURRENCY == "EUR":
20+
return "‎€%d" % val
21+
if CURRENCY == "GBP":
22+
return "£%d" % val
23+
return "%d" % val
24+
25+
26+
# the current working directory (where this file is)
27+
cwd = ("/" + __file__).rsplit("/", 1)[0]
28+
29+
matrixportal = MatrixPortal(
30+
url=DATA_SOURCE,
31+
json_path=DATA_LOCATION,
32+
status_neopixel=board.NEOPIXEL,
33+
default_bg=cwd + "/bitcoin_background.bmp",
34+
debug=True,
35+
)
36+
37+
matrixportal.add_text(
38+
text_font=terminalio.FONT,
39+
text_position=(27, 16),
40+
text_color=0x3d1f5c,
41+
text_transform=text_transform,
42+
)
43+
matrixportal.preload_font(b"$012345789") # preload numbers
44+
matrixportal.preload_font((0x00A3, 0x20AC)) # preload gbp/euro symbol
45+
46+
while True:
47+
try:
48+
value = matrixportal.fetch()
49+
print("Response is", value)
50+
except (ValueError, RuntimeError) as e:
51+
print("Some error occured, retrying! -", e)
52+
53+
time.sleep(3 * 60) # wait 3 minutes

Clue_Step_Counter/clue_step_counter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from adafruit_clue import clue
55
from simpleio import map_range
66
from adafruit_bitmap_font import bitmap_font
7-
from adafruit_lsm6ds import LSM6DS33, Rate, AccelRange
7+
from adafruit_lsm6ds.lsm6ds33 import LSM6DS33
8+
from adafruit_lsm6ds import Rate, AccelRange
89
from adafruit_progressbar import ProgressBar
910
from adafruit_display_text.label import Label
1011

0 commit comments

Comments
 (0)