stopping a cog than restarting it
lockadoc
Posts: 115
I ask before in the Forum about trying to pause a method , and was hinted at way to do it, but just could not grasp it.I've been trying different ways to do it with no luck.I made this simple object to try it out on and have been at it for a couple of days. Could some-one please show me where I'm being dumb ? I've tried using COGSTOP and COGINIT by looking at the two books I have , don't think thats the way· to do it.
Bill S
Louisville KY.
Bill S
Louisville KY.
Comments
If two cogs need to interact, they can signal each other, usually by one cog using a byte that is set to some value that the other cog checks periodically. If that byte is some value (say 1), then the 2nd cog stops doing whatever it's doing except checking the byte. If the byte gets changed to zero, it starts doing whatever it's supposed to do (and continues to check the byte's value.
Post Edited (Mike Green) : 1/22/2010 8:56:44 PM GMT
John Abshier
stopping a cog is not a selfpurpose. So please tell us what is the bigger thing behind it.
If you tell the forum what you want to achieve in the end.
You wrote about pausing a method. I think you want to achive that something "is done" for a certain time
and then controlled by whatever "not to be done" for a certain time.
Most simple way to do this is a repeat-loop with an if-condition.
best regards
Stefan
I believe the attached demo does what you want -- and notice that it's all wrapped up in one nice, tidy file!
In the main loop a background button debouncer is launched into its own cog. When a button is pressed this cog will change the value of a variable called status which is used by the sequencer cog.
Next a sequencer cog is launched. Note that it reports its id so that it can be stopped from another cog. It also uses an extern value called steptime to affect how it runs, and it will stop in its tracks when the program is put into pause mode (status == 1).
After 30 seconds the sequencer is killed -- just to show you that it can be done.
Spend some time with it; until you fully come to grips with how this works you'd just be spining your wheels and starting new threads that all lead back to the same project.
BTW, there is no need to include the Propeller tool in your archives, you're just wasting Parallax server space. Those of us who would help you have it. Just use
File >> Archive >> Project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Jon, took your advice and played ... and played ... some things had been bothering me about cogs ... now they are quite clear ... thanks!
The sequencer looks neat on the PPDB!
I uploaded what I did in case anyone else wants something more to play with ... I commented most of my additions/changes
cheers ... BBR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The Shoppe at Wulfden
www.wulfden.org/TheShoppe/