Skip to content

Commit

Permalink
Badger 2040W: Custom WiFi status handler for #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jul 13, 2023
1 parent 879f044 commit 9b98435
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions firmware/PIMORONI_BADGER2040W/lib/badger2040.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def image(self, data, w, h, x, y):
row >>= 1

def status_handler(self, mode, status, ip):
self.display.set_update_speed(2)
print(mode, status, ip)
self.display.set_pen(15)
self.display.clear()
Expand All @@ -249,15 +250,17 @@ def ip_address(self):
import network
return network.WLAN(network.STA_IF).ifconfig()[0]

def connect(self):
def connect(self, **args):
from network_manager import NetworkManager
import WIFI_CONFIG
import uasyncio
import gc

status_handler = args.get("status_handler", self.status_handler)

if WIFI_CONFIG.COUNTRY == "":
raise RuntimeError("You must populate WIFI_CONFIG.py for networking.")
self.display.set_update_speed(2)
network_manager = NetworkManager(WIFI_CONFIG.COUNTRY, status_handler=self.status_handler)

network_manager = NetworkManager(WIFI_CONFIG.COUNTRY, status_handler=status_handler)
uasyncio.get_event_loop().run_until_complete(network_manager.client(WIFI_CONFIG.SSID, WIFI_CONFIG.PSK))
gc.collect()

0 comments on commit 9b98435

Please sign in to comment.