Shop OBEX P1 Docs P2 Docs Learn Events
Conditional Compilation — Parallax Forums

Conditional Compilation

NewzedNewzed Posts: 2,503
edited 2005-11-23 18:03 in BASIC Stamp
I have a program with two variables, dit and dah, which are expressed in milliseconds.· Is the following Conditional Compilation written correctly:

#SELECT $stamp
#CASE BS2, BS2E, BS2PE
· dit = dit */$0100
· dah = dah */$0100
#CASE BS2P
· dit = dit */$03C4
· dah = dah */$03C4
#CASE BS2px
· dit = dit*/$0605
· dah = dah*/$0605
#ENDSELECT

The above snippet tokenized OK.

Thanks

Sid

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-23 15:29
    The CC construct looks fine.

    Question:·Is there any reason to use variables here?· If the Dit and Dah length are designed to be fixed then you could embed those constants into the CC construct -- just a thought if you run short on variable space.

    I'm glad to see that someone else is using Conditional Compilation; it's a great tool.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 15:35
    I tried using the constants dit and dah first, but got an error message:

    Expected label, variable or instruction

    so I converted dit and dah from a constant to a variable and it tokenized OK.· I would rather use constants if there is a way.

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 15:40
    A bit more explanation.

    I wrote dit con 50 and dah con 150, and then tried to use the constants dit and dah in the CC.· That;s when I got the error.

    Dit and dah are not fixed constants - they can be varied by the user to generate code speeds of 5 to 25 wpm.

    Sid
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-23 16:45
    #SELECT $stamp
    #CASE BS2, BS2E, BS2PE
    BSpeed CON $0100
    #CASE BS2P
    BSpeed CON $03C4
    #CASE BS2px
    BSpeed CON $0605
    #ENDSELECT

    dit = dit */ BSpeed


    Sid, you might also need a separate statement for the BS2pe and BS2sx. It depends on which command you are using to create the sound. The PAUSE command is the same (1 millisecond units) on every single Stamp in the lineup, so if you key an external sounder, the different Stamp speeds would be a non-issue. On the other hand, the FREQOUT command has a separate period parameter for each Stamp (except BS2 = BS2e).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 16:56
    Thanks, Tracy

    That takes care of the dits - what about the dahs?

    Would I write dah·= dit * 3

    I presume I make dit a constant - dit con 50 - and forget about dah since it defined in the program in terms of dit.

    I know about the difference in FREQOUT notes - I just haven't cranked that in yet.

    Sid
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-23 18:03
    Right, everything can depend on the dit length, including the pause between elements, the character spacing and the word spacing. From what you said earlier, dit (the time duration) will be a variable that will be determined at run time by user preference. Then all the other durations are multiples of that one, and can be computed on the fly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.