discrete versus scrolling XY values; Brendan's stuck

brendan mccloskey's icon

Hi
I have hacked a touchpanel and, using Arduino -> [serial], I've got some fairly stable XY values coming in to Max. I wanted discrete and instantaneous location values - touch somewhere, release, touch again; a brief conversion to the signal domain and a [snapshot~] object does this perfectly. However, before the signal domain conversion, I have 'continuous' XY data, a tiny little bit noisy but usable, which allows for 'click-drag' functionality, or scrolling values. How can I tie these two modalities together in Max, without losing the discrete instantaneous touch data? What I desire is rock solid location data, and the ability to drag/scroll.

pseudo-code:
if the number attains it's maximum and doesn't change for N milliseconds then it is discrete.....
if the number does change (over N or M milliseconds?) then it is continuous

haaaalp
Brendan

patch below

Max Patch
Copy patch and select New From Clipboard in Max.

andrea agostini's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi Brendan.
This might get you started - if I have understood your question!
hth
aa

brendan mccloskey's icon

Hi Andrea
thanks for your elegant solution; it addresses one element of my question, which I may not have described very well:

I have a number stream from a touchpanel, which sharply rises (< c.20ms) to the correct X and Y value when the panel is touched. Using an averaging function in Arduino has cleaned up much of the data noise. To capture discrete values I simply use a [togedge] bang and [snapshot~]. This works perfectly well; however, I would also like to be able to use the continuous data from dragging across the touchpanel: as expected, the [togedge] bangs once and lets through a discrete value, not the continuous one...I have attached a small patch demonstrating the issue,

thanks again

Max Patch
Copy patch and select New From Clipboard in Max.

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

don't know if this is helpful at all... works with the trackpad ;)

brendan mccloskey's icon

Hey thanks MIB
not at Max at the moment, but i'll have a look asap

Brendan

brendan mccloskey's icon

this appears to work like a charm......thanks again

Brendan