You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since we only have one core to work with on our Atmel 2560, we need to find a solution to run things in parallel. This is called protothreading (At least according to some guy's article I read).
We need this sort of concurrency for many things, for example for cycling the RGB Led through some colors while operating the UI, or for scrolling a list entry while, well, not worrying about having to do that in the list loop. We could also use it for polling for input in a background "thread" (this would require an input rewrite).
Description
The main keyword here is interrupts. The 2560 has a total of 6 timers, that's three more than the usual on more basic Arduino models. Because of that, these timers aren't used by most libraries and are free for us to use. Every timer is capable of outputting a overflow interrupt, which triggers an IRQ on the processor every time it overflows. We can use this to periodically call a method, no matter the current state of our program, to check up on our protothreads or "routines" and execute them if need be.
Every routine needs to have the following properties:
A frequency, a delay that specifies in what intervals this routines wants to be run
A condition, the condition that specifies whether this routine wants to be run, or not
A run method, the method that runs when the frequency delay has passed and the condition is true
(A break condition), the condition that specifies when this routine would like to be removed completely from the list of routines
The last one is in brackets because this could be handled by whoever added the routine, it doesn't need to be handled by the routine itself, though it is probably not bad to implement something like it.
The text was updated successfully, but these errors were encountered:
Introduction
Since we only have one core to work with on our Atmel 2560, we need to find a solution to run things in parallel. This is called protothreading (At least according to some guy's article I read).
We need this sort of concurrency for many things, for example for cycling the RGB Led through some colors while operating the UI, or for scrolling a list entry while, well, not worrying about having to do that in the list loop. We could also use it for polling for input in a background "thread" (this would require an input rewrite).
Description
The main keyword here is interrupts. The 2560 has a total of 6 timers, that's three more than the usual on more basic Arduino models. Because of that, these timers aren't used by most libraries and are free for us to use. Every timer is capable of outputting a overflow interrupt, which triggers an IRQ on the processor every time it overflows. We can use this to periodically call a method, no matter the current state of our program, to check up on our protothreads or "routines" and execute them if need be.
Every routine needs to have the following properties:
The last one is in brackets because this could be handled by whoever added the routine, it doesn't need to be handled by the routine itself, though it is probably not bad to implement something like it.
The text was updated successfully, but these errors were encountered: