Toggle Navigation
Hatchery
Eggs
BTC-EURO
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import uinterface, rgb, time, default_icons, urequests def left(s, amount): return s[:amount] def logo(): logo = [0x000000ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0x000000ff, 0xff8300ff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0x00000000, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xffe30aff, 0xff8300ff, 0xff8300ff, 0x00000000] rgb.clear() rgb.image(logo, (0, 0), size=(8,8)) api = 'https://api.binance.com/api/v3/klines?symbol=BTCEUR&interval=3m&limit=1' # Data format: [[TS, OPEN, HIGH, LOW, CLOSE, VOL, ...], ...] rgb.setfont(rgb.FONT_6x3) rgb.clear() uinterface.connect_wifi() data, size, frames = default_icons.animation_loading rgb.gif(data, (13, 1), size, frames) while True: uinterface.connect_wifi() request = urequests.get(api) result = request.json() last = int(float(result[0][4])) open = int(float(result[0][1])) percent = ((last-open)/open)*100 if last > open: logo() rgb.text(left(str(last),6), (0,255,0),(9,3)) time.sleep(2) logo() rgb.text(left("+" + str(percent),5)+"%", (0, 255, 0),(9,3)) time.sleep(2) logo() rgb.text(left(str(last),6), (0, 255, 0),(9,3)) else: if last < open: logo() rgb.text(left(str(last),6), (255,0,0),(9,3)) time.sleep(2) logo() rgb.text(left(str(percent),5)+"%", (255, 0, 0),(9,3)) time.sleep(2) logo() rgb.text(left(str(last),6), (255, 0, 0),(9,3)) else: logo() rgb.text(left(str(last),6), (255,255,255),(9,3)) time.sleep(30)