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

Why did you not look at or try that other lvar? First, try logging therm both to see how they change when you turn the knob in the VC. You can do this in lua add this to your current script, or create a new one):

function logLvar(varname, value)
    ipc.log("**** Lvar " .. varname .. " = " .. value)
end

event.Lvar("L:knob_light_dim ", 100, logLvar)
event.Lvar("L:knob_light_dim1 ", 100, logLvar)

That should show you how the lvar values change both when you use the VC and it works and when you use your assignment that only controls the knob and not the actual brightness.  If the other lvar also changes when using the VC but not when using your assignment, you will also need to set the value for that lvar in the script.
Also, do you know whet the custom controls 69636 and 69637 are doing? Try assigning to them to see what they do – if they increase/decrease the brightness, you can also send them in your lua script using ipc.control.


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

Hi John

 Increasing the dimmer the log shows 69636 and  decreasing dimmer the log shows as 69637.

How is spending to the ipc control in the Lua script achieved

Thanks 


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

Did some testing. I assigned the custom controls 69636 and 69637 to a rotary encoder on my panel and got the light intensity to work at last.

How do I now enter 69636 and 69637 into my Lua script so it works in that 

Cheers 


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

Posted by: @reco01

I assigned the custom controls 69636 and 69637 to a rotary encoder on my panel and got the light intensity to work at last.

Do those in/dec controls also move the knob? If so, you don’t need to use the lvar.

Posted by: @reco01

How do I now enter 69636 and 69637 into my Lua script so it works in that 

You can use the lua function ipc.control to send any control – see the lua documentation. However, as they are in/dec controls, they are not really suitable for an axis assignment – better to use (rotary) buttons for such controls. If you want to use these an axis (together with srtting the lvar), you probably want to send multiple commands. In fact, the number of commands sent should vary, depending on the delta or increment in the axis value. So keep the current lvar value you are setting in a local variable, and then when you update this you know the difference between the last and current value and can send a different number of commands depending upon the difference. Something like:

local ThrottleOffset = 0x66D0
local oldValue = -1; 
local delta = 5 -- change this to get more or less in/dec controls

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

if oldValue  == -1 then -- iitialise oldValue to current value
    oldValue = newValue
end

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

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

-- send ind/dec controls
if newValue > oldValue then -- need to increment
  while (newValue > oldValue)
  do
      ipc.control(69636)
      ipc.sleep(10)
      oldValue = oldValue + delta
  end
else -- need to decrement
  while (newValue < oldValue)
  do
      ipc.control(69637)
      ipc.sleep(10)
      oldValue = oldValue - delta
  end
end

oldValue = newValue
end

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

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

John


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

Thanks for the info

I have placed the above  into the working Lua lightknobcontrol with no luck and the Lua file is not working so somewhere in the following file I have made an error 

local LightKnobOffset = 0x66D4

local oldValue = -1; 
local delta = 5 -- change this to get more or less in/dec controls

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 = (16384 + value) / 32768
newValue = (value -3000) / 193.06

if oldValue  == -1 then -- iitialise oldValue to current value
    oldValue = newValue
end

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

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

-- send ind/dec controls
if newValue > oldValue then -- need to increment
  while (newValue > oldValue)
  do
      ipc.control(69636)
      ipc.sleep(10)
      oldValue = oldValue + delta
  end
else -- need to decrement
  while (newValue < oldValue)
  do
      ipc.control(69637)
      ipc.sleep(10)
      oldValue = oldValue - delta
  end

oldValue = newValue

end


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

ipc.log("Milviz MD530F lightKnobControl-handling lua now running")

Reply
Page 3 / 4