Shareing Objects?
photomankc
Posts: 943
I had a similar question before but this involves a twist from that one.· I have in my application a UserInterface main object·that starts a VoltageMonitor object and a Timer object to track the approximate time.· I have a need for the VoltageMonitor object to also pay attention to time.· What I'd like to do is let the monitor use the same timer the UI is using so I don't burn two cogs with timers.· Any pointers to examples of how to code that?· Can I use pointers for that?· An object is just a position in memory so it seems like it should be possible but I have not been able to find a solid example, assuming you can do that.
Thanks for any help you can provide.
Thanks for any help you can provide.
Comments
pwm_32_sv2.spin is a variaton of pwm_32_v2.spin that is on obex. If you use it from multiple apps it only creates 1 cog. Its a pasm cog, access to the variables shared with the pasm cog is controlled with a lock.
timer.spin is a timer object. Again access to shared variables is via a lock.
The other objects to look at on obex is serialmirror or the 4 port serial object. serialmirror gives a debug port that can be called from any object. 4 port serial can also be used from multiple objects but only uses 1 cog.
Including a object in multiple objects doesn't affect code size, prop tool handles that but you need to handle cogs and multiple access to variables,