T-6A Texan II Radio Management Unit (RMU)

Working on a instrument project or just finished a project? Show it to others!

Moderators: russ, Ralph

Message
Author
thistlehead
Posts: 6
Joined: Mon Jul 19, 2021 7:58 pm

T-6A Texan II Radio Management Unit (RMU)

#1 Post by thistlehead »

Okay. I realize I am a hack. LOL
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.
Model vs. Display.JPG
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:
CJS datarefs.JPG
CJS datarefs.JPG (37.3 KiB) Viewed 3554 times
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)
Last edited by thistlehead on Tue Jul 20, 2021 5:55 am, edited 1 time in total.

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: T-6A Texan II Radio Management Unit (RMU)

#2 Post by JackZ »

Well, apart the font that is obviously different, so far so good.

What is your current problem exactly ATM?
Are you sure that all the Dataref returned by XPlane are INT? Seems unusual to me, but I can't tell for sure, as I don't have the T6A addon and don't intend to have it, especially at the price of 99$! :D
As per displaying the code properly in your post, just select the whole code part in the editor then press the </> button to add code markers.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

thistlehead
Posts: 6
Joined: Mon Jul 19, 2021 7:58 pm

Re: T-6A Texan II Radio Management Unit (RMU)

#3 Post by thistlehead »

Jacques,

You have good intuition. You are correct about string vs. integer. I can't seem to handle the data (would help if I had one smattering of background with Lua) to do anything other that txt to the screen. I have tried some crude (and maybe incorrect) if else, or if then but I run into error of "nil" no matter what i do. I can see that the data has been retrieved and is displaying correctly with the built in dataref viewer in Air Manager. BTW is there anyway to change the font in my code? I think Air Manager only has the one font?

Best Regards,

David

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: T-6A Texan II Radio Management Unit (RMU)

#4 Post by Keith Baxter »

Hi David,

1) you are using the default font. You can use any font you like by downloading the font and placing the .ttf file in the <resources> folder. You might be able to find the font that the AirFrame uses in the aircraft resource folder.

2) AM does have some "Included fonts".
http://siminnovations.com/wiki/index.php?title=Txt_add

3) txt_add() needs to be a string. A "int" is not a string and has to be converted to a string AFTER any manipulation.

Code: Select all

new_uhf= tostring(uhf/100)
 txt_set(uhftxt, string.format("%.2f", new_uhf) )
So what I am saying is. A string cannot be used in any math calculations and text must be a string. The two lua functions are tostring() and tonumber()

I would suspect that the datarefs you are using are "FLOAT". What does DRT say they are?

If you want some one-on-one tuition a would be happy to help on the discord. I am sure Jacques would also assist if you ask him.

This type of instrument I prefer to use canvas_draw(). That does not mean that what you are doing is wrong. Just a cleaner way with a few different options.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

thistlehead
Posts: 6
Joined: Mon Jul 19, 2021 7:58 pm

Re: T-6A Texan II Radio Management Unit (RMU)

#5 Post by thistlehead »

Hello Keith,

I will take your code snippet and rework my code. Your help in this matter is most appreciated, as is Jacques'. What time zone are you? I would very much like to use discord for some guidance. I am trying to build a very modest procedure trainer for my son. He is a student pilot in the RCAF and is just about half a year from wings. He will be returning to training after finishing his last year of University and wants to get up to speed before hitting the flight line again. I'm GMT -8.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: T-6A Texan II Radio Management Unit (RMU)

#6 Post by Keith Baxter »

David,

I am UTC +2 so 09H40 now.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: T-6A Texan II Radio Management Unit (RMU)

#7 Post by JackZ »

For starters, I would suggest you put the font properties into a string, so later modifications will be way easier. See code below.

As Keith said, changing the font is simply a matter of specifying which font (should be a TTF file) you want to use.
If nothing is specified, AM will use the « Digital » font style as a default.
If the font you want to use is part of the 7 styles available in AM, there is no need to install it at all, otherwise the corresponding font should be placed in the resources folder.

Code: Select all

