mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-13 20:00:12 +01:00
WJSendPlugin stores args, so will be able to interpolate between values...
This commit is contained in:
@@ -60,7 +60,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
# print(">>>>recall from data:\n\t%s\n" %data)
|
# print(">>>>recall from data:\n\t%s\n" %data)
|
||||||
for queue, item in data.items():
|
for queue, item in data.items():
|
||||||
if item is not None:
|
if item is not None:
|
||||||
self.send_buffered(queue, item, record = False)
|
self.send_buffered(queue, item[0], item[1], record = False)
|
||||||
|
|
||||||
|
|
||||||
# methods for ModulationReceiverPlugin - receives changes to the in-built modulation levels (-1 to +1)
|
# methods for ModulationReceiverPlugin - receives changes to the in-built modulation levels (-1 to +1)
|
||||||
@@ -97,6 +97,8 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
def open_serial(self, port='/dev/ttyUSB0', baudrate=9600):
|
def open_serial(self, port='/dev/ttyUSB0', baudrate=9600):
|
||||||
if self.ser is not None:
|
if self.ser is not None:
|
||||||
self.ser.close()
|
self.ser.close()
|
||||||
|
if self.disabled:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.ser = serial.Serial(
|
self.ser = serial.Serial(
|
||||||
port=port,
|
port=port,
|
||||||
@@ -114,6 +116,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
#self.pc.midi_input.root.after(500, self.refresh)
|
#self.pc.midi_input.root.after(500, self.refresh)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print ("open_serial failed: " + str(type(e)))
|
print ("open_serial failed: " + str(type(e)))
|
||||||
|
self.disabled = True
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for queue, command in self.queue.items():
|
for queue, command in self.queue.items():
|
||||||
self.send_buffered(queue, command)
|
self.send_buffered(queue, command[0], command[1])
|
||||||
#self.queue.clear()
|
#self.queue.clear()
|
||||||
except Exception:
|
except Exception:
|
||||||
print ("!!! CAUGHT EXCEPTION running queue !!!")
|
print ("!!! CAUGHT EXCEPTION running queue !!!")
|
||||||
@@ -148,33 +151,35 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
if self.ser is not None:
|
if self.ser is not None:
|
||||||
self.pc.shaders.root.after(self.THROTTLE, self.refresh)
|
self.pc.shaders.root.after(self.THROTTLE, self.refresh)
|
||||||
|
|
||||||
def send(self, queue, output):
|
def send(self, queue, form, args):
|
||||||
#self.send_buffered(queue,output)
|
#self.send_buffered(queue,output)
|
||||||
self.queue[queue] = output
|
self.queue[queue] = (form, args) #output
|
||||||
|
|
||||||
last = {}
|
last = {}
|
||||||
def send_buffered(self, queue, output, record = True):
|
def send_buffered(self, queue, form, args, record = True):
|
||||||
# TODO: remove this crap when i'm sure the bug has been fixed
|
"""# TODO: remove this crap when i'm sure the bug has been fixed
|
||||||
if output is not None and (type(output) is dict or 'WJSendPlugin' in output):
|
if output is not None and (type(output) is dict or 'WJSendPlugin' in output):
|
||||||
print ("\n\n\ncaught fucker?")
|
print ("\n\n\ncaught fucker?")
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_stack()
|
traceback.print_stack()
|
||||||
quit()
|
quit()"""
|
||||||
|
|
||||||
if self.last.get(queue)!=output:
|
if self.last.get(queue)!=(form,args):
|
||||||
|
print("send_buffered attempting to parse queue\t%s with form\t'%s' and args\t%s" % (queue, form, args))
|
||||||
|
output = form.format(*args)
|
||||||
self.send_serial_string(output)
|
self.send_serial_string(output)
|
||||||
self.last[queue] = output
|
self.last[queue] = (form,args) #output
|
||||||
if record:
|
if record:
|
||||||
print("### send_buffered is setting last_record[%s] to %s" % (queue,output))
|
print("### send_buffered is setting last_record[%s] to %s" % (queue,output))
|
||||||
self.last_record[queue] = output
|
self.last_record[queue] = (form,args)#output
|
||||||
|
|
||||||
def send_append(self, command, value):
|
def send_append(self, command, value):
|
||||||
# append value to the command as a hex value
|
# append value to the command as a hex value
|
||||||
self.send(command.split(':')[0], "{}{:02X}".format(command,int(255*value)))
|
self.send(command.split(':')[0], "{}{:02X}", [ command,int(255*value) ])
|
||||||
|
|
||||||
def send_append_pad(self, pad, command, value):
|
def send_append_pad(self, pad, command, value):
|
||||||
# append value, padded to length
|
# append value, padded to length
|
||||||
self.send(command.split(':')[0], ("{}{:0%iX}"%pad).format(command,int(255*value)))
|
self.send(command.split(':')[0], "{}{:0%iX}"%pad, [ command,int(255*value) ])
|
||||||
|
|
||||||
|
|
||||||
# methods for ActionPlugin
|
# methods for ActionPlugin
|
||||||
@@ -205,8 +210,9 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='y':
|
elif dim=='y':
|
||||||
self.colour_y = int(255*value)
|
self.colour_y = int(255*value)
|
||||||
|
|
||||||
output = "VCC:{}{:02X}{:02X}".format(chan, self.colour_x,self.colour_y)
|
#output = "VCC:{}{:02X}{:02X}".format(chan, self.colour_x, self.colour_y)
|
||||||
self.send('VCC', output)
|
# could store format string + values, then interpolate over those values
|
||||||
|
self.send('VCC', "VCC:{}{:02X}{:02X}", [chan, self.colour_x, self.colour_y]) #output)
|
||||||
|
|
||||||
# RGB control of matte colour!
|
# RGB control of matte colour!
|
||||||
back_colour_x = 127
|
back_colour_x = 127
|
||||||
@@ -221,10 +227,11 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='z':
|
elif dim=='z':
|
||||||
self.back_colour_z = int(255*value)
|
self.back_colour_z = int(255*value)
|
||||||
|
|
||||||
output = "VBM:{:02X}{:02X}{:02X}".format(self.back_colour_x,self.back_colour_y,self.back_colour_z)
|
#output = "VBM:{:02X}{:02X}{:02X}".format(self.back_colour_x,self.back_colour_y,self.back_colour_z)
|
||||||
self.send('VBM', output)
|
self.send('VBM', "VBM:{:02X}{:02X}{:02X}", [ self.back_colour_x,self.back_colour_y,self.back_colour_z ])
|
||||||
|
|
||||||
# this doesnt seem to work on WJ-MX30 at least, or maybe i dont know how to get it into the right mode?
|
# this doesnt seem to work on WJ-MX30 at least, or maybe i dont know how to get it into the right mode?
|
||||||
|
# todo: replace with downstream key control
|
||||||
back_wash_colour_x = 127
|
back_wash_colour_x = 127
|
||||||
back_wash_colour_y = 127
|
back_wash_colour_y = 127
|
||||||
back_wash_colour_z = 127
|
back_wash_colour_z = 127
|
||||||
@@ -237,8 +244,8 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='z':
|
elif dim=='z':
|
||||||
self.back_wash_colour_z = int(255*value)
|
self.back_wash_colour_z = int(255*value)
|
||||||
|
|
||||||
output = "VBW:{:02X}{:02X}{:02X}".format(self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z)
|
#output = "VBW:{:02X}{:02X}{:02X}".format(self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z)
|
||||||
self.send('VBW', output)
|
self.send('VBW', "VBW:{:02X}{:02X}{:02X}", [ self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z ] )
|
||||||
|
|
||||||
# positioner joystick
|
# positioner joystick
|
||||||
position_x = 127
|
position_x = 127
|
||||||
@@ -249,11 +256,11 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='x': # yes, x is really y!
|
elif dim=='x': # yes, x is really y!
|
||||||
self.position_y = int(255*value)
|
self.position_y = int(255*value)
|
||||||
|
|
||||||
output = "VPS:{}{:02X}{:02X}".format(mode,self.position_x,self.position_y)
|
#output = "VPS:{}{:02X}{:02X}".format(mode,self.position_x,self.position_y)
|
||||||
self.send('VPS:{}'.format(mode), output)
|
self.send('VPS:{}'.format(mode), "VPS:{}{:02X}{:02X}", [ mode,self.position_x,self.position_y ])#output)
|
||||||
|
|
||||||
# wipe / mix level
|
# wipe / mix level
|
||||||
def set_mix(self, value):
|
def set_mix(self, value):
|
||||||
output = "VMM:{:04X}".format(int(255*255*value))
|
#output = "VMM:{:04X}".format(int(255*255*value))
|
||||||
self.send('VMM', output)
|
self.send('VMM', "VMM:{:04X}", [ int(255*255*value) ])#output)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user