Shop OBEX P1 Docs P2 Docs Learn Events
Object Questions — Parallax Forums

Object Questions

MasterCMasterC Posts: 39
edited 2009-08-27 20:47 in Propeller 1
So, I'm·just jumping into using I2C devices, and I'm·looking at some of the objects in the object exchange.· My real question below is really applicable to objects in general, but here's a side question about the I2C drivers:

My Side Question: ·I've taken a look at the Basic_I2C_Driver v1.1 by Mike Green, the i2cDemoApp v2.1 by James Burrows (based on Mike Green's), and the I2C SPIN Object v2.0 by Dave Custer (based on James Burrows' which is based on Mike Green's).· My question is, which would be the best starting point to use as a full-featured and generic I2C object?· I was·leaning towards the last one (by Dave Custer), but I haven't seen·that one·come up much when searching the forums.

My Real Question:
OK, now for my real question.· In browsing the i2cDemoApp, I noticed that it includes as on object the basic_i2c_driver.· However, it also includes several other objects for particular i2c devices, each of which also includes the basic_i2c_driver object.· So, does that mean the same code is redundantly included like 8 separate times?· Or is the compiler (or whatever you call it) smart enough to only include one copy of the object that is reference multiple times?

Thanks for the help!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-27 19:58
    1) The compiler is smart enough to include the code for an object only once regardless of the number of times and places it's referred to in the overall program. Each instance of the object does have its own unique data area for variables (VAR).

    2) There are now several other I2C objects including one in assembly that's used internally in FemtoBasic (sdspiFemto.spin), but is usable by itself. There's some I2C support in the BS2 Functions object as well.

    The answer to your question about which object to start with depends on what you want to do with it and whether the demo program included provides support for the devices you want to start with. If you're going to just use I2C memories, the Basic_I2C_Driver is fine by itself. James' and Dave's objects include support for various other I2C devices.
  • MasterCMasterC Posts: 39
    edited 2009-08-27 20:47
    Mike Green said...
    The compiler is smart enough to include the code for an object only once regardless of the number of times and places it's referred to
    Wow, I was not aware of that for some reason!· Would have made things easier a while back when I was frustrated that I couldn't access a child object's children from·my main object.· Apparently, I could have just included the grandchild object in the main as well without much penalty.· Or, on 2nd thought, maybe that wouldn't have gotten me what I was after at the time anyway, due to the·unique variables.

    Anyway, cool.· Thanks!
Sign In or Register to comment.