Shop OBEX P1 Docs P2 Docs Learn Events
Importing pin constants? — Parallax Forums

Importing pin constants?

bte2bte2 Posts: 154
edited 2013-03-15 00:17 in General Discussion
Hi, this might be completely obvious, but I was wondering if there was a way, using Propeller Tool, to maintain a separate file of pin constants from my main object file.

Right now I have a complete program that I would like to use with different pin assignments depending on which board I load it into, without maintaining different versions of the master program or copying and pasting the pin constants or editing the master in any way (if possible)

For example, I might have 3 different boards that I want to do the same thing, just with different pins.

I would LIKE to have a file structure like:

board1pinouts.spin
|___masterprogram.spin

board2pinouts.spin
|___masterprogram.spin

board3pinouts.spin
|___masterprogram.spin

, where I open the file with the board-specific constants, and this file would then "include" my master.

Can I do it this way somehow, or am I just missing it?

Thanks in advance! -bryan

P.S. I did read the manual, and I did try to search the forum before I asked.

ETA- I am aware of the concept of objects, what I am trying to avoid is manipulating the master in any way. Right now, I have a separate commented line for selecting different versions of the same object that I remove the tick to employ that particular board. I would rather use the pinouts file as the top object and have the compiler insert the master program inline. This way, each of my Propeller boards can have it's own unique pinout file that I can use for any program.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2013-03-14 23:52
    Create a file containing an object that has all the pin constants and other constants you need defined in an CON section. I guess you will need an empty PUB statement in there to allow it to compile.
    Include that file into all your other apps objects, as needed, in the normal OBJ section.
    You can include that constants object in any number of other objects in a single program without any problems.
    I think that does what you want.
  • bte2bte2 Posts: 154
    edited 2013-03-15 00:08
    Thanks for responding. I was thinking along those lines too- it almost seemed like my master would be an object of my pinout file, and that is where I got confused. A simple "include" compiler directive is what I am really looking for, then I could write:

    File: C:\My Stuff\My Board1\toaster.spin

    con
    heater = 0 'pin0
    latch = 1 'pin1
    sensor = 2 'pin2
    etc...

    include "C\Propeller\perfecttoastercontrolthatIdontwanttomesswith.spin"

    end
  • bte2bte2 Posts: 154
    edited 2013-03-15 00:17
    Whenever I make a board, it gets a 4-digit hex ID number and a directory with the same name. I try to make my boards usable for more than one particular application. Inside that directory are different files that assign names to particular pins that are to be passed to the master.

    So inside a directory, there might be:

    Board1234toaster.spin
    Board1234washingmachine.spin
    Board1234dishwasher.spin
    Board1234trashcompacter.spin


    They are all the same board, but run different programs. It would be great to merely click on the board-specific file and have it do the rest automatically. If my master needs tweaking, the changes would appear for any board file that subsequently called it.
Sign In or Register to comment.