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.

icon
Avatar
jensenvphilip@gmail.com
Posts: 7
Hi all,

I found this awesome lua script here that records the offset states.

my problem is I am noticing an obvious delay in the master caution warning blinking on my LED vs the virtual cockpit master caution blink.

I can see from my mobiflight that that readings are in sync with FSUIPC and is displayed on my LED. However as said the virtual cockpit is consistent and not delayed and holding pauses...

any suggestion to how I can fix it?

video here:

https://drive.google.com/open?id=1g9cQosH0IkfUboUdqcw5xNpWu_zEEBa]
https://drive.google.com/open?id=1fa1wfjzfV888ycR-PLxbk3gaDcVT03ya


script used here:
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 = "66C0" -- 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 = {
	{"66C0", R, {}, UB, { "ASCRJ_GSC_MASTER_CAUT_ON" }}
}

-- 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
[Last edited by jensenvphilip@gmail.com, 2019-05-13 14:13]
2019-05-13 12:25
icon