I am attempting to build a button box (with 5" LCD display) to replicate the Radio Management unit in the Air Force training aircraft model. I have already built previous button boxes and that part of the project should be not too difficult. The hard part is using Air Manager and reading the datarefs (which in itself is easy to do) and then writing them to the 5" screen (which by far is the harder part). What gets displayed on the screen is of course toggled with things like memory presets, and other active selections. here is a side beside photo of where I am currently with my woefully inadequate LUA skills. The digits 01 in the various places on the 5" are the memory frequencies channel number. The 01 in the middle of the screen indicates that the UHF section has been selected (selected field). I took an simple radio selection instrument example that I stole code from, and have been hacking away at the code to get where I am know. Here are the datarefs I am accessing: I welcome any comments or suggestions as I fumble through this. Any code gurus are most welcome to contribute
Here is the code so far (I'm such a hack I don't even know how to format to paste code)
Code: Select all
img_add_fullscreen("RMU_Background.png")
divider1txt = txt_add("______________", "size:160px; color: limegreen; halign: left; valign: top;", 20, 270, 1170, 160)
devider2txt = txt_add("______________", "size:160px; color: limegreen; halign: left; valign: top;", 20, 670, 1170, 160)
devider3txt = txt_add("______________", "size:160px; color: limegreen; halign: left; valign: top;", 20, 1070, 1170, 160)
devider3txt = txt_add("______________", "size:160px; color: limegreen; halign: left; valign: top;", 30, 1460, 1170, 160)
UHFlabeltxt = txt_add("UHF", "size:140px; color: limegreen; halign: left; valign: top;", 70, 20, 240, 140)
uhftxt = txt_add("---.--", "size:180px; color: limegreen; halign: left; valign: top;", 500, 20, 700, 180)
uhfstbytxt = txt_add("---.--", "size:140px; color: limegreen; halign: left; valign: top;", 70, 250, 500, 140)
VHFlabeltxt = txt_add("VHF", "size:140px; color: limegreen; halign: left; valign: top;", 70, 420, 240, 140)
com2txt = txt_add("---.--", "size:180px; color: limegreen; halign: left; valign: top;", 500, 420, 700, 180)
com2stbytxt = txt_add("---.--", "size:140px; color: limegreen; halign: left; valign: top;", 70, 650, 500, 140)
NAVlabeltxt = txt_add("NAV", "size:140px; color: limegreen; halign: left; valign: top;", 70, 1620, 240, 140)
nav1txt = txt_add("---.--", "size:180px; color: limegreen; halign: left; valign: top;", 500, 1620, 700, 180)
nav1stbytxt = txt_add("---.--", "size:140px; color: limegreen; halign: left; valign: top;", 70, 1850, 500, 140)
uhfchanneltxt = txt_add( "--", "size:140px; color: limegreen; halign: left; valign: top;", 190, 135, 400, 140)
vhfchanneltxt = txt_add( "--", "size:140px; color: limegreen; halign: left; valign: top;", 190, 535, 400, 140)
selectedfieldtxt = txt_add( "--", "size:140px; color: limegreen; halign: left; valign: top;", 190, 935, 400, 140)
navchanneltxt = txt_add( "--", "size:140px; color: limegreen; halign: left; valign: top;", 190, 1735, 400, 140)
function PT_radio(uhf,uhfstby,com2,com2stby,nav1,nav1stby,uhfchannel,vhfchannel,selectedfield, navchannel)
txt_set(uhftxt, string.format("%.2f", uhf/100) )
txt_set(uhfstbytxt, string.format("%.2f", uhfstby/100) )
txt_set(com2txt, string.format("%.02f", com2/100) )
txt_set(com2stbytxt, string.format("%.02f", com2stby/100) )
txt_set(nav1txt, string.format("%.02f", nav1/100) )
txt_set(nav1stbytxt, string.format("%.02f", nav1stby/100) )
txt_set(uhfchanneltxt, string.format("%02.0f", uhfchannel) )
txt_set(vhfchanneltxt, string.format("%02.0f", vhfchannel) )
txt_set(selectedfieldtxt, string.format("%02.0f", selectedfield) )
txt_set(navchanneltxt, string.format("%02.0f", navchannel) )
end
xpl_dataref_subscribe("cjs/texanii/radios/uhf_freq_10hz", "INT",
"cjs/texanii/radios/uhf_standby_freq_10hz", "INT",
"sim/cockpit2/radios/actuators/com2_frequency_hz", "INT",
"sim/cockpit2/radios/actuators/com2_standby_frequency_hz", "INT",
"sim/cockpit2/radios/actuators/nav1_frequency_hz", "INT",
"sim/cockpit2/radios/actuators/nav1_standby_frequency_hz", "INT",
"cjs/texanii/radios/uhf_channel", "INT",
"cjs/texanii/radios/vhf_com_channel", "INT",
"cjs/texanii/rmu/selected_field", "INT",
"cjs/texanii/radios/nav_channel", "INT", PT_radio)