pixelserver2/apps/strobo.py

35 lines
626 B
Python
Raw Normal View History

2018-09-24 19:09:04 +00:00
#!/usr/bin/env python3
import os
import sys
2024-10-28 17:10:03 +00:00
import time
2018-09-24 19:09:04 +00:00
Nx = int(sys.argv[1])
Ny = int(sys.argv[2])
2024-10-28 17:10:03 +00:00
p1 = 20
p2 = 10
2018-09-24 19:09:04 +00:00
try:
2024-10-28 17:10:03 +00:00
param = sys.argv[3]
p = param.split(",")
p1 = int(p[0])
p2 = int(p[1])
2018-09-24 19:09:04 +00:00
except:
pass
buffera = bytearray(b"\x00" * (3 * Nx * Ny))
bufferb = bytearray(b"\xFF" * (3 * Nx * Ny))
2024-10-28 17:10:03 +00:00
cnt = 0
2018-09-24 19:09:04 +00:00
2024-10-28 17:10:03 +00:00
os.write(2,b"Usage: Parameter: \"20,10\"\n -> updates every 20*0.01s, every 10th frame is white")
2018-09-24 19:09:04 +00:00
while True:
os.write(1, buffera)
2024-10-28 17:10:03 +00:00
time.sleep(p1*0.01)
if cnt == p2-1:
cnt = 0
os.write(1, bufferb)
time.sleep(p1*0.01)
cnt += 1