Updated network connection and added PS2 controller.

master
Guy Carver 2021-05-12 15:50:45 -04:00
rodzic 58edcfdc05
commit 6c01843e20
1 zmienionych plików z 32 dodań i 7 usunięć

Wyświetl plik

@ -1,21 +1,46 @@
import esp import esp
import network import network
from time import sleep_ms
def connect(): def init_ap( ) :
ap_if = network.WLAN(network.AP_IF)
ap_if.active(True)
ap_if.config(essid="ESP32-2")
print('{} access point: {}'.format(ap_if.config('essid'), ap_if.ifconfig()[0]))
def connect( ) :
sta_if = network.WLAN(network.STA_IF) sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected() : if not sta_if.isconnected() :
print('Connecting to Carvers') print('Connecting to Carvers')
sta_if.active(True) sta_if.active(True)
sta_if.connect('Carvers', 'gruntbuggly') sta_if.connect('Carvers', 'gruntbuggly')
while not sta_if.isconnected(): counter = 0
pass while not sta_if.isconnected() and counter < 20 :
ap_if = network.WLAN(network.AP_IF) sleep_ms(500)
ap_if.active(True) counter += 1
ap_if.config(essid="ESP32-1")
print('network ip: ', sta_if.ifconfig()[0]) print('network ip: ', sta_if.ifconfig()[0])
print('{} access point: {}'.format(ap_if.config('essid'), ap_if.ifconfig()[0]))
def no_debug(): def no_debug():
# this can be run from the REPL as well # this can be run from the REPL as well
esp.osdebug(None) esp.osdebug(None)
from machine import PS2
def test( ):
''' '''
p = PS2(23, 19, 18, 5)
def cb( ind, status ) :
inname = p.inputname(ind)
if status & 2 :
statname = 'pressed' if status == 3 else 'released'
print(inname + ': ' + statname)
p.callback(cb)
while 1:
p.update()
sleep_ms(100)