KretsloppKontroll for talking to Anna's sensor bracelet


req: [Conductor] quark


read sensor data from slave via master.  the sensors are 3 pushbuttons, 3 knobs and 1 accelerometer (xyz).


*new(portName, action)

portName - a string.  if nil then automatic detection (/dev/tty.usbserial-*).

action - incoming sensor data function - see below.

<port

serial port (baudrate hardcoded to 38400).

<>action

a function called for any incoming sensor data.

the first argument is a dictionary of CVs.  see cvs below.

<>s0action

<>s1action

<>s2action

functions called when the corresponding button changes state.

the functions are passed the following arguments...

val - 0/1

delta - time in seconds since last action.

<cvs

a dictionary of CVs.

mix, fre, alt - arm right side knobs (0.-1.)

a0, a1, a2 - arm left side accelerometers (0.-1.)

s0, s1, s2 - left side buttons 0-2 (0/1)

close

stop thread and close serial port.

also close the gui window if open.

makeWindow(position)

creates a gui that displays the incoming data.  the gui can also work without the hardware system.

position - Point


//--

SerialPort.listDevices;

(

a= KretsloppKontroll(action:{|cvs|

cvs.keysValuesDo{|x, y| (""++x+y.value++" ").post};

"".postln;

});

a.s0action= {|val, delta| ("...s0 is"+val+delta).postln};

a.s1action= {|val, delta| ("...s1 is"+val+delta).postln};

a.s2action= {|val, delta| ("...s2 is"+val+delta).postln};

a.makeWindow;

)


a.cvs.mix.input= 0.3;

a.close;