--- /dev/null
+import network, socket, time, requests, gc
+from machine import Pin
+
+ssid='SSID'
+password='PSWD'
+
+url='http://192.168.0.109:8060'
+
+homeKey='/keypress/home'
+upKey='/keypress/up'
+downKey='/keypress/down'
+leftKey='/keypress/left'
+rightKey='/keypress/right'
+selectKey='/keypress/select'
+
+def connect():
+ wlan=network.WLAN(network.STA_IF)
+ wlan.active(True)
+ wlan.connect(ssid,password)
+ while wlan.isconnected() == False:
+ print('Waiting for connection...')
+ time.sleep(1)
+ ip=wlan.ifconfig()[0]
+ print(f'Connected on {ip}')
+ return ip
+
+def gccol():
+ gc.collect()
+
+connect()
+gccol()
+
+"""
+to use key presses: requests.post(url+keypress), ie, requests.post(url+homeKey)
+need to run gcol() after each keypress, memory runs out quick
+when setting up buttons, set resistor on board, do not use internal PULL_UP/PULL_DOWN
+"""
+"""
+homebtn=Pin(#,Pin.IN)
+upbtn=Pin(#,Pin.IN)
+downbtn=Pin(#,Pin.IN)
+leftbtn=Pin(#,Pin.IN)
+rightbtn=Pin(#,Pin.IN)
+selectbtn=Pin(#,Pin.IN)
+
+while True:
+ if homebtn.value()==1:
+ requests.post(url+homeKey)
+ gccol()
+ time.sleep(0.2)
+ if upbtn.value()==1:
+ requests.post(url+upKey)
+ gccol()
+ time.sleep(0.2)
+ if downbtn.value()==1:
+ requests.post(url+downKey)
+ gccol()
+ time.sleep(0.2)
+ if leftbtn.value()==1:
+ requests.post(url+leftKey)
+ gccol()
+ time.sleep(0.2)
+ if rightbtn.value()==1:
+ requests.post(url+rightKey)
+ gccol()
+ time.sleep(0.2)
+ if selectbtn.value()==1:
+ requests.post(url+selectKey)
+ gccol()
+ time.sleep(0.2)
+"""