forked from protonphoton/LJ
78 lines
1.6 KiB
Python
78 lines
1.6 KiB
Python
|
#!/usr/bin/python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
# -*- mode: Python -*-
|
||
|
|
||
|
|
||
|
'''
|
||
|
|
||
|
This generator print 3 static vertical line.
|
||
|
The aim is to show The aim is to show the laser beam ignition time.
|
||
|
beam when ther is no optimisation
|
||
|
|
||
|
v0.1.0
|
||
|
|
||
|
LICENCE : CC
|
||
|
|
||
|
by lapin (aka nipal)
|
||
|
|
||
|
'''
|
||
|
|
||
|
from __future__ import print_function
|
||
|
import time
|
||
|
import argparse
|
||
|
import sys
|
||
|
|
||
|
name="generator::endingPoint"
|
||
|
|
||
|
|
||
|
def debug(*args, **kwargs):
|
||
|
if( verbose == False ):
|
||
|
return
|
||
|
print(*args, file=sys.stderr, **kwargs)
|
||
|
|
||
|
argsparser = argparse.ArgumentParser(description="dummy generator")
|
||
|
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||
|
argsparser.add_argument("-s","--speed",help="point per frame progress",default=3,type=int)
|
||
|
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
|
||
|
args = argsparser.parse_args()
|
||
|
|
||
|
fps=args.fps
|
||
|
verbose=args.verbose
|
||
|
optimal_looptime = 1 / fps
|
||
|
debug(name+" optimal looptime "+str(optimal_looptime))
|
||
|
|
||
|
white = 0xFFFFFF
|
||
|
blank = 0
|
||
|
offset_y = 100
|
||
|
offset_x = 50
|
||
|
|
||
|
begin_x = 200
|
||
|
begin_y = 200
|
||
|
|
||
|
shape_factor = [
|
||
|
[0, 0, white],
|
||
|
[0, 1, blank],
|
||
|
[1, 1, white],
|
||
|
[1, 0, blank],
|
||
|
[2, 0, white],
|
||
|
[2, 1, blank],
|
||
|
[2, 1, blank],
|
||
|
]
|
||
|
|
||
|
shape = []
|
||
|
|
||
|
for point in shape_factor:
|
||
|
shape.append([begin_x + offset_x * point[0],
|
||
|
begin_y + offset_y * point[1],
|
||
|
point[2]])
|
||
|
|
||
|
|
||
|
while True:
|
||
|
start = time.time()
|
||
|
print(shape, flush=True);
|
||
|
looptime = time.time() - start
|
||
|
if( looptime < optimal_looptime ):
|
||
|
time.sleep( optimal_looptime - looptime)
|
||
|
debug(name+" micro sleep:"+str( optimal_looptime - looptime))
|
||
|
|