Removed separate off and on ms for pattern

This commit is contained in:
Maximilian Giller 2024-03-03 17:32:10 +01:00
parent 2bcc99a893
commit de66a88fda
2 changed files with 4 additions and 6 deletions

View file

@ -68,7 +68,7 @@ class MatrixDisplay:
with canvas(self.device) as draw:
draw.rectangle((0, 0, 31, 7), outline="white", fill="white")
async def pattern(self, pattern: str = "0,1", off_ms: int = 500, on_ms: int = 500):
async def pattern(self, pattern: str = "0,1", step_ms: int = 500):
# Parse
pattern_steps = [step.strip() == "1" for step in pattern.split(",") if step]
# Execute
@ -77,7 +77,7 @@ class MatrixDisplay:
self.turn_full()
else:
self.turn_off()
await asyncio.sleep((on_ms if step else off_ms) / 1000)
await asyncio.sleep(step_ms / 1000)
def show_current_time(self):
self.device.contrast(self.contrast)

View file

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