-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnycscreen.py
42 lines (36 loc) · 1.32 KB
/
nycscreen.py
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
import time
import sys
import json
import urllib.request
import Adafruit_SSD1306
from PIL import Image, ImageDraw, ImageFont
import RPi.GPIO as GPIO
display = Adafruit_SSD1306.SSD1306_128_64(rst=None)
# download raw json object
url = "set explorer/api url here with YOUR address"
data = urllib.request.urlopen(url).read().decode()
# parse json object
obj = json.loads(data)
print("balance:" + obj["balance"])
#tutti i cazzi del display:
balance = obj["balance"]
title = "NewYorkCoin"
by = "By CryptoLover705"
text = "Balance:"
# Setup
display.begin() # initialize graphics library for selected display module
display.clear() # clear display buffer
display.display() # write display buffer to physical display
displayWidth = display.width # get width of display
displayHeight = display.height # get height of display
image = Image.new('1', (displayWidth, displayHeight)) # create graphics library image buffer
draw = ImageDraw.Draw(image) # create drawing object
font = ImageFont.load_default() # load and set default font
draw.text((40,2), title, fill=655)
draw.text((40,25), text, fill=655)
draw.text((25,35), balance, fill=655)
draw.text((25,53), by, fill=655)
display.image(image) # set display buffer with image buffer
display.display() # write display buffer to physical display
# Cleanup
GPIO.cleanup() # release all GPIO resources