DME generic selector knob control

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Message
Author
User avatar
Ralph
Posts: 7917
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: DME generic selector knob control

#11 Post by Ralph »

Please post your script.

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#12 Post by ramberga »

Ralph- attached is the LUA script file from the generic Bendix/King DME display instrument that I added a rotary switch to.

A couple of things to note:
1. in the function 'new_state', the argument 'direction' has no value if called by the hw_switch_add function. So, I hard-coded 'directiuon = -1' into the body of the function, so the switch would operate in the clockwise direction:

function new_state (state, direction)
direction = -1
persist_put(persist_power, var_cap(state + direction, 0, 2))


2. I tried both ways of using the 'hw_switch_add' function call, and you will see one of them commented out in the body. I tried it both ways. Currently, I am using the 'hardware_id' version of the function call and hard-wiring the pin numbers, but it made no difference which version I used:

-- switch add
dme_switch = hw_switch_add ("ARDUINO_LEONARDO_A_D2", "ARDUINO_LEONARDO_A_D3", "ARDUINO_LEONARDO_A_D4", new_state)

--dme_switch = hw_switch_add ("DME selector knob", 3, new_state)

switch_set_position (dme_switch, persist_get(persist_power))


So, if I run the script in the 'create/edit' tab, all is well. If I leave the instrument in 'run' mode, then go back to the normal 'home' tab, it still runs fine. If I stop the instrument in the 'create/edit' tab, then try to run the instrument in 'home' mode, the hardware function does not work (but the instrument works by using the mouse if I put the 'switch_add' function call back in).

Thanks for your time, Ralph - realize you are really busy.

Pete
logic.lua
(5.85 KiB) Downloaded 119 times
logic.lua
(5.85 KiB) Downloaded 125 times

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#13 Post by ramberga »

P.S. I did the same thing to the VOR NAV1/ILS instrument, only added an encoder:

dial_obs = hw_dial_add ("ARGUINO_LEONARDO_A_D6", "ARDUINO_LEONARDO_A_D7", "TYPE_1_DETENT_PER_PULSE", 1, new_obs)

Again, if I run the instrument in 'create/edit' tab, it works fine with an encoder. If I keep it running, but go back to the 'home' tab and run AM with X-Plane running, it works fine. If I stop the instrument in the 'create/edit' tab, and run the previous DME instrument, again all is fine.

I cannot run both instruments at the same time in 'create/edit', so I have to sacrifice one over the other to get one to work when I run AM in the 'home' tab with X-Plane also running. Both instruments cannot be run at the same time when in 'create/edit'.

Pete
logic.lua
(5.29 KiB) Downloaded 126 times

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

Re: DME generic selector knob control

#14 Post by Keith Baxter »

Hi,

<Home> and <Create/Edit> run outside of each other. So .... One has to restart after any code change. You cannot run two instruments in <create/edit>. You can combine two instruments into one.

I will look into your code but request that you place your code within the </> tab above.

Hope this helps all in understanding.

If all else fails. Catch up with one of us on the discord. Guidance and knowledge sharing is what we are about so that your AM experience is maximized.

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 

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#15 Post by ramberga »

Keith - do I have to re-add the instrument to the panel I am using in the 'home' tab after I edit the instrument in 'create/edit'?? That might be my problem.

Pete

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#16 Post by ramberga »

Keith - bingo. That was the problem. The instrument you are editing in 'create/edit' needs to be added to the instrument panel in 'home'. The current instrument in 'home' is not the updated one.

So, what I am finding is that if you edit an existing instrument from a current panel - in this case I had added the DME instrument to my C172SP panel beforehand - that instrument is the OLD version, not the updated one.

Is that correct? If so, is that explained somewhere that I missed (I must have spent 10 hours trying to figure it out!!)?

Pete

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#17 Post by ramberga »

Guys- after setting a new world record on making mistakes while trying to get an existing instrument to be controlled by an external hardware device, I wrote an article (for myself, so I wouldn't forget) on how to add a hardware device in the future.

Help yourself to it, make corrections or whatever you like - maybe it will help somebody else. If there are errors, let me know and I will correct them.

Pete

Google document link:
https://docs.google.com/document/d/e/2P ... OrZaa2/pub

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: DME generic selector knob control

#18 Post by Sling »

Hi Pete,

The very first thing to be done when modifying an existing instrument is to clone it. Note that any changes made to an existing instrument will be lost if it is updated. By cloning the instrument is given a new unique UUID. Any existing panel will be using he old UUID so you need to remove the old instrument and add the new one. You only need to do this once and not for every edit. It’s just so the panel is using the UUID of your modified version.

I think you have it now but hopefully this explains what you were experiencing. Note that some hardware can be directly mapped to the existing soft callback without any other changes required.

Tony

ramberga
Posts: 25
Joined: Sat Dec 19, 2020 10:47 pm

Re: DME generic selector knob control

#19 Post by ramberga »

Tony - suppose I don't clone the original instrument. Suppose I do all of the edits to the original instrument (which I understand not to do). If I restart AM, will the instrument get updated because it has the same UUID as originally?

Oh, what's the 'UU' stand for? I figure 'ID' is - you know - id.

Pete

P.S. I updated the article I wrote to include a step to clone the original instrument.
https://docs.google.com/document/d/e/2P ... OrZaa2/pub

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: DME generic selector knob control

#20 Post by Sling »

Pete,

The UU stands for Universally Unique. Instruments get updated from time to time but there is no telling when it may be overwritten, which is why it’s best to clone before you start.

Tony

Post Reply