Oct-30-2016, 03:11 PM
(Oct-30-2016, 12:50 PM)Amro_Al Wrote: that is a great idea. I never really thought of it as 2 different threads. I understand the simplicity behind it.
As I am new to programming in general though, please bare with me if this question is too stupid or has an answer that is too obvious, but a tuple would be updated every time the variables are calculated right?. It isn't accumulative, as in it will not stack them up. It will always have the last calculated variables only. right?
Finally, will I be using Queues? I would really appreciate it if you could point me in the right direction with examples or maybe a link to a good tutorial. I feel way over my head in this part.
Thanx
1) One of the two threads is the main code flow... you just start a second thread to feed the Arduino on a regular basis.
2) You get a new tuple each time, there is no update of the tuple itself. But the variable that is shared between the threads is a tuple reference, and this reference is updated to point to the new tuple. And yes, when you look at it you only get the last instance of the calculated values.
3) queues are not necessary unless you have a high variation of execution time in the consumer side (Arduino thread) and don't want to lose an item.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net