Shop OBEX P1 Docs P2 Docs Learn Events
how do I — Parallax Forums

how do I

ArchiverArchiver Posts: 46,084
edited 2003-05-22 13:57 in General Discussion
Hello All,

To vastly reduce the number of my coding headaches, I'd really love
to be able to refer to the I/O pins by different names. Currently,
I'm using the CON keyword to set up statements like:

armup con 0
high armup

which works but since it only creates an alias for the number it's
pretty limiting in the expressions I can use (for output functions,
have to use HIGH and LOW instead of pin = value, etc.).

I'd really rather set it up so I could, for example, use:
armup=1
in place of:
out0 = 1

If I'm reading the manual correctly, the BS1 looks like it can
create a pointer to a specific bit with the SYMBOL command (which
would solve my problem) but the BS2 seems to be lacking this
ability. Is there any way to either create an alias for or a
pointer to a specific I/O bit on the BS2? It seems like this should
be possible somehow.

thanks!

John

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-05-22 10:32
    aliasing works for variables too (same concept as the SYMBOL
    directive):

    armup var out0
    armup = 1

    regards
    Adrian
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-22 13:57
    The BS1's SYMBOL directive allows you to define constants or variables. In
    the BS2, you use the CON and VAR declarations separately. So you can do
    this:

    armUp VAR Out0

    ...and later:

    armUp = 1

    We generally refer to this as aliasing a variable.

    In PBASIC 2.5 (available with the new compiler that you can get as a beta
    release) there is a new directive called PIN. This directive is specifically
    for IO pins and allows the compiler to intelligently handle IO pin
    definitions. The reason is that some parts of the language want the pin
    number as a constant (i.e., 0) , other commands want an IO bit (i.e., In0 or
    Out0). So now you can do this:

    ArmUp PIN 0

    ... and later:

    HIGH ArmUp ' ( compiler converts to HIGH 0 )

    or

    ArmUp = 1 ' ( compiler converts to Out0 = 1)


    -- Jon Williams
    -- Parallax


    In a message dated 5/22/2003 2:47:14 AM Central Standard Time,
    jjghost@t... writes:

    > Hello All,
    >
    > To vastly reduce the number of my coding headaches, I'd really love
    > to be able to refer to the I/O pins by different names. Currently,
    > I'm using the CON keyword to set up statements like:
    >
    > armup con 0
    > high armup
    >
    > which works but since it only creates an alias for the number it's
    > pretty limiting in the expressions I can use (for output functions,
    > have to use HIGH and LOW instead of pin = value, etc.).
    >
    > I'd really rather set it up so I could, for example, use:
    > armup=1
    > in place of:
    > out0 = 1
    >
    > If I'm reading the manual correctly, the BS1 looks like it can
    > create a pointer to a specific bit with the SYMBOL command (which
    > would solve my problem) but the BS2 seems to be lacking this
    > ability. Is there any way to either create an alias for or a
    > pointer to a specific I/O bit on the BS2? It seems like this should
    > be possible somehow.
    >
    > thanks!
    >
    > John
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.