Shop OBEX P1 Docs P2 Docs Learn Events
Shareing Objects? — Parallax Forums

Shareing Objects?

photomankcphotomankc Posts: 943
edited 2009-08-22 21:50 in Propeller 1
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.

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-22 21:18
    Depends what the problem is, here are 2 examples

    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,
  • photomankcphotomankc Posts: 943
    edited 2009-08-22 21:50
    Thank you much!· I'll start looking through those to get the idea.
Sign In or Register to comment.