Simplified format for patterns

This commit is contained in:
Maximilian Giller 2024-03-03 18:57:53 +01:00
parent 31072baf97
commit ea73b3702c
2 changed files with 3 additions and 3 deletions

View file

@ -68,9 +68,9 @@ class MatrixDisplay:
with canvas(self.device) as draw: with canvas(self.device) as draw:
draw.rectangle((0, 0, 31, 7), outline="white", fill="white") draw.rectangle((0, 0, 31, 7), outline="white", fill="white")
async def pattern(self, pattern: str = "0,1", step_ms: int = 500): async def pattern(self, pattern: str = "01", step_ms: int = 500):
# Parse # Parse
pattern_steps = [step.strip() == "1" for step in pattern.split(",") if step] pattern_steps = [step.strip() == "1" for step in pattern]
# Execute # Execute
for step in pattern_steps: for step in pattern_steps:
if step: if step:

View file

@ -101,7 +101,7 @@ async def flash(count: int = 1, contrast: Optional[int] = None):
@app.post("/pattern") @app.post("/pattern")
async def flash(pattern: str = "0,1", step_ms: int = 500): async def flash(pattern: str = "01", step_ms: int = 500):
await queue.set_idle_action(display_pattern, pattern=pattern, step_ms=step_ms) await queue.set_idle_action(display_pattern, pattern=pattern, step_ms=step_ms)
return {"message": "Activated pattern."} return {"message": "Activated pattern."}