-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitcoinMatrix.py
More file actions
64 lines (48 loc) · 1.64 KB
/
Copy pathbitcoinMatrix.py
File metadata and controls
64 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
import re
import time
import json, requests
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT
def jsonreq(url):
req = requests.get(url).text
jsonreq = json.loads(req)
return jsonreq
def display_matrix():
#Defaults
url = "https://mempool.space/"
display_list = []
# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=4, block_orientation=-90,
rotate=0, blocks_arranged_in_reverse_order=False)
print("Created device")
#Continuous loop
while True:
#fees
req = jsonreq(url+"/api/v1/fees/recommended")
msg_fast = 'Fast: '+str(req["fastestFee"])
display_list.append(msg_fast)
msg_30 = "Mid: " + str(req["halfHourFee"])
display_list.append(msg_30)
msg_1h = "Slow: " + str(req["hourFee"])
display_list.append(msg_1h)
#Blockchain data
req = jsonreq(url+"/api/blocks/tip/height")
print(req)
height = "Height: " + str(req)
display_list.append(height)
for item in display_list:
print(item)
show_message(device, item, fill="white", font=proportional(TINY_FONT))
#Clear list for next query
display_list = []
if __name__ == "__main__":
try:
display_matrix()
except KeyboardInterrupt:
pass