Jump to content
Sign in to follow this  
Ace9

LUA VOR1-2 ADF Fast spin encoder code wont work.

Recommended Posts

Absolutely agree with that, really enjoyed the challenge and what a buzz when the penny dropped, albeit short lived re below, my final hurdle brings new territory now with error messages 😁 So the Code works a?

Could you perhaps see anything wrong with these lines of code. Linda is blowing an error at me and I really have got no clue, I truly have tried everything I can think of, unless I need to declare & initialise a variable? But I think not because I cannot find the original functions initialised anywhere.

I have verified the LvAR - Kn62InnerKnobPull - using Linda's Tracer (setting the values 0 & 1 via Shift+Ctrl+Alt+F10)  

A2A LvAR list states - DME inner knobPull - (L:Kn62InnerKnobPull,bool)  

[E] *** LUA Error: ...linda/aircrafts/A2A_Piper_PA28_180_Cherokee/user.lua:65: attempt to call global 'PA28_5K_on' (a nil value)
-- Original Functions 
-- A2A_DME_toggle
-- A2A_ADFident_toggle

-- Amended both error the same.

function PA28_5K_toggle ()

    if ipc.readLvar("Kn62InnerKnobPull") == 0 then
       PA28_5K_on ()
	else
       PA28_5K_off ()
	end
end
-- -------------------------------------------------
function PA28_5K_toggle ()

	if _tl("Kn62InnerKnobPull", 0) then
       PA28_5K_on ()
	else
       PA28_5K_off ()
	end
end

Thanks Andrew, 

Share this post


Link to post
Share on other sites

What is function PA28_5K_on? The error indicates that it does not exist or has not been defined as a function (ie. nil means it is undefined). It is not your if/then statements or the Lvar that are at fault. 


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

See you are a good teacher, my code is good, thank you 😀

This to pull (Toggle) the inner rotary encoder knob out on the DME to manipulate the last digit. I have scoured the A2A Linda modules looking for this but it seems the A2A Linda Modules do not include the radio changing knobs (encoders) rather they rely on the built in controls in P3D / FSX found in the Linda lib-fsx-lua file i.e.

function _ADF1_RADIO_TENTHS_DEC (p)     ipc.control( 66453, p )  end 
function _ADF1_RADIO_TENTHS_INC (p)     ipc.control( 66454, p )  end 

I have looked at the P3D Event ID and cannot find anything like this for the DME to alter the tenths frequency. (On the COM/NAV 1-2 I have used Lindas shift ability to programme the tenths)

Outter Knob will change the 100's 10's 1's from -117.00khz to 108.00khz

Inner Knob will change the first decimal - 108.60

PA28_5k_On should pull the inner knob out to change the second decimal - 108.65 

Observation: -  

7 hours ago, ScotFlieger said:

"The error indicates that it does not exist or has not been defined as a function"

Whilst the DME encoder can be used in the Linda Tracer successfully to both see the cockpit knob move in/out (push/pull) and the digits change on the DME display, it seems to me that this is missing from the P3D EventId list http://www.prepar3d.com/SDKv3/LearningCenter/utilities/variables/event_ids.html 

So I need to define a function? No because its already define in Linda because Tracer operates the encoder pull/push. So I need to find the function in Linda?

 

Edited by Ace9
Typo

Share this post


Link to post
Share on other sites

Where the built-in FSX functions (offsets/control) work with an aircraft we tend to leave these well alone. As you are finding, radios and nav aids tend to be a mystery unto themselves.

The ipc.control(value) refers to the FSUIPC control values which can be found in /modules/fsuipc documents. 


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

Copy that, I've read and used that document, understand what you are saying. 😃

Many Thanks again my friend.

PS so I need to work backwards, I know the LvAr, so use this to find the ipc.control using Tracer? No, trawl through the FSUIPC document 👍 Got it.. I think

Edited by Ace9
Add PS.

Share this post


Link to post
Share on other sites

I'm gettin there, got the function working on 2 buttons first then combine these in to an if statement and Bingo..

I have learnt so much. 👍 many thanks for your guidance and direction Andrew, onwards and upwards. 

function PA28_5K_toggle_push ()
    ipc.writeLvar("Kn62InnerKnobPull", 0)
end
function PA28_5K_toggle_pull ()
    ipc.writeLvar("Kn62InnerKnobPull", 1)
end

Here is the working code.. 😁

function PA28_DME_5k_toggle ()
    Def = "Kn62InnerKnobPull"
    Var = ipc.readLvar(Def)
        if  Var == 0 then
            Var = Var + 1
        else
            Var = Var - 1
        end
    ipc.writeLvar(Def, Var)
end

 

Edited by Ace9
added working

Share this post


Link to post
Share on other sites

Hi Andrew, like good old Columbo used to say, "Just one more thing" 🤔

I cannot find much info about developer mode in Linda, is it possible to select an Lvar in Linda tracer, and have it show the ipc.control and any offset. Thus far have not been able to achieve this, am I wasting my time? 

Many Thanks again

Share this post


Link to post
Share on other sites

The Developer mode and tracer are just tools to help with the hard job of finding out how an aircraft developer may have implemented their creation.   Lvars, offsets and control codes are completely independent of each other. Description for the later 2 can be found in the FSUIPC documents. The Lvars are purely in the developers gift. Most of the time you can surmise what they do from the description. All have to be explored with dogged determination. There are few shortcuts to hard and time consuming graft. 


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

That's my understanding thus far, its fun to investigate and hit gold every now and again.

Cheers.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...