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! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

Go to page 1Go to page 2123Go to page 4Go to page 3
Avatar
Hannes
From: Austria
Posts: 164
Supporter
Hallo,

Eine Frage zu dem oben angeführten Script. Habe dies so übernommen und auf einige Werte von mir abgeändert. Funktioniert perfekt. Jedoch jegliche weitere Lvar die ich hinzufüge funktionieren nicht mehr. Weiß aber nicht warum. Könnte es eventuell mit den Byte Werten zusammenhängen. Wie finde ich heraus, welchen Wert ich verwenden muss. In der Lvar Liste der A2A stehen nur die Lvars aber sonst keine Informationen. Hier noch mein Code, der soweit funktioniert.

iconCode:
local UB = {r=ipc.readUB,w=ipc.writeUB} -- 1 Byte Int
local UW = {r=ipc.readUW,w=ipc.writeUW} -- 2 Byte Int
local UD = {r=ipc.readUD,w=ipc.writeUD} -- 4 Byte Int
local FLT = {r=ipc.readFLT,w=ipc.writeFLT} -- 4 Byte Float
local DBL = {r=ipc.readDBL,w=ipc.writeDBL} -- 8 Byte Float
local STR = {r=ipc.readSTR,w=ipc.writeSTR} -- String

local EN1 = "66FF" -- master offset enable

local R = 0
local W = 1

--[[
	Every entry in lvar_list corresponds to one offset.
	How to build an entry:
	{"offset", mode, {enable_switches}, {lvars}}
	- offset = fsuipc offset (between 0x66C0 and 0x66FF)
	- mode is either R or W. R means only read from lvar
	and W means only write to lvar. (e.g. an LED displaying
	the flaps status is R. A switch that extends the gear
	is W.)
	- enable_switches = list of offsets which all have to
	be set to 1 otherwise the line gets ignored. This is useful
	for shared cockpit so that if you are not in charge of the
	buttons your switches won't override the switches of the 
	other pilot.
	-- lvars = list of lvars that get the same value written to.
	You should only use one lvar when mode=R.
]]
local lvar_list = {
    {"66D1", W, {}, UB, { "Panellightknob" }},
    {"66D3", R, {}, UB, { "OILPRESSLIGHT" }},
    {"66D4", R, {}, UB, { "VOLTSLIGHT" }},
    {"66D5", R, {}, UB, { "VACLIGHT" }},
    {"66D6", R, {}, UB, { "FUELLIGHT" }},
--Weitere Einträge funktionieren nicht mehr ???
}

-- set this to true if you want to force your own switch positions on start
local initialized = false

while true do
	for _,v in pairs(lvar_list) do
		local offset = v[1]
		local mode = v[2]
		local enable_offsets = v[3]
		local offset_type = v[4]
		local lvars = v[5]
			
		-- check all enable switches are set
		local enabled = true
		for _, enable_offset in pairs(enable_offsets) do
			local val = ipc.readUB(enable_offset)
			if val == 0 then
				enabled = false
			end
		end
		
		if enabled == true then -- skip line if disabled
			if initialized == true and mode == W then -- write mode			
				-- read offset
				local offset_val = offset_type.r(offset)
				
				-- update lvars
				for _, lvar in pairs(lvars) do
					ipc.writeLvar(lvar, offset_val)
				end
			else -- read mode
				-- read lvars
				local lvar_val = ipc.readLvar(lvars[1])
				
				-- update offset
				offset_type.w(offset, lvar_val)
			end
		end
	end
	initialized = true
end


Und die aktuelle Lvar Liste der A2A C172:

