Qestions on cognew and global variables
treborz17
Posts: 76
Am I correct in assuming that when I have an Application calling OBJ Driver #1, and OBJ Driver #1 calls OBJ Driver #2 and so on, that when I want all the drivers to occupy the same·cog, I have Driver #1 initiate the cognew command then all subsequent drivers will appear in the same cog as #1 unless one of them initiates another cog?
Next, I have an application defining Global Variables.· I want the variables to·end up being defined with data that is calculated by a called·OBJ Driver program.· What command or routine do I use to transfer the data calculated in the driver to the main application containing the variables?
Next, I have an application defining Global Variables.· I want the variables to·end up being defined with data that is calculated by a called·OBJ Driver program.· What command or routine do I use to transfer the data calculated in the driver to the main application containing the variables?
Comments
Regarding global variables ... You can either pass the address of a block of global variables to a method in the object and that method will set the global variables using the address passed (and LONG[noparse][[/noparse] ], WORD[noparse][[/noparse] ], and BYTE[noparse][[/noparse] ]) or you can have a method in the object that returns either one of the values or the address of a block of values that the calling program can copy to the global variables. A lot depends on how you generate the data to be used to initialize the global variables.
About the cogs, I understand what your saying about how cognew and coginit work.· What I was not sure about was if a series of OBJ Drivers -- example:
If my custom Lcd/Ping demo·application calls Parallax Library File Debug_Lcd.spin, that I have modified to start in a new cog by a cognew command, will the two OBJ files listed in Debug_Lcd.spin be called into the same new cog that Debug_Lcd.spin was placed or will·they still be operating in the original cog that the application program is still running in?· In other words I want all of the drivers to be in a cog external to the application program.· I probably could be using more accurate teminoligy on the subject but I'm still a novice in Spin.
Robert
What are you trying to accomplish? The Debug_Lcd methods execute in the cog that calls them.
My program is working, I was just curious as to how, and I have that solved now.
Thanks again,
Robert