feat(patterns): merge pattern styles and add mode support
Consolidate legacy pattern ids into meteor, particles, sparkle, chase, and colour_cycle with n6/mode style selection; add pattern_modes helper, self-contained tests/all.py, and preset mode alias on wire. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
794f1a2841
commit
55a97ac51c
44 files changed
+998
-1539
No files matched your search
@@ -1,5 +1,7 @@
|
||||
"""STA connect helpers aligned with tests/test_wifi.py (status polling, fatal codes)."""
|
||||
|
||||
import gc
|
||||
import machine
|
||||
import utime
|
||||
import network
|
||||
|
||||
@@ -57,6 +59,40 @@ def _one_association_campaign(sta_if, ssid, password, wdt):
|
||||
return True
|
||||
|
||||
|
||||
def boot_sta(settings, wdt):
|
||||
"""Tear down and bring up STA. Call before large heap users (NeoPixel, patterns).
|
||||
|
||||
On ESP32-C3, soft reboots can leave the Wi-Fi driver allocated; init while the
|
||||
heap is still free. If re-init fails after a soft reboot, hard-reset once.
|
||||
"""
|
||||
sta_if = network.WLAN(network.STA_IF)
|
||||
try:
|
||||
if sta_if.active():
|
||||
try:
|
||||
sta_if.disconnect()
|
||||
except Exception:
|
||||
pass
|
||||
sta_if.active(False)
|
||||
except Exception:
|
||||
pass
|
||||
utime.sleep_ms(100)
|
||||
gc.collect()
|
||||
try:
|
||||
sta_if.active(True)
|
||||
except OSError as e:
|
||||
err = str(e)
|
||||
if "Out of Memory" in err or "WiFi" in err:
|
||||
if machine.reset_cause() == machine.SOFT_RESET:
|
||||
print("wifi_sta: init failed after soft reboot, hard reset:", err)
|
||||
machine.reset()
|
||||
raise
|
||||
sta_if.config(pm=network.WLAN.PM_NONE)
|
||||
ssid = settings.get("ssid") or ""
|
||||
if ssid:
|
||||
connect_until_up(sta_if, ssid, settings.get("password") or "", wdt)
|
||||
return sta_if
|
||||
|
||||
|
||||
def connect_until_up(sta_if, ssid, password, wdt):
|
||||
"""Boot: repeat campaigns until STA has a route (same strategy as tests/test_wifi.py)."""
|
||||
if not ssid:
|
||||
|
||||
Reference in new issue
Block a user