|
The
Transponder
|
|||
![]() |
One of the more complex tasks for a seemingly simple device is the Transponder.
The four-digit code can be tuned using four individual controls or a single
rotary control with an integrated pushbutton. This article covers using a single rotary encoder with an integrated pushbutton. |
||
|
Typical Conventions:
|
|||
|
As usual, always include initialization lines in the EPL code. They only need to be included once and should go at the beginning of your EPL code file. First, include the EPIC95 package from Peter Dowson. If you aren't using Peter Dowson's EPIC95 Package, you should be! It's pretty much a necessity to realize the true potential of your EPIC system.
|
#include
EPICVXD.INC #include MACROS.HPL |
||||
|
Now we'll define the display numbers. My Transponder displays just happen to be the first 4 digit on my 32-digit display card, which are labeled 0 thru 3, respectively. |
#define
XPDR0_DSP 0 #define XPDR1_DSP 1 #define XPDR2_DSP 2 #define XPDR3_DSP 3 |
||||
|
The following lines indicate that the display module is '2', the first digit is physical digit '0', which is an absolute value according to the 32-digit display card. Lastly, each display will use only '1' digit. The '0b00000001' turns off the decimal point for each digit.
|
definedisplay(XPDR0_DSP,
2, 0, 1, 0,0,FALSE, 0b00000001) definedisplay(XPDR1_DSP, 2, 1, 1, 0,0,FALSE, 0b00000001) definedisplay(XPDR2_DSP, 2, 2, 1, 0,0,FALSE, 0b00000001) definedisplay(XPDR3_DSP, 2, 3, 1, 0,0,FALSE, 0b00000001) |
||||
|
The pigeonhole call ensures that every time the transponder value changes within the flight sim engine, the 'Transponder' routine is called, thereby updating the display. Pigeonhole 5 is where the transponder values reside. |
DefinePH(5, Transponder, 0,0,0,0) ;Transponder | ||||
|
Flags required for the math used in deriving certain values |
Var16(Remdr)
var16(temp16) var(Temp) var(temp8) |
||||
| These flags will track which is the 'Active' digit, so the program can keep track of which digit is being tuned | FLAG(XPDR0_FLAG,
FALSE) FLAG(XPDR1_FLAG, FALSE) FLAG(XPDR2_FLAG, FALSE) FLAG(XPDR3_FLAG, TRUE) ;BE SURE YOU SET THIS TO TRUE! |
||||
|
THe INIT{} section merely initializes the rotary card (Provided you have one) and sets the Transponder digits to a -DASH-. This is for nothing more than being fancy but is also a good way to determine if your EPIC card has intialized correctly. The statement SENDDATA(2,0,0x0b) can be explained as: Send a -DASH- to Digit '0' on Module 2, which happens to be the display module. (Physical Digits are numbered 0 thru 31) Likewise, SENDDATA(2,0,0x1b) means send a -DASH- to Digit '1' on Module 2.
|
:init{
|
||||
|
I'll be the first to admit I'm not happy that the code in red didn't workk
and I have no idea as other than perhaps it's a compiler limit. There seems
to be a limitation in the EPIC compiler that allows up to 3 IF statements,
but not 4. Originally, this is what it looked like... |
Don't
Use!!!
|
||||
|
Because of the Compiler limitation, I had to rewrite the code above like this: It's a little clumsy, but still gets the job done.
|
:XPDR_Chk
|
||||
| Set FLAGS according to which digit was last tuned and which one should be tuned next. It sends a -DASH- to the digit that will be tuned. |
:XPDR0_SET{ |
||||
| This
routine is in charge of sending joystick button events to the simulator
depending on which flag is currently set. I'm curious that this routine
works and :XPDR_CHK doesn't, considering it also contains 4 separate IF
statements. The joystick events are interpreted in the FS2000.CFG file,
which is a separate article. |
:XPDR_CHG
|
||||
| Finally,
the button events: Button 150 (Which is most likely different on your EPIC
system) sets the digit to be tuned, while button 180 tunes the digit. |
DefineButton(150,
Off, XPDR_CHK) DefineButton(180, ON, XPDR_CHG) DefineButton(180, OFF, XPDR_CHG) |
||||
| Lastly, here's the new Transponder section in the FS2000.CFG |
[JOYSTICK_00] |
||||