Toggle Navigation
Hatchery
Eggs
Bitcoin Wallet
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import wifi, display, time, badge, urequests #from bitcoin_wallet import pyqrnative from bitcoin_wallet import uQR api = 'https://www.bitstamp.net/api/v2/ticker/btcusd' def clearscreen(): display.drawFill(0xFFFFFF) display.flush() def wifi_up(): while not wifi.status(): time.sleep(4) wifi.connect() print("!") pass return wifi.status() def render(thing): # up to level 27 (125x125px) can be displayed qr = uQR() qr.add_data(thing) offset_x = 10 offset_y = 15 matrix = qr.get_matrix() display.drawFill(0xFFFFFF) for y, row in enumerate(matrix): for x, col in enumerate(row): if not matrix[y][x]: #ugfx.area(offset_x+x*block_size, offset_y+y*block_size, block_size, block_size, ugfx.BLACK) display.drawPixel(offset_x+x, offset_y+y, 0x0) display.flush() print("Starting WIFI!") wifi.connect() wifi_up() badge.init() print("Done!") #ugfx.input_init() clearscreen() display.drawText(40, 30, "Initializing!",0x0 , "DejaVuSans20") display.drawText(40, 70, "Bitcoin Wallet!",0x0 , "DejaVuSans20") display.flush() while True: try: request = urequests.get(api) result = request.json() last = float(result['last']) open = float(result['open']) percent = ((last-open)/open)*100 clearscreen() display.drawText(40, 30, "BTC USD!",0x0 , "DejaVuSans20") display.drawText(40, 70, str(last),0x0 , "DejaVuSans20") display.flush() time.sleep(10) except: print("Could not get BTCUSD!") #render('https://duckdns.zwanebloem.nl') render('pizza') time.sleep(10)