MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

icon
Avatar
vicious90270
Posts: 11
Hello, once again

Previously I requested help with JeeHell Airbus. Thank you Again FSlikerXY. But Jeehell is more of a PIT SIM wich is great when I build my pit sometime next year.

For now Im sticking with the aerosoft airbus. Now here is what I can do so far...

Im using linda to program rotary encoders to turn the knobs on the fcu. Works like a charm!!
Now im trying to display said value to my segment display via mobiflight.

My request is help on what file to put where and help setting up a lua to help me display what i need. step by step in basic newbie language.

I understand there are few instructions on this site already however they are a bit to complex for me to understand as of yet.

I appreciate any help I can receive...Thank you
2016-04-12 22:37
Avatar
vicious90270
Posts: 11
update

I was able to get some result after hours of online reading.

however when the Lua is running I get a red syntax error and the fcu on the fsx airbus does not change. but when I kill the LUA all is normal on the airbus

Any Clue??
2016-04-13 19:40
Avatar
FSlikerXY
From: REUTL @ STR, Germany
Posts: 57
Hi vicious90270,

could you post the lua script?
2016-04-13 20:26
Avatar
vicious90270
Posts: 11
--SPD
ipc.writeSW(0x66C0, ipc.readLvar("L:AB_AP_Speed_Select"))
ipc.writeSW(0x66C6, ipc.readLvar("L:AB_AP_Mach_Select")))*100)

--HDG
ipc.writeUW(0x66C8, ipc.readLvar("L:AB_AP_HDG_Select")*182.0444444444444)
ipc.writeUW(0x66D1, ipc.readLvar("Autopilot_TRK_set")*182)
--ALT
ipc.writeUW(0x66D5, ipc.readLvar("L:AB_AP_ALT_Select"))
--VS
ipc.writeSW(0x66C2,ipc.readLvar("L:AB_AP_Vs_Select2"))
ipc.writeSW(0x66C4,ipc.readLvar("L:AB_AP_FPA_Select2")*10)

--HDG/TRK
ipc.writeSW(0x66CC,ipc.readLvar("AB_AP_HDGTRK"))
--SPD/MACH
ipc.writeSW(0x66CE,ipc.readLvar("AB_AP_SPDMACH"))


while 1 do

--HDG/TRK
HdgTrkLvar=ipc.readLvar("AB_AP_HDGTRK")
HdgTrkOffset=ipc.readSW(0x66CC)

if HdgTrkOffset~= HdgTrkLvar then
--ipc.writeLvar("AB_AP_HDGTRK",HdgTrkOffset)
ipc.writeSW(0x66CC,ipc.readLvar("AB_AP_HDGTRK"))
end

--SPD/MACH
SpdMachLvar=ipc.readLvar("AB_AP_SPDMACH")
SpdMachOffset=ipc.readSW(0x66CE)

if SpdMachOffset ~= SpdMachLvar then
--ipc.writeLvar("AB_AP_SPDMACH",SpdMachOffset)
ipc.writeSW(0x66CE,ipc.readLvar("AB_AP_SPDMACH"))
end

--
SPDmode_cur = ipc.readLvar("L:AB_AP_SPDmode_set") --0x66D9
HDGmode_cur = ipc.readLvar("L:AB_AP_HDGmode_set") -- 0x66DA

-- Selected / Managed Display
if SPDmode_cur ~= SPDmode_pre then
SPDmode_pre = SPDmode_cur
if SPDmode_cur == 1 then
ipc.writeUB(0x66D9,SPDmode_cur) --managed
else
ipc.writeUB(0x66D9,SPDmode_cur) --selected
end
end

if HDGmode_cur ~= HDGmode_pre then
HDGmode_pre = HDGmode_cur
if HDGmode_cur == 1 then
ipc.writeUB(0x66DA,HDGmode_cur) --managed
else
ipc.writeUB(0x66DA,HDGmode_cur) --selected
end

end

ipc.sleep(20)


--SPD

SpdMachVar = ipc.readLvar("AB_AP_SPDMACH")
if SpdMachVar == 0 then

SpdLvar = ipc.readLvar("L:AB_AP_Speed_Select")
SpdOffset=ipc.readSW(0x66C0)

if SpdOffset > 399 then
ipc.writeSW(0x66C0, 399)
elseif SpdOffset < 100 then
ipc.writeSW(0x66C0, 100)
end
if SpdOffset~=SpdLvar then
ipc.writeLvar("L:AB_AP_Speed_Select",SpdOffset)
end

