Using objects to help multiple connected props choose the correct program and run it.
Clock Loop
Posts: 2,069
See post #4 for final solution.
http://forums.parallax.com/showthread.php/149399-SPIN-file-order-rules-for-SECTIONS-and-pathway-selection-using-pin-input.?p=1198517&viewfull=1#post1198517
http://forums.parallax.com/showthread.php/149399-SPIN-file-order-rules-for-SECTIONS-and-pathway-selection-using-pin-input.?p=1198517&viewfull=1#post1198517
Is it possible to run two seperate paths in a spin file... I need to set pins as different labels in the CON section depending on say, if P0 is high at boot.
So If I were to place code before the first con section would it work?
Or would I need a beginning con section for at least the clock info, and then insert my logic to determine program path? How would I set up multiple pathways in one spin file?
I want to do this because I plan to make a single spin file run multiple pathways depending on prop pins state.
Does a spin file need to start out with con? If you have two con sections, and set two different variable names to the same pin,...
I would imagine that all sections merge no matter the order and two sets of everything just helps organize it all, this means the data it all takes up is doubled.
The extra chunk of data just dosen't get used, and it dosen't really conflict because the spin pathway never let any cog grind the path.
Really, if I understand spin properly, one could pile a bunch of spin programs into one spin file, and then make the prop run any one of all the seperate programs by simply jumping to the MAIN program, due to all CON sections, VAR, DAT, PUB, PRI they all get compiled and put into the eeprom.
Does order of the sections even matter? The only concern being label conflicts?
Anyone know any tricks that can be used in spin files? does it need every section? does CON have to be first? etc?
Comments
You will need to reserve DAT or VAR storage for things that can do different things at runtime, and you can assign them from different CON sources when the program runs depending on inputs and so on.
This program, in fact, has three distinct sections. Of course, the IO pins are what they are on the board, and several methods are common to the three operating modes.
Here's a simplified version of my start-up code
After thinking about it... why not just program the configurations like each configuration is a spin object.
And run then like that too.
So the configuration is launched like an object......
I just tested this method and it works perfectly, I tested it with 11 seperate props in one of two hardware configurations.