Jump to content
Sign in to follow this  
turner112

FSUIPC and rotary encoder "speed"

Recommended Posts

Hi all-

 

Just bought FSUIPC as I'm building some small controllers.

 

One is a rotary encoder with a pushbutton set up to turn the heading bug on my HSI.

 

It works, but turns s l o w l y.

 

I can set it up to turn fast, but it jumps 10 degrees or so when I do that.

 

Is there a way I can tell FSUIPC to increase the speed based on how fast I'm turning the encoder?

 

Alternately... is there a way I can use the pushbutton to toggle between fast/slow (fine/course) tuning?

 

thanks!

Andrew

Share this post


Link to post
Share on other sites

Here's how I do it with LINDA. Basically you set/reset a global variable on the push-switch UP and DOWN events. Then you check this in the events for rotating the knob left and right so you know whether to do a fast or slow operation. If you do this with the UP and DOWN events (rather than toggling the variable on the DOWN event) you can get fine adjustment when you just rotate the knob and coarse adjustment when you push and turn at the same time.

 

I use this for all my rotary controls and it works great. (LINDA has its own SHIFT functions, BTW, so you could do this without the global variable, but historically this didn't work very well so I did it myself.) You can see all my code by visiting my forum and downloading the Almost Aviation library. This is Lua code, so you can use it without LINDA with a few changes. (Mainly you will need to use FSUIPC's library functions to maintain the global 'SHIFT' variable.)

AAL_RotaryShiftActive = 0  -- This is public, so other modules can use the SHIFT
local BUG_MULTIPLIER = 10  -- Determines how fast to do coarse rotary knob adjustments

function AAL_Rotary_Shift_ON()
    AAL_RotaryShiftActive = 1
end

function AAL_Rotary_Shift_OFF()
    AAL_RotaryShiftActive = 0
end

function AAL_Heading_Bug_Left()
    local nSteps = 1
 
    if AAL_RotaryShiftActive == 1 then
        nSteps = BUG_MULTIPLIER
    end
 
    for n = 1, nSteps do
        _HEADING_BUG_DEC()
    end
end
 
function AAL_Heading_Bug_Right()
    local nSteps = 1
 
    if AAL_RotaryShiftActive == 1 then
        nSteps = BUG_MULTIPLIER
    end
 
    for n = 1, nSteps do
        _HEADING_BUG_INC()
    end
end

MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

Hi... I have doubts that FSUIPC's button polling rates and Lua load-compile-test rates would be adequate for a dial instead of a button being pushed by a finger. I'd recommend looking at the new HID facilities for joysticks, just released today. FSUIPC 4.704 or 3.992 feature these (and WideClient 6.88). Download (from "Download Links" subforum) the latest Lua plug-ins documents and examples and see the "HidDemo" lua plug-in. That does a lot more than you'd need. You'd only need to read certain "axes", those corresponding to your dials. The rest could be left to normal methods.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...