iconCode:
A2A C172 Trainer
variables list and notes for simpit builders
Gauges:
(L:AirspeedIndicatedNeedle,number) - airspeed needle
(L:AirspeedTAS,number) - IAS/TAS conversion chart (range: 0 – 110)
(A:ATTITUDE INDICATOR PITCH DEGREES:1,degrees) - artificial horizon, attitude
(A:ATTITUDE INDICATOR BANK DEGREES:1,grad) - artificial horizon, bank
(A:INDICATED ALTITUDE:1,feet) 1000 % 10 / 100 + - altimeter needle (hundreds feet) (range: 0 –200)
(A:INDICATED ALTITUDE:1,feet) 10000 % 100 / 100 + - altimeter needle (thousands feet) (range: 0 –200)
(A:INDICATED ALTITUDE:1,feet) 100000 % 1000 / 100 + - altimeter needle (ten thousands feet) (range: 0 –200)
(A:KOHLSMAN SETTING HG:1,inHg) 27.99 - 24.87562 * - Kohlsman knob in inHg (range: 0 – 100)
(A:KOHLSMAN SETTING HG:1,hectopascals) 950 - - Kohlsman knob in hPa (range: 0 – 100)
(L:Nav1ObsNeedle,number) - nav1 obs (range: 0 -180) – read only – inc/dec by default events
(>K:VOR1_OBI_INC) and (>K:VOR1_OBI_DEC)
(L:Gsi1Needle,keyframe) - glideslope indicator (range: 0 – 100)
(L:Gsi1Flag,enum) - glideslope indicator flag (0 – off, 1 – on)
(L:Cdi1Needle,keyframe) - course deviation indicator (range: 0 – 100)
(L:ToFrom1Needle,enum) - to/from flag (0 – off, 1 – to, 2 – from)
(L:FuelLeftWingTank,gallons) - left fuel tank
(L:FuelRightWingTank,gallons) - right fuel tank
(L:Eng1_EGTGauge,number) - exhaust gas temp in F
(L:EGTGauge_ref,percent) - egt ref needle (range: 0 – 100)
(L:Eng1_GPH,gallons) - fuel flow in gallons per hour
(L:Eng1_OilTemp,celsius) - oil temp in C
(L:Eng1_OilPressure,psi) - oil pressure in psi
(A:SUCTION PRESSURE,inHg) - suction
(L:Ammeter1,amps) - ammeter
(A:DELTA HEADING RATE,degrees per second) 1.1 * -10 max 10 min 10 + 5 * - turn indicator (range: 0 – 100)
(A:TURN COORDINATOR BALL,position) -1 max 1 min 1 + 25 * - ball (range: 0 – 50)
(L:HiAdjust,number) - heading indicator knob
(L:AutopilotHeadingBug,number) - heading bug – read only – inc/dec by default events
(>K:HEADING_BUG_INC) and (>K:HEADING_BUG_DEC)
(L:HeadingGyro,degrees) - heading gyro
(A:VERTICAL SPEED,feet per minute) - vertical speed indicator
(L:Cdi2Needle,keyframe) - course deviation indicator (range: 0 – 100)
(L:ToFrom2Needle,enum) - to/from flag (0 – off, 1 – to, 2 – from)
(L:Cdi2Flag,bool) - course deviation indicator flag (0 – off, 1 – on)
(L:Nav2ObsNeedle,number) - nav2 obs (range: 0 -180) – read only – inc/dec by default events
(>K:VOR2_OBI_INC) and (>K:VOR2_OBI_DEC)
(L:Eng1_RPM,RPM) - engine rpm
(L:e1Hour4,number) - engine hours, thousands
(L:e1Hour3,number) - engine hours, hundreds
(L:e1Hour2,number) - engine hours, tens
(L:e1Hour1,number) - engine hours, ones
(L: e1HourFract1,number) - engine hours, tenths
(L:AdfHdgNeedle,number) - adf heading – read only – inc/dec by default events
(>K:ADF_CARD_INC) and (>K: ADF_CARD _DEC)
(L:AdfCdiNeedle,keyframe) - ADF course deviation needle
(A:WISKEY COMPASS INDICATION DEGREES,degrees) - Whiskey compass
Switches:
(L:Eng1_GeneratorSwitch,bool) - generator switch
(L:Battery1Switch,bool) - battery switch
(>K:TOGGLE_ELECT_FUEL_PUMP1) - fuel pump
(>K:TOGGLE_BEACON_LIGHTS) - default beacon light toggle event
(>K:LANDING_LIGHTS_TOGGLE) - default landing light toggle event
(>K:TOGGLE_TAXI_LIGHTS) - default taxi light toggle event
(>K:TOGGLE_NAV_LIGHTS) - default nav light toggle event
(>K:STROBES_TOGGLE) - default strobe light toggle event
(>K:PITOT_HEAT_TOGGLE) - default pitot heat toggle event
1 (>K:AVIONICS_MASTER_SET) (on)
0 (>K:AVIONICS_MASTER_SET) (off) - default avionics master set event
Center pedestal/lower main dash:
(L:Magnetos1Pct,percent) - starter key (range: 0 – 15: off; 16 – 37: R magneto; 38 – 63: L magneto;
64 – 85: both magnetos; 86 – 100: starter)
(L:FSelC172State,enum) - fuel selector (0 – left, 1 – both, 2 – right)
(L:Eng1_FuelCutOffSwitch,bool) - fuel cutoff lever (on/off)
(L:TrimtabPosition,percent) - elevator trim position– read only – inc/dec by default events
(>K:ELEV_TRIM_DN) and (>K:ELEV_TRIM_UP)
(L:GlareshieldLightKnob,number) - illumination of the main dash (range: 0 – 32)
(L:PedestalLightKnob,number) - illumination of the fuel selector (range: 0 – 32)
(L:RadioLightKnob,number) - illumination of the radiostack (range: 0 – 32)
(L:PanelLightKnob,number) - illumination of the gauges (range: 0 – 32)
(L:StaticAir,bool) - static air lever (on/off)
(L:Throttle1Position,percent) - throttle lever (range: 0 – 100)
(L:Eng1_MixtureManualLever,percent) - mixture lever (range: 0 – 100)
(L:LandFlapsPos,enum) - flaps position lever (0 – up, 1 – 2/4, 2 – 3/4, 3 – down)
(A:TRAILING EDGE FLAPS LEFT PERCENT,percent) - flaps position indicator (range: 0 – 100)
(L:CabinTempControl,percent) - cockpit heat (range: 0 – 100)
(L:CabinVent,percent) - cockpit ventilation (range: 0 – 100)
(>K:PARKING_BRAKES) - default parking brakes event
Radiostack:
KMA 26 Audioselector:
(L:kma26SelectorKnob_pos,enum) - Audio selector knob (0 – inop/com1, 1 – com1, 2 – com2, 3 – inop/com2, 4 – inop/com2)
Com1 button - if com2 transmit selected use default (>K:COM_RECEIVE_ALL_TOGGLE)
Com2 button - if com1 transmit selected use default (>K:COM_RECEIVE_ALL_TOGGLE)
Com3 button - inop (FSX supports just two com channels)
Nav1 button - if (L:kma26Nav1Switch,bool) is zero, toggle default
(>K:RADIO_VOR1_IDENT_DISABLE) event
Nav2 button - if (L:kma26Nav2Switch,bool) is zero, toggle default
(>K:RADIO_VOR2_IDENT_DISABLE) event
Mkr button - if (L:kma26MkrSwitch,bool) is 1 and (A:MARKER SOUND,bool) is 0 toggle default
(>K:MARKER_SOUND_TOGGLE)
if (L:kma26MkrSwitch,bool) is 0 and (A:MARKER SOUND,bool) is 1 toggle default
(>K:MARKER_SOUND_TOGGLE)
DME button - if (L:kma26DmeSwitch,bool) is 1 toggle default
(>K:RADIO_DME1_IDENT_ENABLE)
if (L:kma26DmeSwitch,bool) is 0 toggle default
(>K:RADIO_DME1_IDENT_DISABLE)
ADF button - if (L:kma26AdfSwitch,bool) is 1 toggle default
(>K:RADIO_ADF_IDENT_ENABLE)
if (L:kma26AdfSwitch,bool) is 0 toggle default
(>K:RADIO_ADF_IDENT_DISABLE)
Aux button - inop
Moni button - inop
Marker lights - (L:kma26OMarker,bool) – outer marker; (L:kma26MMarker,bool) – middle marker;
(L:kma26IMarker,bool) – inner marker
KX 155A Com1/Nav1 unit:
Com1 on/off knob - (L:Com1OnOff,bool)
Com1 STBY button - (L:Com1StbySwitch,bool)
Com1 CHAN button - (L:Com1ChanSwitch,bool)
Com1 outer knob - (L:Com1FreqOuterKnob,percent) (range: 0 – 100)
Com1 inner knob - (L:Com1FreqInnerKnob,percent) (range: 0 -100)
Com1 inner knob pull - (L:Com1InnerKnobPull,bool)
Nav1 ident knob - (L:Nav1Ident,bool)
If (L:Nav1Ident,bool) is equal to zero, toggle the (>K:RADIO_VOR1_IDENT_DISABLE) event
Nav1 STBY button - (L:Nav1StbySwitch,bool)
Nav1 MODE button - (L:Com1NavSwitch,bool)
Nav1 outer knob - (L:Nav1FreqOuterKnob,percent) (range: 0 – 100)
Nav1 inner knob - (L:Nav1FreqInnerKnob,percent) (range: 0 – 100)
Nav1 inner knob pull - (L:Nav1InnerKnobPull,bool)
KX 155A Com2/Nav2 unit:
Com2 on/off knob - (L:Com2OnOff,bool)
Com2 STBY button - (L:Com2StbySwitch,bool)
Com2 CHAN button - (L:Com2ChanSwitch,bool)
Com2 outer knob - (L:Com2FreqOuterKnob,percent) (range: 0 – 100)
Com2 inner knob - (L:Com2FreqInnerKnob,percent) (range: 0 -100)
Com2 inner knob pull - (L:Com2InnerKnobPull,bool)
Nav2 ident knob - (L:Nav2Ident,bool)
If (L:Nav2Ident,bool) is equal to zero, toggle the (>K:RADIO_VOR2_IDENT_DISABLE) event
Nav2 STBY button - (L:Nav2StbySwitch,bool)
Nav2 MODE button - (L:Com2NavSwitch,bool)
Nav2 outer knob - (L:Nav2FreqOuterKnob,percent) (range: 0 – 100)
Nav2 inner knob - (L:Nav2FreqInnerKnob,percent) (range: 0 – 100)
Nav2 inner knob pull - (L:Nav2InnerKnobPull,bool)
ADF unit:
ADF on/off knob - (L:AdfOnOffKnob,bool)
ADF button - (L:AdfAdfButton,bool)
BFO button - (L:AdfBfoButton,bool)
FRQ/Arrows button - (L:AdfFrqButton,bool), also set (L:FrqButton,bool) to 1, don’t change to 0 on button release
FRQ/ET button - (L:AdfFrqEtButton,bool) , also set (L:FrqEtButton,bool) to 1, don’t change to 0 on button release
SET/RST button - (L:AdfFrqRstButton,bool) , also set (L:FrqRstButton,bool) to 1, don’t change to 0 on button release
ADF outer knob - (L:AdfFreqOuterKnob,percent) (range: 0 – 100)
ADF inner knob - (L:AdfFreqInnerKnob,percent) (range: 0 – 100)
ADF inner knob pull - (L:AdfFreqInnerKnobPull,bool)
KT76C transponder unit:
0 button - (L:xpdr_0_button,bool) , also set (L:xpdr_digit0,bool) to 1, don’t change to 0 on button release
1 button - (L:xpdr_1_button,bool) , also set (L:xpdr_digit1,bool) to 1, don’t change to 0 on button release
2 button - (L:xpdr_2_button,bool) , also set (L:xpdr_digit2,bool) to 1, don’t change to 0 on button release
3 button - (L:xpdr_3_button,bool) , also set (L:xpdr_digit3,bool) to 1, don’t change to 0 on button release
4 button - (L:xpdr_4_button,bool) , also set (L:xpdr_digit4,bool) to 1, don’t change to 0 on button release
5 button - (L:xpdr_5_button,bool) , also set (L:xpdr_digit5,bool) to 1, don’t change to 0 on button release
6 button - (L:xpdr_6_button,bool) , also set (L:xpdr_digit6,bool) to 1, don’t change to 0 on button release
7 button - (L:xpdr_7_button,bool) , also set (L:xpdr_digit7,bool) to 1, don’t change to 0 on button release
IDT button - (L:xpdr_ident_button,bool)
CLR button - (L:xpdr_clr_button,bool) , also set (L:xpdr_clr,bool) to 1, don’t change to 0 on button release
VFR button - (L:xpdr_vfr_button,bool) , also set (L:xpdr_vfr,bool) to 1, don’t change to 0 on button release
On/off knob - (L:xpdr_onoff_knob_pos,enum) (0 – off, 1 – Standby, 2 – Test, 3 – On, 4 – Alt)
KAP 140 Autopilot unit:
AP button - (L:kap140_ap_button,bool), also set (L:kap140_ap,bool) to 1, don’t change to 0 on button release
HDG button - (L:kap140_hdg_button,bool) , also set (L:kap140_hdg,bool) to 1, don’t change to 0 on button release
NAV button - (L:kap140_nav_button,bool) , also set (L:kap140_nav,bool) to 1, don’t change to 0 on button release
APR button - (L:kap140_apr_button,bool) , also set (L:kap140_apr,bool) to 1, don’t change to 0 on button release
REV button - (L:kap140_rev_button,bool) , also set (L:kap140_rev,bool) to 1, don’t change to 0 on button release
ALT button - (L:kap140_alt_button,bool) , also set (L:kap140_alt,bool) to 1, don’t change to 0 on button release
UP button - (L:kap140_up_button,bool) , also set (L:kap140_up,bool) to 1, don’t change to 0 on button release
DN button - (L:kap140_dn_button,bool) , also set (L:kap140_dn,bool) to 1, don’t change to 0 on button release
ARM button - (L:kap140_arm_button,bool) , also set (L:kap140_arm,bool) to 1, don’t change to 0 on button release
BARO button - (L:kap140_baro_button,bool) , also set (L:kap140_baro,bool) to 1, don’t change to 0 on button release
AP inner knob - (L:kap140_InnerKnob,percent) (range: 0 – 100)
AP outer knob - (L:kap140_OuterKnob,percent) (range: 0 – 100)
KN62 DME unit:
On/off switch - (L:kn62OnOff,bool)
Function switch - (L:kn62Function,enum) (0 – Remote, 1 – Frequency, 2 – Groundspeed/Time to station
DME outer knob - (L:Kn62OuterKnob,percent) (range: 0 – 100)
DME inner knob - (L:Kn62InnerKnob,percent) (range: 0 – 100)
DME inner knobPull - (L:Kn62InnerKnobPull,bool)
FSX GNS400 GPS:
gps_on_switch - toggle (L:GpsOnSwitch,bool), (>K:GPS_POWER_BUTTON) and (>K:GPS_CLEAR_ALL_BUTTON)
NRST button - (>K:GPS_NEAREST_BUTTON)
OBS button - (>K:GPS_OBS_BUTTON)
MSG button - (>K:GPS_MSG_BUTTON)
FPL button - (>K:GPS_FLIGHTPLAN_BUTTON)
TERR button - (>K:GPS_TERRAIN_BUTTON)
PROC button - (>K:GPS_PROCEDURE_BUTTON)
RNG plus button - (>K:GPS_ZOOMOUT_BUTTON)
RNG minus button - (>K:GPS_ZOOMIN_BUTTON)
D button - (>K:GPS_DIRECTTO_BUTTON)
MENU button - (>K:GPS_MENU_BUTTON)
CLR button - toggle (>K:GPS_CLEAR_BUTTON) event and increase (L:GpsClrSwitchCounter,enum) by one.
If (L:GpsClrSwitchCounter,enum) is equal 90 toggle (>K:GPS_CLEAR_ALL_BUTTON) event and reset the counter.
ENT button - (>K:GPS_ENTER_BUTTON)
GPS outer knob - (L:GpsOuterKnob,percent) for knob rotation in VC, use (>K:GPS_GROUP_KNOB_DEC) and
(>K:GPS_GROUP_KNOB_INC) events for GPS function.
GPS inner knob - (L:GpsInnerKnob,percent) for knob rotation in VC, use (>K:GPS_PAGE_KNOB_DEC) and
(>K:GPS_PAGE_KNOB_INC) events for GPS function.
GPS inner knob push - toggle (L:GpsInnerKnobPush,bool) for VC animation, use (>K:GPS_CURSOR_BUTTON) event for GPS function.
Misc:
Headphones simulation:
To set the headphones on three things are needed in this sequence:
(L:Headphones,bool) set to 1; (L:SystemCondSelectFSX,number) set to 57; (L:SystemCondValueFSX,number) set to 1
To set the headphones off these three variables has to be set in this sequence:
(L:Headphones,bool) set to 0; (L:SystemCondSelectFSX,number) set to 57; (L:SystemCondValueFSX,number) set to 0
Airframe hours counter:
(L:a1Hour4,number) - airframe hours, thousands
(L:a1Hour3,number) - airframe hours, hundreds
(L:a1Hour2,number) - airframe hours, tens
(L:a1Hour1,number) - airframe hours, ones
(L: a1HourFract1,number) - airframe hours, tenths
Doors:
(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_1) - left doors (toggle)
(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_2) - right doors (toggle)
(L:WindowLeft,bool) - left window (toggle)
(L:WindowRight,bool) - right window (toggle)
Defrosters:
(L:WindowDefrosterControl1,number) - left defroster levers (range: 0 – 50)
(L:WindowDefrosterControl2,number) - right defroster levers (range: 0 – 50)


Benötigen würde ich noch die Buttons für HDG Hold, ALT Hold, usw. vom Autopiloten und die Buttons für Com1, Com2, NAV1, NAV2, BOTH, MKR, ADF, usw.

Wenn jemand eine Idee hat wäre ich froh. Vielen Dank
www.modellbau-technik.at
hannes.dobersberger@modellbau-technik.at
2019-01-08 06:52
Avatar
Hannes
From: Austria
Posts: 164
Supporter
Hat jemand eine Idee?
www.modellbau-technik.at
hannes.dobersberger@modellbau-technik.at
2019-01-13 13:51
Avatar
Hannes
From: Austria
Posts: 164
Supporter
Hallo Tommy1332,

Könntest du mir hier eventuell noch weiterhelfen?

Vielen Dank
www.modellbau-technik.at
hannes.dobersberger@modellbau-technik.at
2019-01-30 13:38
Avatar
jensenvphilip@gmail.com
Posts: 7
Hi there,

I have just started on the CRJ, any chance you can send an example of the LED out lua script you made?

cheers
2019-05-13 11:29
Avatar
CaptainJack
Posts: 5
Guys working on qw787 lua scripts how to programm lvar with encoder I don't have any idea how to do that. Will be there simple tutorial how to use lua in mobiflight since it's added at 7.5 version
2019-06-16 13:52
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
The Lua PlugIn is just a "transmitter" that can Start/Stop Lua Cripts or Macros.

so you can not include Lua scripts or so in Mobiflight itself. Those scripts must be written/saved and included in FSUIPC like in the past....
The "Lua Plugin" is just a plattform you can "start/Stop" a script or to fire a single Macro .

Without that it is needed to controll that things by a FSUIPC Key/Joybutton binding.

A Tutorial was never done by the guy who write this PlugIn. The only stuff we got a.t.m. is this.... https://www.mobiflight.com/forum/message/10232.html
Good Luck !
2019-06-16 15:36
Avatar
nicolapodda
From: EAST PERTH, Australia
Posts: 5
Supporter
iconzenit_swe:

As we say here in Sweden, better late than never! Here comes a little explanation of how I was able to read the AP altitude of my Aerosoft A320, and set it using an encoder. Remember that I'm a total newbie in this particular area and I'm still learning. This step was the first in my project to build some panels for the A320 and that panel is still a work in progress.

The L:Var for that one is AB_AP_ALT_Select. Here is the LUA script I used to "assign" that L:Var to an offset:

iconCode:
first = true

while true do
    if first then
        initialALTVal = ipc.readLvar("L:AB_AP_ALT_Select")
        ipc.writeUD(0x66C0, initialALTVal)
        first = false
    else
        currentALTVal = ipc.readUD(0x66C0)
        ipc.writeLvar("L:AB_AP_ALT_Select", currentALTVal)
    end
end


The file is saved in <FSX root folder>\Modules, I named it a320_test.lua. The offset (0x66C0) is the first in the range that FSUIPC have dedicated for us to use for whatever we like.

One important thing I've learned about L:Vars and offsets is that L:Vars contains the value that is present in the simulator and the offset contains the value that is present on your panel. In this case, reading the L:Var AB_AP_ALT_Select will give you the altitude displayed in the "cockpit". The first time the loop is executed this value is written to the offset 0x66C0, it's like "assigning" that offset to the L:Var and sync the "cockpit" with your panel. The rest of the loop will then only read the value from the panel and write that to the L:Var.

Now, in order for this lua script to be executed at all you can assign it to a key press combination as explained by jumpin84, or you can execute it automatically whenever you start a flight with the A320/321. The latter is done by writing another lua script and save it in the Modules folder as Ipcready.lua:

iconCode:
if ipc.readSTR(0x3D00, 10) == "Airbus A32" then
	ipc.runlua("Lua:a320_test")
end


To show the altitude in MobiFlight you assign a display to the offset that you've chosen and to set the altitude you assign an encoder to the same offset.

I hope this make sense?



Hi, I'm trying to make a FCU for my FSLABS A321. I'm in trouble with the altitude indicator. I made the lua script as described but, doesn't work.

I've already tested the arduino and 7 Segments display with an other aircraft (P3D standard aircraft and pmdg) and it works well.
Can you please guys give me an hand?
Thanks
Nick
Some information..
P4DV4
Registered FSUIPC 5
Genuine FSLAS A321
Mobiflight 8
Arduino mega 2560
[Last edited by nicolapodda, 2021-02-13 09:39]
2021-02-13 02:26
Avatar
fazli
Posts: 91
iconHannes:

Hallo,

Eine Frage zu dem oben angeführten Script. Habe dies so übernommen und auf einige Werte von mir abgeändert. Funktioniert perfekt. Jedoch jegliche weitere Lvar die ich hinzufüge funktionieren nicht mehr. Weiß aber nicht warum. Könnte es eventuell mit den Byte Werten zusammenhängen. Wie finde ich heraus, welchen Wert ich verwenden muss. In der Lvar Liste der A2A stehen nur die Lvars aber sonst keine Informationen. Hier noch mein Code, der soweit funktioniert.

iconCode:
local UB = {r=ipc.readUB,w=ipc.writeUB} -- 1 Byte Int
local UW = {r=ipc.readUW,w=ipc.writeUW} -- 2 Byte Int
local UD = {r=ipc.readUD,w=ipc.writeUD} -- 4 Byte Int
local FLT = {r=ipc.readFLT,w=ipc.writeFLT} -- 4 Byte Float
local DBL = {r=ipc.readDBL,w=ipc.writeDBL} -- 8 Byte Float
local STR = {r=ipc.readSTR,w=ipc.writeSTR} -- String

local EN1 = "66FF" -- master offset enable

local R = 0
local W = 1

--[[
	Every entry in lvar_list corresponds to one offset.
	How to build an entry:
	{"offset", mode, {enable_switches}, {lvars}}
	- offset = fsuipc offset (between 0x66C0 and 0x66FF)
	- mode is either R or W. R means only read from lvar
	and W means only write to lvar. (e.g. an LED displaying
	the flaps status is R. A switch that extends the gear
	is W.)
	- enable_switches = list of offsets which all have to
	be set to 1 otherwise the line gets ignored. This is useful
	for shared cockpit so that if you are not in charge of the
	buttons your switches won't override the switches of the 
	other pilot.
	-- lvars = list of lvars that get the same value written to.
	You should only use one lvar when mode=R.
]]
local lvar_list = {
    {"66D1", W, {}, UB, { "Panellightknob" }},
    {"66D3", R, {}, UB, { "OILPRESSLIGHT" }},
    {"66D4", R, {}, UB, { "VOLTSLIGHT" }},
    {"66D5", R, {}, UB, { "VACLIGHT" }},
    {"66D6", R, {}, UB, { "FUELLIGHT" }},
--Weitere Einträge funktionieren nicht mehr ???
}

-- set this to true if you want to force your own switch positions on start
local initialized = false

while true do
	for _,v in pairs(lvar_list) do
		local offset = v[1]
		local mode = v[2]
		local enable_offsets = v[3]
		local offset_type = v[4]
		local lvars = v[5]
			
		-- check all enable switches are set
		local enabled = true
		for _, enable_offset in pairs(enable_offsets) do
			local val = ipc.readUB(enable_offset)
			if val == 0 then
				enabled = false
			end
		end
		
		if enabled == true then -- skip line if disabled
			if initialized == true and mode == W then -- write mode			
				-- read offset
				local offset_val = offset_type.r(offset)
				
				-- update lvars
				for _, lvar in pairs(lvars) do
					ipc.writeLvar(lvar, offset_val)
				end
			else -- read mode
				-- read lvars
				local lvar_val = ipc.readLvar(lvars[1])
				
				-- update offset
				offset_type.w(offset, lvar_val)
			end
		end
	end
	initialized = true
end


Und die aktuelle Lvar Liste der A2A C172:

iconCode:
A2A C172 Trainer
variables list and notes for simpit builders
Gauges:
(L:AirspeedIndicatedNeedle,number) - airspeed needle
(L:AirspeedTAS,number) - IAS/TAS conversion chart (range: 0 – 110)
(A:ATTITUDE INDICATOR PITCH DEGREES:1,degrees) - artificial horizon, attitude
(A:ATTITUDE INDICATOR BANK DEGREES:1,grad) - artificial horizon, bank
(A:INDICATED ALTITUDE:1,feet) 1000 % 10 / 100 + - altimeter needle (hundreds feet) (range: 0 –200)
(A:INDICATED ALTITUDE:1,feet) 10000 % 100 / 100 + - altimeter needle (thousands feet) (range: 0 –200)
(A:INDICATED ALTITUDE:1,feet) 100000 % 1000 / 100 + - altimeter needle (ten thousands feet) (range: 0 –200)
(A:KOHLSMAN SETTING HG:1,inHg) 27.99 - 24.87562 * - Kohlsman knob in inHg (range: 0 – 100)
(A:KOHLSMAN SETTING HG:1,hectopascals) 950 - - Kohlsman knob in hPa (range: 0 – 100)
(L:Nav1ObsNeedle,number) - nav1 obs (range: 0 -180) – read only – inc/dec by default events
(>K:VOR1_OBI_INC) and (>K:VOR1_OBI_DEC)
(L:Gsi1Needle,keyframe) - glideslope indicator (range: 0 – 100)
(L:Gsi1Flag,enum) - glideslope indicator flag (0 – off, 1 – on)
(L:Cdi1Needle,keyframe) - course deviation indicator (range: 0 – 100)
(L:ToFrom1Needle,enum) - to/from flag (0 – off, 1 – to, 2 – from)
(L:FuelLeftWingTank,gallons) - left fuel tank
(L:FuelRightWingTank,gallons) - right fuel tank
(L:Eng1_EGTGauge,number) - exhaust gas temp in F
(L:EGTGauge_ref,percent) - egt ref needle (range: 0 – 100)
(L:Eng1_GPH,gallons) - fuel flow in gallons per hour
(L:Eng1_OilTemp,celsius) - oil temp in C
(L:Eng1_OilPressure,psi) - oil pressure in psi
(A:SUCTION PRESSURE,inHg) - suction
(L:Ammeter1,amps) - ammeter
(A:DELTA HEADING RATE,degrees per second) 1.1 * -10 max 10 min 10 + 5 * - turn indicator (range: 0 – 100)
(A:TURN COORDINATOR BALL,position) -1 max 1 min 1 + 25 * - ball (range: 0 – 50)
(L:HiAdjust,number) - heading indicator knob
(L:AutopilotHeadingBug,number) - heading bug – read only – inc/dec by default events
(>K:HEADING_BUG_INC) and (>K:HEADING_BUG_DEC)
(L:HeadingGyro,degrees) - heading gyro
(A:VERTICAL SPEED,feet per minute) - vertical speed indicator
(L:Cdi2Needle,keyframe) - course deviation indicator (range: 0 – 100)
(L:ToFrom2Needle,enum) - to/from flag (0 – off, 1 – to, 2 – from)
(L:Cdi2Flag,bool) - course deviation indicator flag (0 – off, 1 – on)
(L:Nav2ObsNeedle,number) - nav2 obs (range: 0 -180) – read only – inc/dec by default events
(>K:VOR2_OBI_INC) and (>K:VOR2_OBI_DEC)
(L:Eng1_RPM,RPM) - engine rpm
(L:e1Hour4,number) - engine hours, thousands
(L:e1Hour3,number) - engine hours, hundreds
(L:e1Hour2,number) - engine hours, tens
(L:e1Hour1,number) - engine hours, ones
(L: e1HourFract1,number) - engine hours, tenths
(L:AdfHdgNeedle,number) - adf heading – read only – inc/dec by default events
(>K:ADF_CARD_INC) and (>K: ADF_CARD _DEC)
(L:AdfCdiNeedle,keyframe) - ADF course deviation needle
(A:WISKEY COMPASS INDICATION DEGREES,degrees) - Whiskey compass
Switches:
(L:Eng1_GeneratorSwitch,bool) - generator switch
(L:Battery1Switch,bool) - battery switch
(>K:TOGGLE_ELECT_FUEL_PUMP1) - fuel pump
(>K:TOGGLE_BEACON_LIGHTS) - default beacon light toggle event
(>K:LANDING_LIGHTS_TOGGLE) - default landing light toggle event
(>K:TOGGLE_TAXI_LIGHTS) - default taxi light toggle event
(>K:TOGGLE_NAV_LIGHTS) - default nav light toggle event
(>K:STROBES_TOGGLE) - default strobe light toggle event
(>K:PITOT_HEAT_TOGGLE) - default pitot heat toggle event
1 (>K:AVIONICS_MASTER_SET) (on)
0 (>K:AVIONICS_MASTER_SET) (off) - default avionics master set event
Center pedestal/lower main dash:
(L:Magnetos1Pct,percent) - starter key (range: 0 – 15: off; 16 – 37: R magneto; 38 – 63: L magneto;
64 – 85: both magnetos; 86 – 100: starter)
(L:FSelC172State,enum) - fuel selector (0 – left, 1 – both, 2 – right)
(L:Eng1_FuelCutOffSwitch,bool) - fuel cutoff lever (on/off)
(L:TrimtabPosition,percent) - elevator trim position– read only – inc/dec by default events
(>K:ELEV_TRIM_DN) and (>K:ELEV_TRIM_UP)
(L:GlareshieldLightKnob,number) - illumination of the main dash (range: 0 – 32)
(L:PedestalLightKnob,number) - illumination of the fuel selector (range: 0 – 32)
(L:RadioLightKnob,number) - illumination of the radiostack (range: 0 – 32)
(L:PanelLightKnob,number) - illumination of the gauges (range: 0 – 32)
(L:StaticAir,bool) - static air lever (on/off)
(L:Throttle1Position,percent) - throttle lever (range: 0 – 100)
(L:Eng1_MixtureManualLever,percent) - mixture lever (range: 0 – 100)
(L:LandFlapsPos,enum) - flaps position lever (0 – up, 1 – 2/4, 2 – 3/4, 3 – down)
(A:TRAILING EDGE FLAPS LEFT PERCENT,percent) - flaps position indicator (range: 0 – 100)
(L:CabinTempControl,percent) - cockpit heat (range: 0 – 100)
(L:CabinVent,percent) - cockpit ventilation (range: 0 – 100)
(>K:PARKING_BRAKES) - default parking brakes event
Radiostack:
KMA 26 Audioselector:
(L:kma26SelectorKnob_pos,enum) - Audio selector knob (0 – inop/com1, 1 – com1, 2 – com2, 3 – inop/com2, 4 – inop/com2)
Com1 button - if com2 transmit selected use default (>K:COM_RECEIVE_ALL_TOGGLE)
Com2 button - if com1 transmit selected use default (>K:COM_RECEIVE_ALL_TOGGLE)
Com3 button - inop (FSX supports just two com channels)
Nav1 button - if (L:kma26Nav1Switch,bool) is zero, toggle default
(>K:RADIO_VOR1_IDENT_DISABLE) event
Nav2 button - if (L:kma26Nav2Switch,bool) is zero, toggle default
(>K:RADIO_VOR2_IDENT_DISABLE) event
Mkr button - if (L:kma26MkrSwitch,bool) is 1 and (A:MARKER SOUND,bool) is 0 toggle default
(>K:MARKER_SOUND_TOGGLE)
if (L:kma26MkrSwitch,bool) is 0 and (A:MARKER SOUND,bool) is 1 toggle default
(>K:MARKER_SOUND_TOGGLE)
DME button - if (L:kma26DmeSwitch,bool) is 1 toggle default
(>K:RADIO_DME1_IDENT_ENABLE)
if (L:kma26DmeSwitch,bool) is 0 toggle default
(>K:RADIO_DME1_IDENT_DISABLE)
ADF button - if (L:kma26AdfSwitch,bool) is 1 toggle default
(>K:RADIO_ADF_IDENT_ENABLE)
if (L:kma26AdfSwitch,bool) is 0 toggle default
(>K:RADIO_ADF_IDENT_DISABLE)
Aux button - inop
Moni button - inop
Marker lights - (L:kma26OMarker,bool) – outer marker; (L:kma26MMarker,bool) – middle marker;
(L:kma26IMarker,bool) – inner marker
KX 155A Com1/Nav1 unit:
Com1 on/off knob - (L:Com1OnOff,bool)
Com1 STBY button - (L:Com1StbySwitch,bool)
Com1 CHAN button - (L:Com1ChanSwitch,bool)
Com1 outer knob - (L:Com1FreqOuterKnob,percent) (range: 0 – 100)
Com1 inner knob - (L:Com1FreqInnerKnob,percent) (range: 0 -100)
Com1 inner knob pull - (L:Com1InnerKnobPull,bool)
Nav1 ident knob - (L:Nav1Ident,bool)
If (L:Nav1Ident,bool) is equal to zero, toggle the (>K:RADIO_VOR1_IDENT_DISABLE) event
Nav1 STBY button - (L:Nav1StbySwitch,bool)
Nav1 MODE button - (L:Com1NavSwitch,bool)
Nav1 outer knob - (L:Nav1FreqOuterKnob,percent) (range: 0 – 100)
Nav1 inner knob - (L:Nav1FreqInnerKnob,percent) (range: 0 – 100)
Nav1 inner knob pull - (L:Nav1InnerKnobPull,bool)
KX 155A Com2/Nav2 unit:
Com2 on/off knob - (L:Com2OnOff,bool)
Com2 STBY button - (L:Com2StbySwitch,bool)
Com2 CHAN button - (L:Com2ChanSwitch,bool)
Com2 outer knob - (L:Com2FreqOuterKnob,percent) (range: 0 – 100)
Com2 inner knob - (L:Com2FreqInnerKnob,percent) (range: 0 -100)
Com2 inner knob pull - (L:Com2InnerKnobPull,bool)
Nav2 ident knob - (L:Nav2Ident,bool)
If (L:Nav2Ident,bool) is equal to zero, toggle the (>K:RADIO_VOR2_IDENT_DISABLE) event
Nav2 STBY button - (L:Nav2StbySwitch,bool)
Nav2 MODE button - (L:Com2NavSwitch,bool)
Nav2 outer knob - (L:Nav2FreqOuterKnob,percent) (range: 0 – 100)
Nav2 inner knob - (L:Nav2FreqInnerKnob,percent) (range: 0 – 100)
Nav2 inner knob pull - (L:Nav2InnerKnobPull,bool)
ADF unit:
ADF on/off knob - (L:AdfOnOffKnob,bool)
ADF button - (L:AdfAdfButton,bool)
BFO button - (L:AdfBfoButton,bool)
FRQ/Arrows button - (L:AdfFrqButton,bool), also set (L:FrqButton,bool) to 1, don’t change to 0 on button release
FRQ/ET button - (L:AdfFrqEtButton,bool) , also set (L:FrqEtButton,bool) to 1, don’t change to 0 on button release
SET/RST button - (L:AdfFrqRstButton,bool) , also set (L:FrqRstButton,bool) to 1, don’t change to 0 on button release
ADF outer knob - (L:AdfFreqOuterKnob,percent) (range: 0 – 100)
ADF inner knob - (L:AdfFreqInnerKnob,percent) (range: 0 – 100)
ADF inner knob pull - (L:AdfFreqInnerKnobPull,bool)
KT76C transponder unit:
0 button - (L:xpdr_0_button,bool) , also set (L:xpdr_digit0,bool) to 1, don’t change to 0 on button release
1 button - (L:xpdr_1_button,bool) , also set (L:xpdr_digit1,bool) to 1, don’t change to 0 on button release
2 button - (L:xpdr_2_button,bool) , also set (L:xpdr_digit2,bool) to 1, don’t change to 0 on button release
3 button - (L:xpdr_3_button,bool) , also set (L:xpdr_digit3,bool) to 1, don’t change to 0 on button release
4 button - (L:xpdr_4_button,bool) , also set (L:xpdr_digit4,bool) to 1, don’t change to 0 on button release
5 button - (L:xpdr_5_button,bool) , also set (L:xpdr_digit5,bool) to 1, don’t change to 0 on button release
6 button - (L:xpdr_6_button,bool) , also set (L:xpdr_digit6,bool) to 1, don’t change to 0 on button release
7 button - (L:xpdr_7_button,bool) , also set (L:xpdr_digit7,bool) to 1, don’t change to 0 on button release
IDT button - (L:xpdr_ident_button,bool)
CLR button - (L:xpdr_clr_button,bool) , also set (L:xpdr_clr,bool) to 1, don’t change to 0 on button release
VFR button - (L:xpdr_vfr_button,bool) , also set (L:xpdr_vfr,bool) to 1, don’t change to 0 on button release
On/off knob - (L:xpdr_onoff_knob_pos,enum) (0 – off, 1 – Standby, 2 – Test, 3 – On, 4 – Alt)
KAP 140 Autopilot unit:
AP button - (L:kap140_ap_button,bool), also set (L:kap140_ap,bool) to 1, don’t change to 0 on button release
HDG button - (L:kap140_hdg_button,bool) , also set (L:kap140_hdg,bool) to 1, don’t change to 0 on button release
NAV button - (L:kap140_nav_button,bool) , also set (L:kap140_nav,bool) to 1, don’t change to 0 on button release
APR button - (L:kap140_apr_button,bool) , also set (L:kap140_apr,bool) to 1, don’t change to 0 on button release
REV button - (L:kap140_rev_button,bool) , also set (L:kap140_rev,bool) to 1, don’t change to 0 on button release
ALT button - (L:kap140_alt_button,bool) , also set (L:kap140_alt,bool) to 1, don’t change to 0 on button release
UP button - (L:kap140_up_button,bool) , also set (L:kap140_up,bool) to 1, don’t change to 0 on button release
DN button - (L:kap140_dn_button,bool) , also set (L:kap140_dn,bool) to 1, don’t change to 0 on button release
ARM button - (L:kap140_arm_button,bool) , also set (L:kap140_arm,bool) to 1, don’t change to 0 on button release
BARO button - (L:kap140_baro_button,bool) , also set (L:kap140_baro,bool) to 1, don’t change to 0 on button release
AP inner knob - (L:kap140_InnerKnob,percent) (range: 0 – 100)
AP outer knob - (L:kap140_OuterKnob,percent) (range: 0 – 100)
KN62 DME unit:
On/off switch - (L:kn62OnOff,bool)
Function switch - (L:kn62Function,enum) (0 – Remote, 1 – Frequency, 2 – Groundspeed/Time to station
DME outer knob - (L:Kn62OuterKnob,percent) (range: 0 – 100)
DME inner knob - (L:Kn62InnerKnob,percent) (range: 0 – 100)
DME inner knobPull - (L:Kn62InnerKnobPull,bool)
FSX GNS400 GPS:
gps_on_switch - toggle (L:GpsOnSwitch,bool), (>K:GPS_POWER_BUTTON) and (>K:GPS_CLEAR_ALL_BUTTON)
NRST button - (>K:GPS_NEAREST_BUTTON)
OBS button - (>K:GPS_OBS_BUTTON)
MSG button - (>K:GPS_MSG_BUTTON)
FPL button - (>K:GPS_FLIGHTPLAN_BUTTON)
TERR button - (>K:GPS_TERRAIN_BUTTON)
PROC button - (>K:GPS_PROCEDURE_BUTTON)
RNG plus button - (>K:GPS_ZOOMOUT_BUTTON)
RNG minus button - (>K:GPS_ZOOMIN_BUTTON)
D button - (>K:GPS_DIRECTTO_BUTTON)
MENU button - (>K:GPS_MENU_BUTTON)
CLR button - toggle (>K:GPS_CLEAR_BUTTON) event and increase (L:GpsClrSwitchCounter,enum) by one.
If (L:GpsClrSwitchCounter,enum) is equal 90 toggle (>K:GPS_CLEAR_ALL_BUTTON) event and reset the counter.
ENT button - (>K:GPS_ENTER_BUTTON)
GPS outer knob - (L:GpsOuterKnob,percent) for knob rotation in VC, use (>K:GPS_GROUP_KNOB_DEC) and
(>K:GPS_GROUP_KNOB_INC) events for GPS function.
GPS inner knob - (L:GpsInnerKnob,percent) for knob rotation in VC, use (>K:GPS_PAGE_KNOB_DEC) and
(>K:GPS_PAGE_KNOB_INC) events for GPS function.
GPS inner knob push - toggle (L:GpsInnerKnobPush,bool) for VC animation, use (>K:GPS_CURSOR_BUTTON) event for GPS function.
Misc:
Headphones simulation:
To set the headphones on three things are needed in this sequence:
(L:Headphones,bool) set to 1; (L:SystemCondSelectFSX,number) set to 57; (L:SystemCondValueFSX,number) set to 1
To set the headphones off these three variables has to be set in this sequence:
(L:Headphones,bool) set to 0; (L:SystemCondSelectFSX,number) set to 57; (L:SystemCondValueFSX,number) set to 0
Airframe hours counter:
(L:a1Hour4,number) - airframe hours, thousands
(L:a1Hour3,number) - airframe hours, hundreds
(L:a1Hour2,number) - airframe hours, tens
(L:a1Hour1,number) - airframe hours, ones
(L: a1HourFract1,number) - airframe hours, tenths
Doors:
(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_1) - left doors (toggle)
(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_2) - right doors (toggle)
(L:WindowLeft,bool) - left window (toggle)
(L:WindowRight,bool) - right window (toggle)
Defrosters:
(L:WindowDefrosterControl1,number) - left defroster levers (range: 0 – 50)
(L:WindowDefrosterControl2,number) - right defroster levers (range: 0 – 50)


Benötigen würde ich noch die Buttons für HDG Hold, ALT Hold, usw. vom Autopiloten und die Buttons für Com1, Com2, NAV1, NAV2, BOTH, MKR, ADF, usw.

Wenn jemand eine Idee hat wäre ich froh. Vielen Dank

2021-07-21 04:47
Avatar
fazli
Posts: 91
Hi,hannes
I don't see script heading offset value output.
Example I want turn on LED lighting if I press button heading.
Can I using L:kap_ 140_heading.
What should we I do first.can u give me example

C172 add-on aircraft
P3dv4
2021-07-21 04:50
Avatar
fazli
Posts: 91
Hi,
I try write script marco.how to on GPS.

[macro]
1=offon5=set
Than I save in module as macro file.

In my case GPS can't on via button mobiflight just look movement switch in sim.
My GPS can on using mouse only.

Here I show you my vedio.

https://youtu.be/tWCIIOJ8cO4
2021-08-04 08:15
Avatar
d_sirius
Posts: 2
Thanks for the info. I'm about to start on a panel for the A2A Cessna 182 so this will really help.
2022-01-19 21:28
Go to page 1Go to page 2123Go to page 4Go to page 3