fix(patterns): correct non-blocking timing and blink off phase

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-06 20:28:52 +12:00
parent a79c6f4dd3
commit fbebe9f4f9
19 changed files with 77 additions and 28 deletions

View File

@@ -184,6 +184,36 @@ def test_pattern_smoke():
ctx.tick_for_ms(120)
def test_patterns_do_not_use_blocking_sleep():
pattern_dir = "patterns"
offenders = []
try:
files = os.listdir(pattern_dir)
except OSError:
raise AssertionError("patterns directory is missing")
for filename in files:
if not filename.endswith(".py") or filename in ("__init__.py", "main.py"):
continue
path = pattern_dir + "/" + filename
try:
with open(path, "r") as f:
src = f.read()
except OSError:
offenders.append(filename + " (unreadable)")
continue
if (
"utime.sleep(" in src
or "utime.sleep_ms(" in src
or "time.sleep(" in src
or "time.sleep_ms(" in src
):
offenders.append(filename)
assert not offenders, "blocking sleep found in patterns: %s" % ", ".join(offenders)
def test_default_requires_existing_preset():
ctx = _TestContext()
_process_message(ctx, {"v": "1", "default": "missing"})
@@ -242,6 +272,7 @@ def run_all():
test_preset_edit_sanitization,
test_colour_conversion_and_transition,
test_pattern_smoke,
test_patterns_do_not_use_blocking_sleep,
test_default_requires_existing_preset,
test_default_targets_gate_by_device_name,
test_save_and_load_roundtrip,