Proper way to call a method used by object further down the chain
LarryG
Posts: 50
Help a brother out, donate a cog [noparse]:)[/noparse]
I am running tight on cogs, and would really like to keep to one Prop chip for my bike computer if at all possible.
Master.spin is my main code, I assume runs in cog0
Fred is declared as an obj in Master.spin
Fred declares George as an object
Pub A in Master calls Fred.start
Fred.start starts George in his own cog (George has some heavy stuff and needs his own cog)
Pub B is some other method in Master.spin
Questions:
1) Can Pub B make use of methods in George?
2) If so, what is the proper syntax?
2) If not, do I need declare George as an object in Master.spin call him separately, and take up another cog?
Thanks for any suggestions.
-Larry G
I am running tight on cogs, and would really like to keep to one Prop chip for my bike computer if at all possible.
Master.spin is my main code, I assume runs in cog0
Fred is declared as an obj in Master.spin
Fred declares George as an object
Pub A in Master calls Fred.start
Fred.start starts George in his own cog (George has some heavy stuff and needs his own cog)
Pub B is some other method in Master.spin
Questions:
1) Can Pub B make use of methods in George?
2) If so, what is the proper syntax?
2) If not, do I need declare George as an object in Master.spin call him separately, and take up another cog?
Thanks for any suggestions.
-Larry G
Comments
About cogstop, look what Mike Green says about it here:
http://forums.parallax.com/showthread.php?p=872463
Also see page 83 of the Propeller Manual.
I hope that helps a bit.
Long answer: If George does not make use of VAR data but only DAT, then all instances of George share data. This means you start George once but you can then include it in the OBJ fields of any and all modules and George's methods will then be available to all. If George has a start() method it should only be called by one of its followers, but then all can use its methods.