Multiple instances of object in Spin 2
I'm configuring a P2 to control a Newhaven LCD with the FT812 video engine. Works great after porting Rayman's code from this thread to Spin 2. The driver basically includes lots of low-level methods for drawing lines, text, buttons, etc. It calls an SPI driver (formerly SPI_Spin but I changed it to gp_asm_spi with same syntax) to communicate with the EVE chip.
I would like to create a separate object with some higher level functions, to draw more complex primitives, so that I can reuse it in other projects. This object would call the low-level EVE methods. So the object hierarchy would be like this:
However, I would still like to be able to call the low level functions from my Main program. So really I need this arrangement:
I'm a bit confused on how to implement this, since there are multiple definitions of the same objects. The EVE driver takes some startup parameters to configure the screen (pin numbers, etc.). I could define these identically in both places, but that seems redundant. My understanding is that if I move the common variables from VAR to DAT, then all calls to either driver object would reference the same values, is this correct?
I'm also not sure how to handle the SPI driver object that they both reference. This driver is directly controlling P2 pins so I would think there could be some pin contention if two instances of the object are defined. Just thinking conceptually it seems like I need something like this:
Or maybe this:
I guess I'm just unclear on how multiple instances of the same object exist together. Method pointers seemed relevant but the description in the manual is brief and I couldn't find any tutorials or further explanation. Object pointers also looked like an option but I'm using Propeller Tool so that might not be possible.
Or I could be going totally down the wrong track--feel free to say so. I would appreciate any suggestions!
EDIT: I should add that everything is running in the same cog.