elseif SpdMachVar == 1 then

--MachLvar = ipc.readLvar("L:AB_AP_Mach_Select")*100
MachLvar= tonumber(string.format("%.2f", ipc.readLvar("L:AB_AP_Mach_Select")))
MachLvar=MachLvar*100
MachOffset=ipc.readSW(0x66C6)

if MachOffset < 10 then
ipc.writeSW(0x66C6, 10)
elseif MachOffset > 84 then
ipc.writeSW(0x66C6, 84)
end

if MachOffset ~= MachLvar then
ipc.writeLvar("L:AB_AP_Mach_Select",MachOffset/100)
end

end


ipc.sleep(20)
--HDG
AB_hdgtrk = ipc.readLvar("L:AB_AP_HDGTRK")

HdgLvar=ipc.readLvar("L:AB_AP_HDG_Select")*182.0444444444444
HdgOffset = ipc.readUW(0x66C8)


TrkLvar=ipc.readLvar("Autopilot_TRK_set")*182.0444444444444
TrkOffset = ipc.readUW(0x66D1)

if AB_hdgtrk == 0 then

if HdgOffset ~= HdgLvar then

currentValue =(ipc.readUW(0x66C8))*0.0054931640625
ipc.writeLvar("L:AB_AP_HDG_Select", currentValue)

end

else


if TrkOffset ~= TrkLvar then
currentValue = ipc.readUW(0x66D1)*0.0054931640625
ipc.writeLvar("Autopilot_TRK_set", currentValue)
end

end
ipc.sleep(20)
--ALT
AltLvar=ipc.readLvar("L:AB_AP_ALT_Select")
AltOffset=ipc.readUW(0x66D5)

if AltOffset < 100 then
ipc.writeUW(0x66D5,100)
elseif AltOffset >49000 and AltOffset < 55000 then
ipc.writeUW(0x66D5,49000)
elseif AltOffset > 55000 then
ipc.writeUW(0x66D5,100)
end

if AltOffset~=AltLvar then
ipc.writeLvar("L:AB_AP_ALT_Select",AltOffset)
end

ipc.sleep(20)
--VS
if ipc.readLvar("AB_AP_HDGTRK") == 0 then
VsHdgLvar=ipc.readLvar("L:AB_AP_Vs_Select2")
VsHdgOffset=ipc.readSW(0x66C2)

if VsHdgOffset < -60 then
ipc.writeSW(0x66C2,-60)
elseif VsHdgOffset > 60 then
ipc.writeSW(0x66C2,60)
end
if VsHdgOffset ~=VsHdgLvar then
ipc.writeLvar("L:AB_AP_Vs_Select2", VsHdgOffset)
end
else
VsTrkLvar=ipc.readLvar("L:AB_AP_FPA_Select2")
VsTrkOffset=ipc.readSW(0x66C4)/10

if VsTrkOffset < -9.5 then
ipc.writeSW(0x66C4,-95)
elseif VsTrkOffset > 9.5 then
ipc.writeSW(0x66C4,95)
end
if VsTrkOffset ~= VsTrkLvar then
ipc.writeLvar("L:AB_AP_FPA_Select2", VsTrkOffset)
end


end
2016-04-13 20:35
Avatar
mauri61173
Posts: 4
Hello
I would build home cockipit on aerosoft airbus. I would like to understand how to assign an offset contact by attributing L var ap_throttle. I downloaded Linda and Aerosoft 4.4. But I can not get it to work. Can you help me. Thank you
2017-06-06 20:32
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3838
Supporter
Hi.
I´m not advanced here..... But everything you need is just explaned above.... or here...https://www.mobiflight.com/forum/topic/251.html

Additional i don´t know what "AP_throttle" exactly do..... You need to know youreself how you will use this Data after readout it.
Good Luck !
2017-06-07 09:34
Avatar
mauri61173
Posts: 4
Hello
I'm trying to try to run via linda and aerosoft 4.4 my cockipit, but I can not associate the respective offset. Can you give me an example of Linda how to associate it.
Thank you.
2017-06-09 17:58
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3838
Supporter
No Sorry. I Never use LINDA.

Basicly when you can write the script ( and understand the scripting language) you can include the script into the Auto File. for example

Read the FSUIPC Guide or google a bit like " Running LUA Script in FSX"

