;***************** watch and mouse test demo ****************** ; 1. Edit this file to correspond to buttons you want to assign to do radio tuning ; ; 2. if using EPIC DISPLAY MODULE instead of Flight Link TR-1- ; comment out "#define TR-1" with a ";" ; and edit the definebutton block for button numbers you want to tune with ; and uncomment out the else and the definebutton block ; 3. Run EPL MTEST ; 4. Run LOADEPIC MTEST ; 5. Run EPICTSR ; 6. Run IFT-PRO- For other programs change the X,Y coords to the correct values ; ; If you have button 14 on when you move the mouse display 0 will show the X coord and display 1 ; will show the Y. Click the left mouse button and you will get 1 beep, ; click the right mouse button and you will get 2 beeps ; Button 14 off and the mouse coordinates will no longer update. ; ; rotate the NAV1 clockwise and the mouse cursor will move to the NAV1 display ; and increment the MHZ frequency. Counter clockwise and will decrement the ; frequency. Hit the comm tune buttons and the cursor will move to the comm ; display and update. ; ; Also moving the mouse while tuning is not checked yet, so moving the ; mouse to comm while rotating the NAV knob will start tuning the COMM as ; you will only be sending click data, not position data with the clicks. ; ; This file has some undocumented low level commands. 1 Error and EPIC will bomb so use these ; commands with CAUTION ;#define IFT ;#define ELITE #define FS5 #define TR-1 #define GETDSCMD 81 #define WATCHPHCMD 82 #define MOUSE_EN_CMD 83 #define WATCHQPCMD 85 ;watch types #define WATCHPH 0 ;watch byte(s) to load to pigeon hole #define WATCHQP 1 ;watch byte and execute a Queue Procedure ;on change #define WATCHDISPI 2 ;Watch byte(s) and send to display using ;integer on change #define WATCHDISPB 3 ;Watch byte(s) and sent to display using ;BCD on change ;***************************** ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Macros XXXXXXXXX #macro SetWatchPH(offset,bytes,PHnumb,PHelement) pushc(offset) ;offset relative to DS reg pushc(PHnumb) ;PH number to load pushc(PHelement) ;Starting PH element to load pushc(WATCHPH) ;type pushc(bytes) ;#watch bytes(maximum of 4) exec(WATCHPHCMD) ;EPIC internal command genint #endmac #macro SetWatchQP(offset,bytes,QPnumb) pushc(offset) ;offset relative to DS reg pushc(QPnumb) ;QP number to execute on change pushc(bytes) ;#watch bytes(maximum of 4) exec(WATCHQPCMD) ;EPIC internal command genint #endmac #macro SetWatchDispInt(offset,bytes,displaynumb) pushc(offset) ;offset relative to DS reg pushc(0) ;filler pushc(displaynumb) ;display # to load (must be defined) pushc(WATCHDISPI) ;TSR command: display integer pushc(2) ;#watch bytes (2 for integer) exec(WATCHPHCMD) ;EPIC internal command genint #endmac #macro SetWatchDispBcd(offset,bytes,displaynumb) pushc(offset) ;offset relative to DS reg pushc(0) ;filler pushc(displaynumb) ;display # to load (must be defined) pushc(WATCHDISPB) ;TSR command: display BCD pushc(bytes) ;#watch bytes(maximum of 4) BCD is 2 digits/byte exec(WATCHPHCMD) ;EPIC internal command genint #endmac #macro TSR_Get_DS(segment,offset) pushc(segment) pushc(offset) exec(GETDSCMD) #endmac #define delta 8 #define fastscan 0 #define slowscan 1 #define output 2 definePH(0,updateAirSpd,0,0,0,0) definePH(1,updateMarkers,0,0,0,0) definePH(2,updateDME,0,0,0,0) definePH(3,updatetach,0,0,0,0) #ifdef TR-1 #define beeper 3,9,0b00001000 ;TR1 beeper #define imarker 3,11,0b00000100 ;inner marker led #define mmarker 3,11,0b00010000 ;middle marker led #define omarker 3,11,0b00001000 ;outer marker led #define display_module 3 ;2 for EPIC display module, 3 for TR-1 #define num_digits 5 ;4 for EPIC display module, 5 for TR-1 #define disp1_start 5 #else #define beeper 0,1,0b00001000 ;beeper or led outmodule,row,bit #define display_module 2 ;2 for EPIC display module, 3 for TR-1 #define num_digits 4 ;4 for EPIC display module, 5 for TR-1 #define disp1_start 4 #define disp2_start 20 ;DME start on TR-1 change if different #endif #define num2_digits 3 ;DME definemodule(0,fastscan,0,7) #ifdef TR-1 definemodule(3,fastscan,8,4) definemodule(3,fastscan,2,1) definemodule(3,slowscan,0,2) definemodule(3,slowscan,3,5) definemodule(3,output,8,4) ;TR-1 #else definemodule(0,output,0,4) ;EPIC output module #endif definemodule(4,output,0,4) ;gauge module ;*************** Mouse event definitions ********* #define left_down 0b00000001 #define left_up 0b00000010 #define right_down 0b00000100 #define right_up 0b00001000 var(targetGaugePosition) var(currentGaugePos) var(markers) var16(mouseThrX) ;mouse throttle X position var16(mouseThrY) ;mouse throttle Y position var(ana4) var(current_radio) ;0=commMhz,1=commFract ;2=navMhz,3=navFract ;Elite 2=navMhzup,3=navMhzdn,4=navFracUp,5=navFracDn var(air_speed) var(tach) var(DMEtens) var(DMEunits) var(DMEfract) #IFDEF TR-1 ;*************** TR-1 Displays ************************ definedisplay(0,display_module,0,num_digits,0,0,FALSE,0b00000000) ;COMM definedisplay(10,2,0,num_digits,0,0,FALSE,0b00000000) ;COMM definedisplay(1,display_module,disp1_start,num_digits,0,0,FALSE,0b00000000);NAV1 definedisplay(2,display_module,22,1,0,0,FALSE,0b00000000) ;DME tens definedisplay(3,display_module,21,1,0,0,FALSE,0b00000001) ;DME units definedisplay(4,display_module,20,1,0,0,FALSE,0b00000000) ;DME fractions #ELSE definedisplay(0,display_module,0,num_digits,0,0,FALSE,0b00001111) ;COMM definedisplay(1,display_module,disp1_start,num_digits,0,0,FALSE,0b00001111) ;NAV1 #ENDIF :init{ setmap(2,7) setvar(currentGaugePos,0) setword(mouseThrX,400) setword(mouseThrY,200) setvar(targetGaugePosition,250) call(moveASgauge) delay(20) setvar(targetGaugePosition,0) ;zero Air speed gauge call(moveASgauge) setdisplay(0,1111) ;show something on display setdisplay(1,2222) senddata(3,14,1) ;enable TR-1 outputs for beeper call(clear_markers) setpoint(beeper) ;init beep delay(5) clearpoint(beeper) } :moveASgauge{ ifvar(currentGaugePos,GT,targetGaugePosition) MoveASdown else MoveASup } :MoveASdown{ subvar(currentGaugePos,10) setdisplay(0,currentGaugePos) setdisplay(10,currentGaugePos) setdisplay(1,TargetGaugePosition) senddata(4,0,currentGaugePos) senddata(4,1,currentGaugePos) ifvar(targetGaugePosition,GT,currentGaugePos) jump return ifvar(targetGaugePosition,EQU,currentGaugePos) jump return delay(3) jump(MoveASdown) } :MoveASup{ addvar(currentGaugePos,10) setdisplay(0,currentGaugePos) setdisplay(10,currentGaugePos) setdisplay(1,TargetGaugePosition) senddata(4,0,currentGaugePos) senddata(4,1,currentGaugePos) ifvar(targetGaugePosition,LT,currentGaugePos) jump return ifvar(targetGaugePosition,EQU,currentGaugePos) jump return delay(3) jump(MoveASup) } :beepon{setpoint(beeper)} :beepoff{clearpoint(beeper)} :updatetach{ pushc(0x0103) exec(67) pushc(0x0103) exec(67) exec(74) pushc(0x0103) exec(67) exec(74) popv8(tach) senddata(4,0,tach) } ; this is WRONG ! The intention is to multiply air speed from pigeon hole by 2 , subtract 40 (lowest ; reading on airspeed gauge, multiply by 2 (approx 23 per 10 knots), and add 25 (offset to 40) ; :updateAirSpd{ pushc(0) ;ph0,el0 exec(67) ;push ph8 pushc(0) exec(67) ;again, both on stack exec(74) ;add (*2) result on stack pushc(40) exec(75) ;subract 40 popv8(air_speed) pushv8(air_speed) pushv8(air_speed) exec(74) ;air_speed * 2 pushc(25) ;gauge zero offset (40 knots) exec(74) ;add to 2* airspeed popv8(air_speed) ;result to air_speed variable ; setdisplay(0,air_speed) ;TR-1 comm display senddata(4,1,air_speed) ;gauge } :updateMarkers{ pushc(0x01) ;element 0,PH 1 exec(67) ;push ph8 popv8(markers) ifvar(markers,EQU,0) jump clear_markers ifvar(markers,EQU,1) jump lite_outer ifvar(markers,EQU,2) jump lite_middle ifvar(markers,EQU,4) jump lite_inner } :lite_outer{clearpoint(mmarker) clearpoint(imarker) setpoint(omarker)} :lite_middle{clearpoint(omarker) clearpoint(imarker) setpoint(mmarker)} :lite_inner{clearpoint(mmarker) clearpoint(omarker) setpoint(imarker)} :clear_markers{clearpoint(mmarker) clearpoint(omarker) clearpoint(imarker)} ;**************** DME ;DME is in PH2 in ASCII ; to display it is necessary (for now) to define the DME as ; 3 diplays of 1 digit each ; ; display 2= fraction (PH2 element 3) ; display 3= units(PH2 element 1) ; display 4= tens (PH2 element 0) ; ; each digit need the upper nibble stripped to get numeric value ; :updateDME{ pushc(0x0002) ;ph2 element 0 exec(67) ;push ph pushc(0x0F) ;mask off upper nibble exec(86) ;and popv8(DMEtens) pushc(0x0102) exec(67) pushc(0x0F) exec(86) popv8(DMEunits) pushc(0x0302) ;ph2 element 3 exec(67) ;push pigeon hole element pushc(0x0F) exec(86) ;mask V1 with V2 popv8(DMEfract) ; each Value should be tested for 0x0B and a "-" sent to DME display ; The way it is here a "1" will display setdisplay(2,DMEtens) setdisplay(3,DMEunits) setdisplay(4,DMEfract) } definebutton(13,on,updateDME) ;***** Q procedure ******** ; These events come from EPICTSR ; 1=left mouse button has been pressed ; 2=right mouse button has been pressed ; :rightdown{call(beepon) delay(6) ;120 msecond call(beepoff) delay(6) call(beepon) delay(6) call(beepoff) } :leftdown{ call(beepon) delay(6) call(beepoff) } ;********************************* Mouse button clicks ********* ; These will be sent to EPICTSR and to the PC program ; ; :left_click{mousebutton(left_down) genint ;send event delay(2) ;40 ms mousebutton(left_up) genint ;send event } :right_click{mousebutton(right_down) genint ;send event delay(2) ;40 ms mousebutton(right_up) genint ;send event } ;***************************** Radio tuning ;These X,Y coords are for IFT comm MHZ 600,160 and Nav MHZ 600,100 and were ; obtained by moving the physical mouse to these points, sending to display ; 0(TR1-comm for X coords) and 1(TR1-NAV1 for Y coords) from the EPICTSR :comm_up{ ifvar(current_radio,NEQ,0) {setvar(current_radio,0) mousemove(600,160) } call(left_click) } :comm_down{ ifvar(current_radio,NEQ,0) {setvar(current_radio,0) mousemove(600,160) } call(right_click) } #ifdef ELITE :navmup{ mousemove(515,45) mousebutton(left_down) genint delay(1) mousemove(526,45) mousebutton(left_up) genint } :navmdwn{ mousemove(515,45) mousebutton(left_down) genint delay(1) mousemove(505,45) mousebutton(left_up) genint } #endif ;********************************** #ifdef FS5 :navmup{ ;+++++16 bit variable tests ++++++++ ; addword(mouseThrX,10) ; subword(mouseThrY,10) ; mousemove(mouseThrX,mouseThrY) ;+++++++++++++++++++++++++++++++++++ mousemove(275,275) call(left_click) } :navmdwn{ mousemove(265,275) call(left_click) } #endif ;*********************************** #ifdef IFT :navmup{ifvar(current_radio,NEQ,2) {setvar(current_radio,2) mousemove(600,100) } call(left_click)} :navmdwn{ifvar(current_radio,NEQ,2) {setvar(current_radio,2) mousemove(600,100) } call(right_click)} #endif ;**************************** Q procedure definintions defineqproc(1,leftdown) defineqproc(2,rightdown) ;**************************** :B0on{buttonpress(0)} :B0off{buttonrelease(0)} flag(ds_set,FALSE) var(dsprog,0) flag(ds2,FALSE) flag(watch_set,FALSE) :GDS{ if(watch_set) jump return exec(84) ;Initialize TSR watch and PH structures ;generates interrupt delay(1) #expand TSR_Get_DS(0,0x6E) ;location of Critical break ISR #expand SetWatchPH(0x865,1,0,0) ;airspeed data to PH0,element0 ;NOTE: only 16 bytes allowed in Interrupt ;buffer. Get DS(5 bytes) + Setwatch(7)=12 ;not enough room for next watch. Genint to ;allow room for next watch delay(3) ;Allow 20ms for ISR to clear buffer #expand SetWatchPH(0xB28,1,1,0) ;marker light data to PH 1,element 0 delay(3) #expand SetWatchPH(0x8E1,4,2,0) ;DME to PH2 delay(3) #expand SetWatchPH(0x16c4,2,3,0) ;tach to PH3 setflag(watch_set) } :test_g{ readinpot(4,ana4) senddata(4,0,ana4) senddata(4,1,ana4) setdisplay(0,ana4) setdisplay(10,ana4) delay(1) ifactive(15) jump test_g } :Mousedispon{ pushc(1) exec(MOUSE_EN_CMD) ;TSR mouse coords enable genint } :Mousedispoff{ pushc(0) exec(MOUSE_EN_CMD) ;TSR mouse coords disable genint } ;++++++++++++++++++++++++++++++++ BUTTON DEFINES ++++++++++++ definebutton(0,on,B0on) definebutton(0,off,B0off) definebutton(9,on,comm_up) ;my TQS BTN T2 definebutton(10,on,comm_down) ;my TQS BTN T3 definebutton(8,on,GDS) definebutton(14,on,Mousedispon) definebutton(14,off,Mousedispoff) definebutton(15,on,test_g) #ifdef TR-1 definebutton(151,on,navmup) ;TR-1 NAV1 large knob clockwise definebutton(151,off,navmup) definebutton(150,on,navmdwn) ;TR-1 NAV1 large knob counter-clockwise definebutton(150,off,navmdwn) #else ;definebutton(151,on,navmup) ;TR-1 NAV1 large knob clockwise ;definebutton(151,off,navmup) ;definebutton(150,on,navmdwn) ;TR-1 NAV1 large knob counter-clockwise ;definebutton(150,off,navmdwn) #endif