Jump to content
The simFlight Network Forums

Goflight MCP Displays (Lua file)


Recommended Posts

well hello Pete,

"gfd" Lua library? i had a look in FSUIPC Lua Library dokument whit the variabels and all that stuff.

"gfdDisplay.lua" about it i tryeid to modificate and worked if i delt some lines i got it show only the 12345 and that on the displays and got the window sohwing what was goeing on.

1) how to start, input from fs Airbus X or goflight display set up ?

2) should the there be a place where there is the code whit the numbers the autopilot could use on the display of the goflight displays i mean 0123456789. like you do in other programing tels the device what is useabel.

3) How to identify the display you want to program as whit "gfdDisplay.lua" it only shows on the knob or button pressed after it did the test and then you could press knobs and that. but no identifications on displays

4) about the: gfd.SetDisplay(model, unit, id, "display text") what i know or think is gfd.SetDisplay(GFMCP, unit ?, id ?, "display text" ?) about the text should it be an name like ("L:AB_AP_ALTSTEP") to read that or should it be another way.

not ask me to do all your work for you, im just need a way of info to get started.

Link to comment
Share on other sites

  • Replies 79
  • Created
  • Last Reply

Top Posters In This Topic

well hello Pete

I've changed the title of this new thread of yours to refer to Lua, not your "lau" which will only succeed in confusing folks. Please do try harder to spell proper names properly!

"gfd" Lua library? i had a look in FSUIPC Lua Library dokument whit the variabels and all that stuff.

So, you can read the section entitled "the Go-flight Device (gfd) Library", then. It comes after the Sound library and is currently the last section in the Lua Library Reference document.

"gfdDisplay.lua" about it i tryeid to modificate and worked if i delt some lines i got it show only the 12345 and that on the displays and got the window sohwing what was goeing on.

Okay, so you can look at that file too. It is an example of how to manipulate GF displays.

1) how to start, input from fs Airbus X or goflight display set up ?

2) should the there be a place where there is the code whit the numbers the autopilot could use on the display of the goflight displays i mean 0123456789. like you do in other programing tels the device what is useabel.

I've no idea. Can you read the AirbusX autopilot values anywhere? It may be like the PMDG aircraft and not export them anywhere. Possibly they are readaable via L:vars, but you'd need to work that out.

3) How to identify the display you want to program as whit "gfdDisplay.lua" it only shows on the knob or button pressed after it did the test and then you could press knobs and that. but no identifications on displays

Try and see. You can't do any harm. As I already told you, mostly the GF displays are numbered either left to right or right to left.

4) about the: gfd.SetDisplay(model, unit, id, "display text") what i know or think is gfd.SetDisplay(GFMCP, unit ?, id ?, "display text" ?) about the text should it be an name like ("L:AB_AP_ALTSTEP") to read that or should it be another way.

Oh dear. How many GF MCPs do you have? If only 1 the unit number will be 0. The second is 1 and so on. The id is the specific display number, as I already said. The text is what you want to display. It will be a number, won't it? You don't get altitudes reading "L:AB ...", and in any case the display probably won't take letters and the string is far too long for a 5 digit display!!!

Please think things through a little more before posting. You are wasting both of our time!

not ask me to do all your work for you, im just need a way of info to get started.

You need to read what is already available and think a little, please. I am getting the impression that all this is rather beyond you.

I don't even know if what you want to do is possible. It wasn't for the PMDG 737 for instance, which is why folks had to use GF or special PMDG drivers.

Pete

Link to comment
Share on other sites

I don't even know if what you want to do is possible.

Further to this, by monitoring the L:vars (using the Lua plug-in provided for this, the one called "Log Lvars"), I see that, for instance, the MCP's altitude reading is obtainable by reading the L:var called "L:AB_AP_ALT_Select". So all you'd need to do is read that into a variable, say alt then create the decimal string you need to display by using using string.format("%05d", alt).

Pete

Link to comment
Share on other sites

Should i use ipc.lineDisplay(“string”) ?

