Toggle Navigation
Hatchery
Eggs
pixelflood-server2
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import wifi, rgb, _thread, time, gc, usocket, display 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) def threadDraw(): while True: display.flush() time.sleep(0.001) sock.listen(1) sock.settimeout(None) started = False while True: client, remote_addr = sock.accept() client.settimeout(0.0001) if not started: started = True rgb.disablecomp() _thread.start_new_thread("threadDraw",threadDraw, ()) #print("Connection from ", remote_addr) 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]) display.set(x,y,c) #fb[x+y*32] = c << 8 #rgb.frame(fb) gc.collect() except Exception as err: print(err) finally: client.close() client = None sock.close()