2019-03-10 22:06:04 +00:00
|
|
|
# coding=UTF-8
|
|
|
|
|
|
|
|
'''
|
2019-03-17 03:19:57 +00:00
|
|
|
|
|
|
|
LJ v0.8.1
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
Cycling text on one LJ laser.
|
|
|
|
LICENCE : CC
|
2019-03-17 03:19:57 +00:00
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
import redis
|
|
|
|
import lj3
|
|
|
|
import sys,time
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
from osc4py3.as_eventloop import *
|
|
|
|
from osc4py3 import oscbuildparse
|
|
|
|
#from osc4py3 import oscmethod as osm
|
|
|
|
from osc4py3.oscmethod import *
|
|
|
|
|
|
|
|
OSCinPort = 8007
|
|
|
|
|
|
|
|
duration = 300
|
|
|
|
lasertext = ["TEAMLASER","FANFAN","LOLOSTER","SAM"]
|
|
|
|
|
|
|
|
'''
|
|
|
|
is_py2 = sys.version[0] == '2'
|
|
|
|
if is_py2:
|
|
|
|
from Queue import Queue
|
|
|
|
else:
|
|
|
|
from queue import Queue
|
|
|
|
'''
|
2019-03-17 03:19:57 +00:00
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
print ("Arguments parsing if needed...")
|
|
|
|
argsparser = argparse.ArgumentParser(description="Text Cycling for LJ")
|
|
|
|
argsparser.add_argument("-r","--redisIP",help="IP of the Redis server used by LJ (127.0.0.1 by default) ",type=str)
|
|
|
|
argsparser.add_argument("-c","--client",help="LJ client number (0 by default)",type=int)
|
|
|
|
argsparser.add_argument("-l","--laser",help="Laser number to be displayed (0 by default)",type=int)
|
|
|
|
argsparser.add_argument("-v","--verbose",help="Verbosity level (0 by default)",type=int)
|
|
|
|
|
|
|
|
|
|
|
|
args = argsparser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
if args.client:
|
|
|
|
ljclient = args.client
|
|
|
|
else:
|
|
|
|
ljclient = 0
|
|
|
|
|
|
|
|
if args.laser:
|
|
|
|
plnumber = args.laser
|
|
|
|
else:
|
|
|
|
plnumber = 0
|
|
|
|
|
|
|
|
if args.verbose:
|
|
|
|
debug = args.verbose
|
|
|
|
else:
|
|
|
|
debug = 0
|
|
|
|
|
|
|
|
# Redis Computer IP
|
|
|
|
if args.redisIP != None:
|
|
|
|
redisIP = args.redisIP
|
|
|
|
else:
|
|
|
|
redisIP = '127.0.0.1'
|
|
|
|
|
|
|
|
lj3.Config(redisIP,ljclient)
|
|
|
|
#r = redis.StrictRedis(host=redisIP, port=6379, db=0)
|
|
|
|
|
|
|
|
|
|
|
|
# If you want to use rgb for color :
|
|
|
|
def rgb2int(r,g,b):
|
|
|
|
return int('0x%02x%02x%02x' % (r,g,b),0)
|
|
|
|
|
|
|
|
|
|
|
|
def WebStatus(message):
|
2019-03-17 03:19:57 +00:00
|
|
|
lj3.SendLJ("/status",message)
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
def OSCljclient(value):
|
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
|
|
|
print("I got /cycl/ljclient with value", value)
|
|
|
|
ljclient = value
|
|
|
|
lj3.LjClient(ljclient)
|
|
|
|
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
# /ping
|
|
|
|
def OSCping():
|
|
|
|
|
|
|
|
lj3.OSCping("cycl")
|
|
|
|
|
|
|
|
# /quit
|
|
|
|
def OSCquit():
|
|
|
|
|
|
|
|
lj3.OSCquit("Cycl")
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
osc_startup()
|
|
|
|
osc_udp_server("127.0.0.1", OSCinPort, "InPort")
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
osc_method("/ping*", OSCping)
|
|
|
|
osc_method("/quit", OSCquit)
|
2019-03-10 22:06:04 +00:00
|
|
|
osc_method("/cycl/ljclient", OSCljclient)
|
|
|
|
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
WebStatus("Textcycl Ready")
|
|
|
|
lj3.SendLJ("/cycl/start 1")
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
def Run():
|
|
|
|
|
|
|
|
counter =0
|
|
|
|
step = 0
|
|
|
|
timing = -1
|
|
|
|
color = rgb2int(255,255,255)
|
|
|
|
|
|
|
|
try:
|
|
|
|
while 1:
|
|
|
|
|
|
|
|
if timing == duration or timing == -1:
|
|
|
|
message = lasertext[step]
|
|
|
|
lj3.Text(message, color, PL = 0, xpos = 300, ypos = 300, resize = 1, rotx =0, roty =0 , rotz=0)
|
|
|
|
lj3.DrawPL(0)
|
|
|
|
timing = 0
|
|
|
|
|
|
|
|
else:
|
|
|
|
step += 1
|
|
|
|
if step >3:
|
|
|
|
step =0
|
|
|
|
timing += 1
|
|
|
|
time.sleep(0.01)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Gently stop on CTRL C
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
WebStatus("Textcycl stop")
|
|
|
|
print("Stopping OSC...")
|
|
|
|
lj3.OSCstop()
|
|
|
|
|
|
|
|
print ("Textcycl Stopped.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Run()
|
|
|
|
|
|
|
|
|