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
Aurelien
Posts: 6
Hello everyone,

I work slowly into my interface work of cessna 172 A2A with mobiflight.

Currently, I am trying to recreate the panel of alarms.

I isolated the corresponding Lvar.

I set an LUA code to assign these Lvar to free offset.

Here is my code for the two LEDs of the LOW FUEL signal, L and R:

iconCode:
-- Fuel L
	function FuelL (Lvarname, value)
	ipc.writeUB(0x3348, ipc.readLvar("FuelLLight"))
	end
		FuelL ("FuelLLight", ipc.readLvar("FuelLLight"))
		event.Lvar("FuelLLight", 100, "FuelL")
-- Fuel R
	function FuelR (Lvarname, value)
	ipc.writeUB(0x334c, ipc.readLvar("FuelRLight"))
	end
		FuelR ("FuelRLight", ipc.readLvar("FuelRLight"))
		event.Lvar("FuelRLight", 100, "FuelR")


this code works perfectly, my LEDs flash when they flash in the virtual cockpit, stop if I cut the battery, etc.

On this panel of alarms, I have 7 differents entries to manage:
1: FUEL L
2: FUEL R
3: Pitch Trim
4: OIL Press
5: VAC L
6: VAC R
7: VOLTS

however, if I continue like this, I will use 7 different offsets, to use only the first bit of each byte ...

I found this, which explains how to use each bit separately from the same byte:
https://tabar57.blog4ever.com/comment-economiser-des-offsets-libres-fsuipc-en-manipulant-des-bits-sous-lua


then, tried with this code, to work only with the 3348 byte

iconCode:
-- Fuel L
	function FuelL (Lvarname, value)
	ipc.writeUB(0x3348, ipc.readLvar("FuelLLight"))
        ipc.clearbits(0x3348,2)
	end
		FuelL ("FuelLLight", ipc.readLvar("FuelLLight"))
		event.Lvar("FuelLLight", 100, "FuelL")
-- Fuel R
	function FuelR (Lvarname, value)
	ipc.writeUB(0x3348, ipc.readLvar("FuelRLight"))
        ipc.clearbits(0x3348,1)
	end
		FuelR ("FuelRLight", ipc.readLvar("FuelRLight"))
		event.Lvar("FuelRLight", 100, "FuelR")


but that does'nt work, LEDs are no longer individualized ...

then, I tried with the MASK function of mobiflight, but without success either ...

Do you have an idea about the problem? :blink:
thank you
[Last edited by Aurelien, 2019-08-20 09:58]
2019-08-20 09:53
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

At first check your Offset Area.

3340 and the follow are Joystick Input Commands.
iconQuote:

3340 36 This area is used for externally signalled “joystick button”
control, a set of 288 "virtual buttons". Each DWORD or 32 bits
represents one “joystick” with 32 buttons. If an external program
sets or clears a bit in any of these 9 DWORDS the “Buttons”
page in FSUIPC will register the change as a button operation on
one of Joystick numbers 64 to 73 (corresponding to the 9
DWORDs). So, FSUIPC can be used to program whatever
actions the user wants.



I recommend to use for custom things a free Area of FSUIPC. Not handle Offsets that are execute something internal.
Use 66C0 above or the PMDG, Magenta or other Areas from AddOns you will not use at the moment.

***********************

About your code. Here im not advanced.... But logical its wrong.
As the name said.... "clearbits" means you DELETE the Bit. What you need is "setbits" This will SET a Value
(Check the "Lua Library.pdf" File in the Modules/Documents Folder for further information )

********************

By the way....
Its correct you can write Data to a Bit.... It also save maby a millicsecond of time in case Mobiflight not must read a Full Byte ( whatever just the Information of the first bit is needed) .... But Sebastian said its no problem for Mobiflight to read 1000 Bytes or more.... And the Range in FSUIPC of Free Offsets is also extremly large.
I personaly would not think about using Bits ..... If it work easy then do it..... If you have problems simply use Byte. There should be no disadvantage with it.
Good Luck !
2019-08-20 12:26
Avatar
Pietrogramma
Posts: 19
Hi Aurelien, I reopen this your old post to see if you were able to create the script to play the Cessna C172 annunciator panel. If so, can you give me a hand?
Thank you and hello
2020-05-05 23:23
icon