Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Multitasking
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multitasking

by Rcayot on Tue Jun 23, 2020 7:57 am

There is a great series by Bill Earl called multitasking on arduino. Is there something similar for circuitpython?

I have done a bit of beginner arduino programming, and would like to move to CP because of all of the great products and supporting libraries at Adafruit. I have yet to find, however, a good guide to using classes for multitasking using CP. and the new years eve drop ball example does not help me, it is more of a state machine example.

Also, any other resources on that subject would be helpful. Most online python resources do not address aspects of physical computing.

Thanks,
Roger Ayotte

Rcayot
 
Posts: 41
Joined: Sat Feb 08, 2020 6:48 pm

Re: Multitasking

by adafruit_support_bill on Tue Jun 23, 2020 9:39 am

the new years eve drop ball example does not help me, it is more of a state machine example.

State machines are the key to multitasking in a purely single-threaded environment. The state machine classes in Dave's ball-drop tutorial are structured a little differently from the state machines in my Multitasking the Arduino series. But overall effect is similar. The main processing loop just needs to call the update function.

To make it multitask, you create multiple state machines and call update on all of them.

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Re: Multitasking

by tannewt on Tue Jun 23, 2020 2:02 pm

Hi Roger,
CircuitPython doesn't support any of Python's concurrency mechanics. There is a long issue about it here if you are interested: https://github.com/adafruit/circuitpython/issues/1380
~Scott

tannewt
 
Posts: 1685
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.