Hello, Years ago I got help for a project on the forum. Got the project working but never understood the patch. Can someone help explain the steps here, please.
Data is being delivered via the comport as an x and y position. It looked something like 15x14y13x17y11x10 and on and on. I understand that asci code is being delivered across the serial connection from an arduino sketch and that 120 selects the x character but not really much else. Why porepend and not append for instance? Any help would be greatly appreciated. Thanks. JoeF.
-
Help explain a list from comport
-
Meant prepend. And, append. Doh!
-
@lulu_joe13 [list prepend] because the following [t l] is adding back the previously built list for each new data value......... BEFORE the current data value....... keeping the list in the original order as it is built up.
Then the [list split 6] is chopping the messages into groups of 6 atoms.... resetting the spigot to re-start the process when "120" is received again. As [list prepend] receives another "120" the previous list is overwritten and a new list starts building.
6 atoms because x15y17 is......... 120 49 55 121 49 57 in ascii.
Explanation......... why.pdI suppose you could use [list append] and reverse interpret all the outlets of [unpack] but it seems easier to read in the current order, and the calculations that derive the x / y values post [unpack] might be harder to fathom with the right > left ordering.
David. -
@lulu_joe13 If you're using Pd 0.48 or newer, have a look at [list store] which is very helpful for building lists.
-
Thank-you so much for taking the time. Turning the spigot off baffled me until you explained it. Still confused on the multiport triggers? Thanks-again. JoeF.
-
@lulu_joe13 Unpack drops its values in order from right to left....... like everything else...... so if you want to do a calc based on the 3rd outlet it can only be done on data from the 4th onwards.
Try to do it on data from the second outlet and you still have the data from the last set.
You can reorder the data before the [unpack f f f f f f] with something like a [$6 $5 $1 $2 $3 $4( message that will reverse the last two atoms in a list (of 6 atoms) and put them before the rest.........
David.