No. why? That, as documented, displays stuff in a Window in your FS. Why do you want that? To display things on a Go-Flight device you use the Go-Flight functions, as listed for the gfd library. I already told you to use that. Why don't you read the documentation? Why not look at the examples?

Pete

Link to comment
Share on other sites

I have already reade the 2 last pages of the dokument several times, but all those words and no exampels of codes in an text or some, is why i dont get it. Think it is simpel if you understand how to use it. as yes it should only bee the goflight display. as yesterday i also think it was 1 of the L:vars there was needed and you found it today.

about look at the exsampels i told i did and made some experiments and made this gfd.setDisplay(GFMCP,0,4,"LN123") then i found out of that but, realy cant find out how to do that you was sayeing.

Sorry mabee it just me there is stupid but tryeing my best to understand it.

Link to comment
Share on other sites

well it did but just test.

about what i dont understan is how to get the goflight display show the data from fs autopilot insted of the LN123 and how to get it work whitout having to push a button as i did to get this working or is it neaded just to activate the lau.

to get back to the display you said it was the reading or so "L:AB_AP_ALT_Select" but next step would then be to get the data to the display insted of the LN123.

as this is some thing i dont understand what you'd need to do is read that into a variable ("L:AB_AP_ALT_Select" i think you ment), say alt then create the decimal string you need to display by using using string.format("%05d", alt).

as should it look like this

XXXXXXXX=("L:AB_AP_ALT_Select", 0123456789)

string.format("%05d", alt)

gfd.setDisplay(GFMCP,0,4,"%05d", alt)

Link to comment
Share on other sites

w

about what i dont understan is how to get the goflight display show the data from fs autopilot insted of the LN123 and how to get it work whitout having to push a button as i did to get this working or is it neaded just to activate the lau.

There's no such thing as a "lau". Please get that right. You won't get anything else right if you cannot correct that one annoying thing.

to get back to the display you said it was the reading or so "L:AB_AP_ALT_Select" but next step would then be to get the data to the display insted of the LN123.

You need a Lua plug-in which is running continuously, in a loop, rwading the variable at intervals and writing it to the display when it changes. Something like

prevalt = -1

