Toggle Navigation
Hatchery
Eggs
pixelflood-server
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import wifi, rgb, gc, usocket wifi.connect() rgb.clear() rgb.setfont(rgb.FONT_6x3) rgb.text("WiFi...") _ = wifi.wait() rgb.clear() rgb.setfont(rgb.FONT_7x5) addr = usocket.getaddrinfo("0.0.0.0",1234)[0][-1] sock = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM, usocket.IPPROTO_TCP) sock.bind(addr) ip = wifi.sta_if.ifconfig()[0] print("IP: " + ip) rgb.scrolltext(ip) fb = [0]*32*8 sock.listen(1) sock.settimeout(None) started = False while True: client, remote_addr = sock.accept() client.settimeout(0.01) if not started: started = True rgb.disablecomp() try: data = client.read().decode("ascii") if data and len(data) > 0: data.rstrip("\n") parts = data.split(" ") if len(parts) == 4: if (parts[0] == "PX"): x = int(parts[1]) y = int(parts[2]) c = int(parts[3]) fb[x+y*32] = c << 8 print(data) rgb.frame(fb) gc.collect() except Exception as err: print(err) finally: client.close() client = None sock.close()