This are the (new) Support Forums for FSUIPC and related products.

These forums replace the old support forums which have been running for 20+ years. The old forums contain a wealth of information on all FSUIPC products, and are still available (until the end of the year) for read-only here.

At the moment these new forums are quite empty – I will be updating the FAQ section and copying across the User Contributions from the old forums in the next few months.

Please note that you will need to Register and Login to post for support, and also to download attachments. You can view these forums without registering.

Support is also available via Discord. Please use the following invite link to join the FSUIPC Discord server:
https://discord.gg/zjwUTrxmmE

Local panel Variabl…
 
Notifications
Clear all

[Solved] Local panel Variables looking for a particular switch

Posts: 113
Admin
(@fsuipc)
Joined: 6 months ago

Posted by: @reco01

I ran log Lvars and got this “113844 LUA.1: L:knob_light_dim=95”  What does 113844 refer to ?

That is a timestamp Every line inthe log has a timestamp, in milliseconds, so that was logged 113.844 seconds after FSUIPC was started.

Posted by: @reco01

As you mentioned I could use the current  throttle LAU and modify it.

Do I copy the throttle Lua and rename it knob_light_dim and in the Lua script just replace any throttle  reference  with knob_light_dim and of course change the calibration and then place the script in the ini file as I did with the throttle axis

You can either use the same script or create a new script, up to you. If its easier for you to copy, rename and adjust the existing script (and add the script to the auto-section in your ini file), then do that. Alternatively, you can use the same script by adding an additional event.offset call and an additional event handling function. You also need to use a different offset (e.g. 0x66D4) and assign your axis to that offset.

However, if using a rotary for this, this would depend on how the rotary works. If the rotary is an axis, then this will work. But most rotaries work on buttons, using either 1 or 2 buttons (if 2, then 1 for fast and another for slow movement) in each direction. If using a rotary, you would need a different lua that increments/decrements the value of the lvar when the rotary buttons are triggered. If this is the case, I can provide further information on how to do this if needed.

John


Reply
Posts: 11
Registered
Topic starter
(@reco01)
Joined: 2 months ago

Hi John

If you could provide further information on using rotary encoders that would be great.

I could use either encoders or a spare potentiometer. I have some spare inputs on my bodnar board including a Dial input. I use CTS288 encoders for ADF , HSi and VOR and have spare button connections. 

If using the throttle Lua file would I just replace any reference of the word throttle and replace it with knob_light_dim

 

Cheers 

 

 


Reply
Posts: 173
Moderator
(@fsuipc-support)
Joined: 3 months ago

If you want to use lua, you should learn the basics. Try
  – googling for an on-line tutorial
  – read the FSUIPC documentation, There are two documents, one on how lua plugins work and another
    describing the additional lua functions (API) that FSUIPC provides
  – look at the provided lua examples (should be in your FSUIPC4 Documents folder)

Posted by: @reco01

If you could provide further information on using rotary encoders that would be great.

There are various ways to do this. The easiest is probably to have a lua script that waits for the button events on your rotary, using event.button. You should register for all of your rotary buttons, so 2 or 4 events, depending on your rotary. You can use the same event handling function for each if you like, or have a different handling function. I would use just one handling function, and use a conditional statement (i.e. an ‘if…’ clause) on the button number to determine the increment or decrement value. The event handling function would read the current value if the lvar (or you can have this already stored in a local variable) using ipc.readLvar, increment or decrement that value by the required amount, depending on which button event was received, and then just write/update the lvar to the new value using ipc.writeLvar.

Posted by: @reco01

If using the throttle Lua file would I just replace any reference of the word throttle and replace it with knob_light_dim

As I said, you can use the same script or copy the throttle one and update it. This is your current script:

local ThrottleOffset = 0x66D0

function throttleControl(offset, value)
-- Calibrate value from range -16384 - +16384 to 0-100
-- NB if the lvar range is fifferent, change this, e.g. if the range is 0-1, use
-- newValue = (value + 16384) / 32768
newValue = (3000 -value) / 193.06

--ipc.log("Throttle axis value is " .. value .. " resulting in lvar value " .. newValue)

-- send value to lvar
ipc.writeLvar("L:UH1_THROTTLE", newValue)

end

event.offset(ThrottleOffset, "SD", "throttleControl")

ipc.log("Milviz Bell uh1 redux ThrottleCollective-handling lua now running")

As I said, add a new event on a different offset, and a new event handling function for the light dim knob:

local ThrottleOffset = 0x66D0
local LightKnobOffset = 0x66D4

function throttleControl(offset, value)
-- Calibrate value from range -16384 - +16384 to 0-100
-- NB if the lvar range is different, change this, e.g. if the range is 0-1, use
-- newValue = (value + 16384) / 32768
newValue = (3000 -value) / 193.06

--ipc.log("Throttle axis value is " .. value .. " resulting in lvar value " .. newValue)

-- send value to lvar
ipc.writeLvar("L:UH1_THROTTLE", newValue)

end


function lightKnobControl(offset, value)
-- Calibrate value from range -16384 - +16384 to 0-100
-- NB if the lvar range is different, change this, e.g. if the range is 0-1, use
-- newValue = (value + 16384) / 32768
newValue = (3000 -value) / 193.06

--ipc.log("Knob Light Dim axis value is " .. value .. " resulting in lvar value " .. newValue)

-- send value to lvar
ipc.writeLvar("L:knob_light_dim", newValue)

end

event.offset(ThrottleOffset, "SD", "throttleControl")
event.offset(LightKnobOffset , "SD", "lightKnobControl")

ipc.log("Milviz Bell uh1 redux ThrottleCollective-handling lua now running")

and assign your potentiometer / axis to FSUIPC offset 66D4.

Note that the calibration line:

    newValue = (3000 -value) / 193.06

assumes the axis is reversed and has the same range as your throttle axis. Adjust this if needed, so the axis range (whatever that is) maps to the lvar range.

Alternatively, use a separate lua script (using the same code I added to that one) and have the new script auto-started.

John


Reply
1 Reply
Registered
(@reco01)
Joined: 2 months ago

Posts: 11

Thanks John

Knob is rotating on the panel but the panel lights dont change.   

When I use the mouse in the cockpit and turn the knob the panel lights change from dim to bright.

There are two Lvar 

knob_light_dim 

knob_light_dim1

knob_light_dim1 controls the panel knob via the Lua script 

Do both of them need to be in the Lua for the knob to move and the light to work awell 

Cheers 

Rhys


Reply
Posts: 113
Admin
(@fsuipc)
Joined: 6 months ago

Posted by: @reco01

Do both of them need to be in the Lua for the knob to move and the light to work awell 

i have no idea – why don’t you just try it?
Also try looking at / logging the lvar values – list the values, turn the knob with the mouse, then lust the values again. Do both of them change? If so, you need to set both.

Also try logging events – do you see any events logged when you turn the knob with the mouse?

 


Reply
Posts: 11
Registered
Topic starter
(@reco01)
Joined: 2 months ago

Hi, 

After getting the logging window back, thank you for that. I logged the control knob in 3d cockpit panel and logged the 664D offset when turning the dial in my cockpit.

Apart from the PANEL_LIGHTS_TOGGLE that show in the log I am unsure of what to make of the rest of the data 

 

 

Cheers 

Rhys 


Reply
Page 2 / 4