while true do
    alt = ipc.readLvar ("L:AB_AP_ALT_Select")
    if (alt ~= prevalt then
         stringalt = string.format("%05d", alt)
         gfd.setDisplay(GFMCP,0,4,stringalt)
         prevalt = alt
    end
    ipc.sleep(500)
end

To make this run all the time you could save it as ipcReady.lua, which is run automatically when FS is ready to fly. Or you'd have to program a button or keypress to run it when you wanted to fly the AirbusX.

You could then add the other MCP variables in the same way, in the same loop.

Not sure what you are thinking in this proposal:

XXXXXXXX=("L:AB_AP_ALT_Select", 0123456789)

string.format("%05d", alt)

gfd.setDisplay(GFMCP,0,4,"%05d", alt)

What's XXXXX, what's 0123456789, where's the formatted string going, what is %05d doing as an extra parameter in setdisplay?

Please read more carefully. Programming is an EXACT science, you can't make it up as you go along as you are doing. Stringing together bits of nonsense just won't work! THINK! You surely can't really be stupid if you can understand flying, and certainly not advanced aircraft like the Airbus.

Pete

Link to comment
Share on other sites

well year know my last part was ????? and yes i know things have to be right set up and all that as worked whit some c++ programing 2 years ago but it was just 1 week so dident learn much.

well i just toke up this fight to get it working as iritating me so much that we have so many hardware and no of them is abel to cumunicate by default. but i know it is not posible as vaulve is different form plane to plane to make it as close to real. just a bit disapointing to have hardware then.

well i tryeid your code but dident showed anything could there be some thing i did wrong i have set all gf device comands i the goflight driver to no assignment. and copy the file from goflight folder to modul folder as shown in te dokument.

by the way if it wasent right it would have worked whit my code from today it gave me an this in the log over and over again

********* LUA: "ipcReady" Log [from FSUIPC version 4.626] *********

162538 System time = 08/09/2010 22:26:22, Simulator time = 07:24:26 (05:24Z)

162538 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"

162538 *** LUA Error:(x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:5: ')' expected near 'then'

162538 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"

162538 System time = 08/09/2010 22:26:22, Simulator time = 07:24:26 (05:24Z)

********* LUA execution terminated: Log Closed *********

but many thanks for show it, as it is an big help you provide.

Link to comment
Share on other sites

.

by the way if it wasent right it would have worked whit my code from today it gave me an this in the log over and over again

162538 *** LUA Error:(x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:5: ')' expected near 'then'

Ah, yes. Sorry. That message was my last before dashing out for a Table Tennis match and I made a silly error, which you should really have seen as soon as you got that error Message? Look, it says:

ipcReady.lua:5: ')' expected near 'then'

which means line 5 of "ipcReady.lua" has an error, there's a missing ).

Look at line 5:

    if (alt ~= prevalt then

Don't you see that there's a ( and no )? Obviously the intention was for this to be

    if (alt ~= prevalt) then

which will work, though it could equally be

    if alt ~= prevalt then

as Lua doesn't need parentheses around conditions -- that's a C requirement and my habit, since I'm a C programmer.

You will need to be able to find simple errors like these -- they won't be hard to find as the Error report tells you exactly where to look.

Please note that I'm only showing you code snippets like this so that you can work out how to do them yourself. I'm not intending for you to simply copy them and use them, but to read them, and understand them. If you don't put such effort into it you will not finish what you need to make the MCP work with the Airbus X.

Pete

Link to comment
Share on other sites

well pete, yes that was an easy to spot, but thanks for the hint of where to look, that could be useful.

should that mean that this was the way it should look and then i need to finde out what there is need to be changesed to get it work or does there stil miss 1 or some lines below or above the text?

prevalt = -1

while true do

alt = ipc.readLvar ("L:AB_AP_ALT_Select")

if (alt ~= prevalt) then

stringalt = string.format("%05d", alt)

gfd.setDisplay(GFMCP,0,4,stringalt)

prevalt = alt

end

ipc.sleep(500)

end

by the way i have some things i would aske about to get better understanding what dose prevalt = -1 mean or tell ?

As i reade it if that is true it should read the altitude which is coming from the L:var called "L:AB_AP_ALT_Select" then i dont understand if (alt ~= prevalt) then and stringalt = string.format("%05d", alt) well i understand that stringalt must be the name whis is the same as string.format("%05d", alt) and that must be some kind of an identification that the goflight display know if the name is stringalt it would be = string.format("%05d", alt) then prevalt = alt is also unknown as it just stands there should that have been used before some thing and not in the end ??

Link to comment
Share on other sites

by the way i have some things i would aske about to get better understanding what dose prevalt = -1 mean or tell ?

It simply means set the value of a viariable called "prevalt" to -1. I am using prevalt as a memory for the previously display altitude, so we know when to change it. since -1 is not a possible MCP altitude, setting it initially to -1 will make sure we display the first value we get.

As i reade it if that is true it should read the altitude which is coming from the L:var called "L:AB_AP_ALT_Select"

Mo, we read that altitude into a different variable called "alt".

then i dont understand if (alt ~= prevalt) then

That says "obey the following lines, up to 'end' if alt is not equal to prevalt". In other words it is where we test if the altitude has changed. We don't want to keep displaying the same value several times a second. It wastes time and may even make the display flicker.

and stringalt = string.format("%05d", alt)

That simply converts the number we have in the 'alt' variable into a string of 5 decimal characters, with zero (0) padding on the left if needed. So 200 becomes "00200" and so on.

Please, I recommend strongly that you follow the links in the Lua documents to the Lua website and learn a little bit more abouyt the Lua programming language. you don't need much, nothing complicated, just basics.

Pete

Link to comment
Share on other sites

pete i am so thanks full for your support and happy that things now seem to work. by the way may i upload it ?

by the way is there any way to get all 3 parts in to 1 dokument as my last try here dident work as it just read 1 of them or should it be 3 dokuments but how to get fs run them all as cant have the same name

as i tryeid but know there is missing som thing but what as they all ends whit end as that is the way to indicate it is ended right? becaus it should be set up whit numbers like prarmeters or should it just then wounder how it then would read the parameters whit out pressing a button.

prevshdg = -1

while true do

prevhdg = hdg

hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")

if ("hdg ~= prevspeed") then

stringhdg = string.format("%03d", hdg)

gfd.setDisplay(GFMCP,0,1,stringhdg)

end

end

prevalt = -1

while true do

prevalt = alt

alt = ipc.readLvar ("L:AB_AP_ALT_Select")

if ("alt ~= prevalt") then

stringalt = string.format("%05d", alt)

gfd.setDisplay(GFMCP,0,4,stringalt)

end

end

prevspeed = -1

while true do

prespeed = speed

speed = ipc.readLvar ("AB_AP_SPEED_Select")

if ("speed ~= prevspeed") then

stringspeed = string.format("%03d", speed)

gfd.setDisplay(GFMCP,0,2,stringspeed)

end

end

Link to comment
Share on other sites

pete i am so thanks full for your support and happy that things now seem to work. by the way may i upload it ?

If you include it in a message and use the "code" button to envelope it, it will be easily selectable by those who want to try it.

by the way is there any way to get all 3 parts in to 1 dokument as my last try here dident work as it just read 1 of them or should it be 3 dokuments but how to get fs run them all as cant have the same name

There are two answers to that.

First, the best way to use the special plug-in "ipcReady.lua" is to use it to start all of the different plug-ins you want to have running all of the time. So could could have your three separate ones, named say "GFMCP1.lua", "GFMCP2.lua" and "GFMCP3.lua", and in the ipcReady.lua you can simply have:

ipc.runlua("GFMCP1")
ipc.runlua("GFMCP2")
ipc.runlua("GFMCP3")

However, whilst this is a good idea for different things, with these it is very wasteful to do that. So just make the one plug in, putting all three actions in the same "whileend" loop. Not your three separate loops -- which cannot work because the first loop never ends (if it did it would stop updating its display, you see) -- but just the one loop, which I'll show later.

First let's look at the mistakes you made. Let's look at your first example:

prevshdg = -1

while true do
    prevhdg = hdg
    hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")
    if ("hdg ~= prevspeed") then
         stringhdg = string.format("%03d", hdg)
         gfd.setDisplay(GFMCP,0,1,stringhdg)
    end
end

Several errors here, and aNONE of them are due to any lack of programming ability, but just sheer carelessness. You MUST (repeat MUST) be more careful. Just look:

prevshdg = -1

Okay, you named the memory for your heading value "prevshdg". But then:

prevhdg = hdg

What is "prevhdg"? Do you think it does not matter that you spell it differently each time? The computer will NOT recognise "prevhdg" as the same as "prevshdg"! Don't you see this simple thing? This isn't about programming now, so there's no excuse! It is the same as you referring to "lau" instead of "Lua". you may well spell your name differently each time, and that may not matter to you. But computers are fussy!

Also, what is the point of having a memory of the previous heading set to -1 initially if the very first thing you do is set it to something different? You don't seem to have looked at the example I did for you -- you have the lines in a different order!

The order of lines in a program is VITALLY IMPORTANT. It is the order they will be executed. Like in a story, would you understand it if Chapter 2 came before Chapter 1?

In this line

hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")

where did you get "AB_AP_HDG_Select_hist" from? I'm not saying it is wrong, I haven't been through the L:Var log i made to check -- but did you?

Then this line:

if ("hdg ~= prevspeed") then

Surely you can spot the error there? Is "prevspeed" supposed to be the memorised previous heading, the one you set to -1 initially? Three different names for the same value?

That's four (4) definite errors in not many more lines, and all of them simply careless -- not a matter of programming but writing things without enough thought.

I'm not going to lecture about this any more. If you do not take note of this I will not help any more. Okay?

The other two are better, but in all three you are copying the new, changed value into the memory BEFORE you've read it, which is wrong. As in my original example i provided it should go in the conditional part, after you've updated the display, before the first 'end'. I failed to spot you got it wrong in your posting just after. Remember when I explained this? I said "I am using prevalt as a memory for the previously displayed altitude". So that is what it should be -- a memory of what you just displayed. I know it appears to work still the other way, but it is not logically correct and it is inefficient to do it as you have done -- and also it won't work if the initial value is 0 (because the initial alt is 0 too).

Finally, as promised. To combine all three just group your three "xxxx = -1" statements at the start, before the "while" line, and then have just the one while .... end, with all three of the main parts inside, so:

while 1 do

   xxx =  ipc.readLvar ...
   if ...
      ...
   end

   xxx =  ipc.readLvar ...
   if ...
      ...
   end

   xxx =  ipc.readLvar ...
   if ...
      ...
   end

   ipc.sleep(500)
end

Finally, note that the 500 in the "sleep" will limit the display update rate to 2 per second. You might want to speed that up. A value of 50 would be 20 per second, but that's probably over the top. You could experiment, but I would say no lower than 100 (for 10 per second). Just remember there are 1000 milliseconds in a second.

Regards

Pete

Link to comment
Share on other sites

well got it corectet i hope and it worked but did many other times whit error so would you se if i have corected it as you told or there stil is something i dident get right. before sharing it to much.


prevalt = -1
prevhdg = -1
prevspeed = -1

while 1 do

    alt = ipc.readLvar ("L:AB_AP_ALT_Select")
    if ("alt ~= prevalt") then
         stringalt = string.format("%05d", alt)
         gfd.setDisplay(GFMCP,0,4,stringalt)
         prevalt = alt
    end

    hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")
    if ("hdg ~= prevhdg") then
         stringhdg = string.format("%03d", hdg)
         gfd.setDisplay(GFMCP,0,1,stringhdg)
         prevhdg = hdg
    end

    speed = ipc.readLvar ("AB_AP_SPEED_Select")
    if ("speed ~= prevspeed") then
         stringspeed = string.format("%03d", speed)
         gfd.setDisplay(GFMCP,0,2,stringspeed)
         prevspeed = speed
    end

    ipc.sleep(500)
end

and yes i have watched that hdg = ipc.readLvar ("AB_AP_HDG_Select_hist") was exsisting also tryeid whit ("AB_AP_HDG_Select") as also exsisted but dident work. but would try it now to se if it would work now if things are right.

Link to comment
Share on other sites

hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")

speed = ipc.readLvar ("AB_AP_SPEED_Select")

if ("speed ~= prevspeed") then

stringspeed = string.format("%03d", speed)

gfd.setDisplay(GFMCP,0,2,stringspeed)

prevspeed = speed

end

You've not tested this evidently? The L:var names have "L:" at the beginning, as for the altitude one. You've missed it out!

I've now looked at the full L:Var list for the AirbusX, and I would have thought the correct Heading value was in "AB_AP_HDG_Select" rather than the "Hist" one -- the Hist one sounds like one retained so it knows which way to turn?

I attach a sorted list of all of the AirbusX L:Vars.

Pete

AirbusX Lvars.zip

Link to comment
Share on other sites

have tested and yes it works whit "AB_AP_HDG_Select" dont know why it dosent work yesterday, but many error by mee would be the corect awenser. but els is it then right?

!!UPDATE!! as now i have compleated an instalation guide and ready to release have attached the manual whit the Lau file as it would acept my dokument.

prevalt = -1
prevhdg = -1
prevspeed = -1

while 1 do

    alt = ipc.readLvar ("L:AB_AP_ALT_Select")
    if ("alt ~= prevalt") then
         stringalt = string.format("%05d", alt)
         gfd.setDisplay(GFMCP,0,4,stringalt)
         prevalt = alt
    end

    hdg = ipc.readLvar ("L:AB_AP_HDG_Select")
    if ("hdg ~= prevhdg") then
         stringhdg = string.format("%03d", hdg)
         gfd.setDisplay(GFMCP,0,1,stringhdg)
         prevhdg = hdg
    end

    speed = ipc.readLvar ("L:AB_AP_SPEED_Select")
    if ("speed ~= prevspeed") then
         stringspeed = string.format("%03d", speed)
         gfd.setDisplay(GFMCP,0,2,stringspeed)
         prevspeed = speed
    end

    ipc.sleep(500)
end

goflight MCP display.zip

Link to comment
Share on other sites

but els is it then right?

No.

I didn't notice this before, sorry, but WHY have you put "" around the numerical comparisons, in these lines?

if ("alt ~= prevalt") then

if ("hdg ~= prevhdg") then

if ("speed ~= prevspeed") then

That simply makes the condition always true, because the strings are always strings!!!! Those lines are meant to be comparing two numbers, as I carefully explained. The "" turns them into strings! They might as well all be

if ("THIS IS GARBAGE") then

because that would give exactly the same result!!! What will happen is that the displays will be updated all of the time, whether they need to be or not. It makes many of the lines a waste of time.

You are making far too many silly careless mistakes.

Pete

Link to comment
Share on other sites

well pete the reason for using ("alt ~= prevhdg") was neaded for stop the display showing wrong info as if i read my goflight it shows lets say 256 then i want to fly hdg 350. well then i want to turn right on the knob to 350 then stop, and it show 350 on the display but after a small amount of time it corect it to lets say hdg 345. so there for i did it and seems to work. by the way it also have to update in same like airbus autopilot, it was also therefor i delted the sleep yesterday as then it works like default plane

Link to comment
Share on other sites

well pete the reason for using ("alt ~= prevhdg") was neaded for stop the display showing wrong info as if i read my goflight it shows lets say 256 then i want to fly hdg 350. well then i want to turn right on the knob to 350 then stop, and it show 350 on the display but after a small amount of time it corect it to lets say hdg 345. so there for i did it and seems to work.

But I told you the Sleep might be too long and to try changing that till it responds okay for you. Just wrecking the program entirely isn't the right way to carry on. You do your own thing, to please yourself, but don't keep coming here to get my approval for things which are wrong. I keep advising you, showing you, explaining things, but you choose to ignore me.

Please carry on, but don't ask me anything else now. it is taking too long. I have other things to do.

Regards

Pete

Link to comment
Share on other sites

sorry pete of cause you are right it works it was me there have made an test yesterday then i fogot to turn off goflight display sorry.

I did set sleep to 100 and seems to be like having no sleep. or simular. by the way i stil dont understand why it needs sleep as fs dosent crash if you have no sleep but here is it then


prevalt = -1
prevhdg = -1
prevspeed = -1

while 1 do

    alt = ipc.readLvar ("L:AB_AP_ALT_Select")
    if (alt ~= prevalt) then
         stringalt = string.format("%05d", alt)
         gfd.setDisplay(GFMCP,0,4,stringalt)
         prevalt = alt
    end

    hdg = ipc.readLvar ("AB_AP_HDG_Select_hist")
    if (hdg ~= prevhdg) then
         stringhdg = string.format("%03d", hdg)
         gfd.setDisplay(GFMCP,0,1,stringhdg)
         prevhdg = hdg
    end

    speed = ipc.readLvar ("AB_AP_SPEED_Select")
    if (speed ~= prevspeed) then
         stringspeed = string.format("%03d", speed)
         gfd.setDisplay(GFMCP,0,2,stringspeed)
         prevspeed = speed
    end

    ipc.sleep(100)
end

Link to comment
Share on other sites

i stil dont understand why it needs sleep as fs dosent crash if you have no sleep but here is it then

It won't crash, it is just that it would be taking a lot more resources than it needs. You might not notice until you fly in a busy or complicated place and lose performance. Just adjust it low enough to do the job, and no lower.

Pete

Link to comment
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

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.