From a806fabf5ca3b45ea33735361516185f56ea08e5 Mon Sep 17 00:00:00 2001 From: tmpbci Date: Fri, 21 Dec 2018 17:23:43 +0100 Subject: [PATCH] Simplify file names --- mainy.conf => LJ.conf | 2 +- las.py => commands.py | 2 +- gstt.py | 2 +- mainyservers.py => main.py | 14 +++--- newdacp.py => tracer.py | 9 ++-- webui/index.html | 92 ++++++++++++++++++++++++-------------- webui/indexgl.html | 91 +++++++++++++++++++++++++++++++++++++ 7 files changed, 163 insertions(+), 49 deletions(-) rename mainy.conf => LJ.conf (99%) rename las.py => commands.py (99%) rename mainyservers.py => main.py (98%) rename newdacp.py => tracer.py (98%) create mode 100644 webui/indexgl.html diff --git a/mainy.conf b/LJ.conf similarity index 99% rename from mainy.conf rename to LJ.conf index f791359..c03594c 100644 --- a/mainy.conf +++ b/LJ.conf @@ -2,7 +2,7 @@ set = 5 curve = 0 lasernumber = 3 -debug = 0 +debug = 1 ljayserverip = 127.0.0.1 nozoscip = 127.0.0.1 bhoroscip = 127.0.0.1 diff --git a/las.py b/commands.py similarity index 99% rename from las.py rename to commands.py index 90537bb..33f5334 100644 --- a/las.py +++ b/commands.py @@ -1,7 +1,7 @@ # coding=UTF-8 """ -LJ OSC handler +LJ OSC and Websockets laser commands v0.7.0 diff --git a/gstt.py b/gstt.py index d103a02..7eb3082 100644 --- a/gstt.py +++ b/gstt.py @@ -11,7 +11,7 @@ from /team/laser ''' #ConfigName = "setexample.conf" -ConfigName = "mainy.conf" +ConfigName = "LJ.conf" debug = 2 diff --git a/mainyservers.py b/main.py similarity index 98% rename from mainyservers.py rename to main.py index 888e6f0..b0f4a9d 100644 --- a/mainyservers.py +++ b/main.py @@ -1,5 +1,5 @@ ''' -LJ Servers v0.8 +LJ Laser Server v0.8 Laser server + webUI servers (ws + OSC) @@ -30,9 +30,9 @@ settings.Write() from multiprocessing import Process, Queue, TimeoutError import random, ast -import newdacp +import tracer import homographyp -import las +import commands import font1 @@ -48,7 +48,7 @@ args =[0,0] def dac_process(number, pl): while True: try: - d = newdacp.DAC(number,pl) + d = tracer.DAC(number,pl) d.play_stream() except Exception as e: @@ -176,7 +176,7 @@ def handler(path, tags, args, source): print "default handler" print "OSC said : ", path, oscpath, args sendWSall(path + " " + str(args[0])) - las.handler(oscpath,args) + commands.handler(oscpath,args) # RAW OSC Frame available ? @@ -288,7 +288,7 @@ def message_received(client, server, message): oscpath = message.split(" ") args[0] = str(oscpath[1]) #print oscpath[0].split("/"),oscpath[1] - las.handler(oscpath[0].split("/"),args) + commands.handler(oscpath[0].split("/"),args) # current UI has no dedicated off button so /on 0 trigs /off to bhorosc if oscpath[0] == "/on": @@ -367,7 +367,7 @@ try: print "Launching OSC server..." print "at", bhoroscIPin, "port",str(bhoroscPORTin) print "Will update webUI dac status every second" - oscserver.addMsgHandler( "/noteon", las.NoteOn ) + oscserver.addMsgHandler( "/noteon", commands.NoteOn ) # Default OSC handler for all OSC incoming message oscserver.addMsgHandler("default", handler) thread.start_new_thread(osc_thread, ()) diff --git a/newdacp.py b/tracer.py similarity index 98% rename from newdacp.py rename to tracer.py index f2bd1d8..fe63493 100644 --- a/newdacp.py +++ b/tracer.py @@ -1,12 +1,11 @@ #!/usr/bin/python2.7 # -*- coding: utf-8 -*- # -*- mode: Python -*- - ''' LJay/LJ v0.8.0 -newdacp.py -Enhanced version (redis and process style) of the etherdream python library from j4cDAC. +tracer.py (was newdacp.py) +Enhanced version (support for several lasers) of the etherdream python library from j4cDAC. LICENCE : CC Sam Neurohack, pclf @@ -18,6 +17,7 @@ Uses redis keys value for live inputs/outputs These redis keys are read and set at each main loop. Live inputs : +/order select some change to adjust /pl/lasernumber [(x,y,color),(x1,y1,color),...] A string of list of pygame points list. /resampler/lasernumber [(1.0,8), (0.25,3),(0.75,3),(1.0,10)] : a string for resampling rules. the first tuple (1.0,8) is for short line < 4000 in etherdream space @@ -30,9 +30,6 @@ Live ouputs : /lack/lasernumber value "a": ACK "F": Full "I": invalid. 64 or 35 for no connection. Geometric corrections : - - - ''' import socket diff --git a/webui/index.html b/webui/index.html index da4fddb..15eccca 100644 --- a/webui/index.html +++ b/webui/index.html @@ -403,10 +403,10 @@
-
-
-
-
+
+
+
+
@@ -420,10 +420,10 @@
-
-
-
-
+
+
+
+
@@ -546,37 +546,63 @@ // Store Reference To The Canvas & Set Context var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); - var lastpoint = { x: 0, y: 0 }; + var lastpoint = { x: 0, y: 0, color: 0}; - function draw() { - // Clear Canvas At The Start Of Every Frame - ctx.clearRect(0,0,400,400); - if (pl2.length > 0) - { - ctx.beginPath(); - ctx.moveTo(lastpoint.x , lastpoint.y ); + // Todo : laser point will have black points to go from a polyline to another. Need to discard those black points. + function draw() { - // Draw Lines - for (var i = 0; i < pl2.length/3; i++) { - ctx.lineTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7); - //ctx.strokeStyle = "#"+(pl2[2+(i*3)]).toString(16); + // Clear Canvas At The Start Of Every Frame + ctx.clearRect(0,0,400,400); + if (pl2.length > 0) + { + + // Begin a new path + // 0.7 reduces max coordinates in a more browser compatible resolution. + ctx.beginPath(); + ctx.moveTo(pl2[0]*0.7, pl2[1]*0.7); + lastpoint.color = pl2[2]; + + // Draw n Lines + for (var i = 0; i < pl2.length/3; i++) + { + + // New point has the same color -> add a new line to new point + if (pl2[2+(i*3)] === lastpoint.color) + { + ctx.lineTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7); + } + + // New point has different color -> stroke with previous color + if (pl2[2+(i*3)] != lastpoint.color) + { + ctx.strokeStyle = "#"+(lastpoint.color + Math.pow(16, 6)).toString(16).slice(-6); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7); + } + + // Last point -> stroke with current color + if (i === (pl2.length/3)-1 ) + { + ctx.moveTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7); ctx.strokeStyle = "#"+((pl2[2+(i*3)]) + Math.pow(16, 6)).toString(16).slice(-6); ctx.stroke(); - } - - //ctx.strokeStyle = "#888"; - //ctx.stroke(); - lastpoint.x = pl2[i*3]; - lastpoint.y = pl2[1+(i*3)]; - } - // Call Draw Function Again To Create Animation - window.requestAnimationFrame(draw); - } - - // Initialize The Draw Function - draw(); + } + // store point for comparison + lastpoint.x = pl2[i*3]; + lastpoint.y = pl2[1+(i*3)]; + lastpoint.color = pl2[2+(i*3)]; + } + + } + // Call Draw Function Again To Create Animation + window.requestAnimationFrame(draw); + } + + // Initialize The Draw Function + draw(); diff --git a/webui/indexgl.html b/webui/indexgl.html new file mode 100644 index 0000000..bd9cccb --- /dev/null +++ b/webui/indexgl.html @@ -0,0 +1,91 @@ + + + + + + LJ + + + + + +
+ +
+ + + + + + +