Toggle Navigation
Hatchery
Eggs
SpaceStateV3
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
#need to retest the display api import rgb rgb.clear() displaytext = "Hello World!" rgb.text(displaytext) """ import wifi, gc, machine, system, easydraw, time, urequests as requests, display # Read settings from NVS status_url = machine.nvs_getstr("spacestate", "url") or "https://tkkrlab.nl/statejson.php" if not status_url: print("Status URL not configured") easydraw.messageCentered("Status URL not configured") display.flush() time.sleep(5) system.home() while True: # Connect to wifi (non-blocking) wifi.connect() print("Connecting to WiFi...") easydraw.messageCentered("Connecting to WiFi...") display.flush() # Wait for WiFi to be connected if not wifi.wait(): print("Failed to connect to WiFi!") easydraw.messageCentered("Failed to connect to WiFi!") display.flush() time.sleep(5) continue # Get status from internet print("Loading...") easydraw.messageCentered("Loading...") display.flush() data = requests.get(status_url) content=data.json()['state']['open'] data.close() gc.collect() # Print status if content == True: #space is open print("TkkrLab is open") easydraw.messageCentered("TkkrLab is open") #easydraw not documented else: #space is closed print("TkkrLab is closed") easydraw.messageCentered("TkkrLab is closed") #easydraw not documented gc.collect() display.flush(display.FLAG_LUT_GREYSCALE) # Waiting for 180 seconds... or 10 when devving time.sleep(180) """