font_style1= "arimo_bold.ttf;"
font_size1= "size:160px;"
font_color1= "color: limegreen;"
font_halign1= "halign: left;"
font_valign1= " valign: top;"
font_string1=font_style1..font_size1..font_color1..font_halign1..font_valign1
——
font_style2= "arimo_bold.ttf;"
font_size2= "size:140px;"
font_color2= "color: limegreen;"
font_halign2= "halign: left;"
font_valign2= " valign: top;"
font_string2=font_style2..font_size2..font_color2..font_halign2..font_valign2
——-
font_style3= "arimo_bold.ttf;"
font_size3= "size:180px;"
font_color3= "color: limegreen;"
font_halign3= "halign: left;"
font_valign3= " valign: top;"
font_string3=font_style3..font_size3..font_color3..font_halign3..font_valign3

img_add_fullscreen("RMU_Background.png")

divider1txt = txt_add("______________", font_string1, 20, 270, 1170, 160)
devider2txt = txt_add("______________", font_string1, 20, 670, 1170, 160)
devider3txt = txt_add("______________", font_string1, 20, 1070, 1170, 160)
devider3txt = txt_add("______________", font_string1, 30, 1460, 1170, 160)

UHFlabeltxt = txt_add("UHF", font_string2, 70, 20, 240, 140)

uhftxt = txt_add("---.--", font_string3 , 500, 20, 700, 180)
uhfstbytxt = txt_add("---.--", font_string2 , 70, 250, 500, 140)
VHFlabeltxt = txt_add("VHF", font_string2, 70, 420, 240, 140)
com2txt = txt_add("---.--", font_string3, 500, 420, 700, 180)
com2stbytxt = txt_add("---.--", font_string2 , 70, 650, 500, 140)
NAVlabeltxt = txt_add("NAV", font_string2, 70, 1620, 240, 140)
nav1txt = txt_add("---.--", font_string3, 500, 1620, 700, 180)
nav1stbytxt = txt_add("---.--", font_string2, 70, 1850, 500, 140)
uhfchanneltxt = txt_add( "--", font_string2 , 190, 135, 400, 140)


vhfchanneltxt = txt_add( "--", font_string2, 190, 535, 400, 140)

selectedfieldtxt = txt_add( "--", font_string2, 190, 935, 400, 140)

navchanneltxt = txt_add( "--", font_string2 , 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)
For the rest, unless you are more specific about what is your problem I am unable to go further :D

For any serious work in XPlane and AM, installing the DatarefTool (DRT in short) as an XPlane plugin is a must. It is free.

That way you will be able to figure out what is the type of the Datarefs you will be using.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: T-6A Texan II Radio Management Unit (RMU)

#8 Post by Keith Baxter »

Hi,

I did a bit of research on the BendixKing RMS 555 info is available from here if you want to build the real thing.

https://hobbydocbox.com/79569839-Radio/ ... onics.html


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

thistlehead
Posts: 6
Joined: Mon Jul 19, 2021 7:58 pm

Re: T-6A Texan II Radio Management Unit (RMU)

#9 Post by thistlehead »

Hello JackZ,

Thank you so much for hopping in :-). You font declarations are an eloquent solution. But they seem to perform poorly when run in the code.

Code: Select all

font_style3= "arimo_bold.ttf;"
font_size3= "size:180px;"
font_color3= "color: limegreen;"
font_halign3= "halign: left;"
font_valign3= " valign: top;"
font_string3=font_style3..font_size3..font_color3..font_halign3..font_valign3

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", "font_style3..font_size3..font_color3..font_halign3..font_valign3", 70, 20, 240, 140)
Produces a result of a teeny tiny UHF up in the top left corner?
Tiny UHF from font style code.JPG
I have also found what I think to be the actual font used by the model. I think it is ProFontWindows.ttf

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: T-6A Texan II Radio Management Unit (RMU)

#10 Post by Keith Baxter »

David,

Catch me on the discord now. I am busy with the Bezel using canvas_draw().
ice_screenshot_20210720-203045.png
ice_screenshot_20210720-203045.png (5.57 KiB) Viewed 3444 times
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply