separate wifi setup function
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m27s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s

This commit is contained in:
2025-08-05 21:36:31 +02:00
parent 8a7eaf1d63
commit 9ee0418d60

View File

@@ -79,6 +79,13 @@ class SDContext:
self.sdcard.deinit()
def setup_wifi():
network.hostname("TonberryPico")
wlan = network.WLAN(network.WLAN.IF_AP)
wlan.config(ssid=f"TonberryPicoAP_{machine.unique_id().hex()}", security=wlan.SEC_OPEN)
wlan.active(True)
def run():
asyncio.new_event_loop()
# Setup LEDs
@@ -86,6 +93,9 @@ def run():
np = NeoPixel(pin, 10, sm=1)
asyncio.create_task(rainbow(np))
# Wifi with default config
setup_wifi()
# Setup MP3 player
with SDContext(mosi=Pin(3), miso=Pin(4), sck=Pin(2), ss=Pin(5), baudrate=15000000), \
AudioContext(Pin(8), Pin(6)) as audioctx:
@@ -106,12 +116,4 @@ def run():
if __name__ == '__main__':
time.sleep(1)
network.hostname("TonberryPico")
wlan = network.WLAN(network.WLAN.IF_AP)
wlan.config(ssid=f"TonberryPicoAP_{machine.unique_id().hex()}", security=wlan.SEC_OPEN)
wlan.active(True)
run()