Additional you can use for Testing a Joystickbutton. Simply set in FSUIPC for example that Button 1 should Start the LUA script and Button 2 should Kill the Lua script.
Then you can Test.... Push button 1.... Lua should run.... Check if your used custom offset include the Data you try to read out. If Yes Kill Lua with button 2.

When you see your script is working then you can make a entry in the Auto File to tell FSUIPC it should run your script for example always when Aerosoft Airbus is loaded.
Good Luck !
2017-06-09 22:06
Avatar
mauri61173
Posts: 4
Hello
Thanks to your help I managed to assign an entry to Aerosoft Airbus by assigning offset 0x66C0 to the Throttle autopilot assignment, but I can not turn on the respective led when the function is switched off according to offset 0x66C1. I write the lua command to verify the string:

function Autopilot_ATHR(offset,value)
if (value == 1) then ipc.writeLvar("L:AB_AP_ATHR",1)
else ipc.writeLvar("L:AB_AP_ATHR",0)
end
end

event.offset("66C0","UB","Autopilot_ATHR")


ipc.writeSB(0x66C1, 0)

offsetValue = ipc.readSB(0x66C1);


if offsetValue ~= ATT_cur then
ipc.writeLvar("L:AB_AP_ATHR", offsetValue)
end

Thanks in advance for the given collaboration.
2017-06-12 14:54
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3838
Supporter
HI

Nice to hear you comming forward here.

again my experience is still poor here.... So my review of your Code is MABY not 100% Correct. I still learning this myself !
I try to understand......

iconmauri61173:


function Autopilot_ATHR(offset,value)
if (value == 1) then ipc.writeLvar("L:AB_AP_ATHR",1)
else ipc.writeLvar("L:AB_AP_ATHR",0)
end
end

event.offset("66C0","UB","Autopilot_ATHR")



This should be the INPUT Section.... I think it looks good. You create the function on base of Offset 66C0 .... If Value is 1 then you write 1 to the LVAR else Zero.
Here i´m not shure.... Is it correct that Function and Event.Offset just CALL this function if value of Offset is changing ?? I Just ask to get shure this code part not running all the time and write the LVAR 100x per second.... We only need a Write if Offset Value is real changed.
************************

Now the Part i NOT understand ( I Think you say this should be the Output !!) ......

iconmauri61173:



ipc.writeSB(0x66C1, 0) // Here you define the Offset 66C1 to 0

offsetValue = ipc.readSB(0x66C1); // Here you read the Offset and save it to the Variable

if offsetValue ~= ATT_cur then // Here i not understand WHERE do you define or readout "ATT_cur" ( Logical it is the Value of the LVAR But how you define it ?)
ipc.writeLvar("L:AB_AP_ATHR", offsetValue) // Here you Write the current value of Offset 66C1 to the LVAR WHY ???
end



If this should be the OUTPUT Line i don´t understand your logic..... Why do you WRITE the Value of the Output Offset to the LVAR ??

I think better way is.....
ATT_cur should be the read out status of the LVAR..... If the 2 Variables are not simular (if offsetValue ~= ATT_cur then)
THEN Write the OFFSET with the Data form the LVAR..... Not Reversed like in your code. So the Offset (Output) get the same value like the current Value in Sim !

Finaly i think about a "sleep" command. (Not shure how to set this with LUA and if its posible to do this Sleep individual for some Sub functions)
BUT. I Think if you permanent check the Offset and LVar you create lots of data traffic. Maby a Read 5 Time per second ( Sleep 200ms) is enough !
Good Luck !
2017-06-13 04:01
Avatar
emmanuel.morales
Posts: 17
iconmauri61173:

Hello
Thanks to your help I managed to assign an entry to Aerosoft Airbus by assigning offset 0x66C0 to the Throttle autopilot assignment, but I can not turn on the respective led when the function is switched off according to offset 0x66C1. I write the lua command to verify the string:

function Autopilot_ATHR(offset,value)
if (value == 1) then ipc.writeLvar("L:AB_AP_ATHR",1)
else ipc.writeLvar("L:AB_AP_ATHR",0)
end
end

event.offset("66C0","UB","Autopilot_ATHR")


ipc.writeSB(0x66C1, 0)

offsetValue = ipc.readSB(0x66C1);


if offsetValue ~= ATT_cur then
ipc.writeLvar("L:AB_AP_ATHR", offsetValue)
end

Thanks in advance for the given collaboration.




Hi mauir,

could you make it work... I am trying to build a fcu for aerosoft in fsx... but don´t kjnow how to.

thanks
2020-05-11 21:40
icon