Toggle Navigation
Hatchery
Eggs
wifikeys
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import wifi, socket, network, ugfx wifi.connect() if wifi.wait(10, True): addr = socket.getaddrinfo('0.0.0.0', 1337)[0][-1] s = socket.socket() s.bind(addr) s.listen(5) ugfx.init() ugfx.clear() print(network.WLAN(network.STA_IF).ifconfig()[0]) ugfx.string(20, 20, network.WLAN(network.STA_IF).ifconfig()[0], "Roboto_Regular18",ugfx.BLACK) ugfx.string(20, 60, "port 1337", "Roboto_Regular18",ugfx.BLACK) ugfx.flush() while True: res = s.accept() client_s = res[0] def p(msg, pressed): if pressed: client_s.send(msg) ugfx.input_attach(ugfx.JOY_UP, lambda pressed: p("Up\n", pressed)) ugfx.input_attach(ugfx.JOY_DOWN, lambda pressed: p("Down\n", pressed)) ugfx.input_attach(ugfx.JOY_LEFT, lambda pressed: p("Left\n", pressed)) ugfx.input_attach(ugfx.JOY_RIGHT, lambda pressed: p("Right\n", pressed)) ugfx.input_attach(ugfx.BTN_A, lambda pressed: p("a\n", pressed)) ugfx.input_attach(ugfx.BTN_B, lambda pressed: p("b\n", pressed)) ugfx.input_attach(ugfx.BTN_SELECT, lambda pressed: p("Return\n", pressed)) ugfx.input_attach(ugfx.BTN_START, lambda pressed: p("s\n", pressed))