Jump to content
The simFlight Network Forums

FSUIPC Conditional Button Programming


Recommended Posts

I am trying to use a rotary encoder to have dual functionality! So that when moving the heading bug (for example) it will turn the heading bug 1degree per pulse! (Which is the normal speed at the moment).

But I would like to use the push button on the rotary encode to be able to speed the rotation! so that when the button is pressed the rotary encoder will move the heading bug 5degrees per pulse and when pressing the push button again it will revert back to the original speed of 1degree per pulse!

How can this be done?

Link to comment
Share on other sites

Read the documentation...The "FSUIPC4 for Advanced Users.pdf"...the techniques for doing this are explained there.

One can use the compound button programming approach or even a small Lua script to do whatever you wish.

I use a user-definable location to create multiple "modes" for the switches on my dual throttle quadrant. In one

aircraft I have 8 "modes", that is to say that each of my 10 switches have 8 unique functions, or 80 functions

overall.

I would guess that using a simple Lua script should allow you to handle the two different speeds for the encoder

with an "if" "els" construct using the button state as the tested variable.

Paul

Link to comment
Share on other sites

Thank You for answers. The question PositiveAero asked is exactly one of the two I intended to ask too. Could you also tell me please if I can change heading bug stepping as a function of encoder rotation speed or amount (like it works with mouse wheel)? I actually never tried scripting for FSUIPC or with LUA but since I'm a soft developer this wouldn't be the problem if it is practically possible. In case it also appears in documentation, just send me RTFM. :razz:

Kind Regards

Link to comment
Share on other sites

Thank You for answers. The question PositiveAero asked is exactly one of the two I intended to ask too. Could you also tell me please if I can change heading bug stepping as a function of encoder rotation speed or amount (like it works with mouse wheel)? I actually never tried scripting for FSUIPC or with LUA but since I'm a soft developer this wouldn't be the problem if it is practically possible. In case it also appears in documentation, just send me RTFM. :razz:

Check the FSUIPC Documents folder, "Example Lua Plugins" and see the "TripleUse.lua" example there for multiple actions on one button. that should give you the ideas you need for rotaries too. There's also an example of exactly what you want in a thread somewhere here. Er ... yes. Try reading rotary-encoder-input-speed.

Regards

Pete

Link to comment
Share on other sites

  • 2 weeks later...

HI all and thanks very much for the help with this, and apologies for the delay in reply I was away for a week :)

Reading the above it seems that the answer lies in an lua script! this is not an area im familiar with but even if it was it seems a complex solution to the problem (just my impression)?

So I tough i would clarify on my initial question and also to summaries my investigation since in posted the initial question:

I would like to use a push button on a rotary to toggle a flag in such a way that when the rotary encoder is rotated either clockwise or anticlockwise to move a heading bug (just as an example in reality I have 14 functions i want to do this with), the speed of movement can be determined (ie slow - fast or 1 degree - 5 degree per pulse). I am trying to implement this functionality from within the FSUIPC.INI [buttons] section using compound FSUIPC button syntax (see below).

My understanding so far is I am using joystick 0, button 7 which is a push button to set the flag so that when this is pressed it toggles a flag for both buttons 0 & 1 which are the inputs set to decrement and increment the heading bug respectively. The compound (CP) commands I believe will activate the control dependent on the button flag status (ie command 'CP(F-0,1)0,1,C65870,0' will operate the HEADING_BUG_INC control (C65879) if the flag is not set. I would expect a control to be available which would be similar to HEADING_BUG_INC_FAST. I could not find this so I am wondering if there is another way around this (ie repeat the slow (CP) comand say five times for 5 degree shift or not. Can anyone help?

[buttons]

1=P0,7,C1005,0; toggle flag for button (0,0) when button(0,7) pressed

2=P0,7,C1005,1; toggle flag for button (0,1) when button(0,7) pressed

3 =CP(F-0,0)0,0,C65880,0; HEADING_BUG_DEC if flag not set (slow)

4 =CP(F+0,0)0,0,C ?????,0; HEADING_BUG_DEC if flag set (fast) - replace C ????? with Hdg bug dec fast control if one exists!

5 = CP(F-0,1)0,1,C65879,0; HEADING_BUG_INC if flag not set (slow)

6 =CP(F+0,1)0,1,C?????,0; HEADING_BUG_INC also if flag set (fast) - replace C ????? with Hdg bug inc fast control if one exists

Link to comment
Share on other sites

[buttons]

1=P0,7,C1005,0; toggle flag for button (0,0) when button(0,7) pressed

2=P0,7,C1005,1; toggle flag for button (0,1) when button(0,7) pressed

3 =CP(F-0,0)0,0,C65880,0; HEADING_BUG_DEC if flag not set (slow)

4 =CP(F+0,0)0,0,C ?????,0; HEADING_BUG_DEC if flag set (fast) - replace C ????? with Hdg bug dec fast control if one exists!

5 = CP(F-0,1)0,1,C65879,0; HEADING_BUG_INC if flag not set (slow)

6 =CP(F+0,1)0,1,C?????,0; HEADING_BUG_INC also if flag set (fast) - replace C ????? with Hdg bug inc fast control if one exists

First, there is an evident misunderstanding here. The button flags for a real button are automatically toggles each time that button is pressed. This is a deliberate action to allow an easy adaptation of a momentary button as a locking toggle switch.

If you want to use a flag to change the action of a button press you need to choose one which cannot be used by a real button -- i.e. one associated with a joystick you don't actually have.

So, change your lines 1 and 2 to toggle flag 15,0, and 15,1 for example.

Second, yes, in order to make something change faster, send the same control several times. Just repeat the line with different line numbers. and, of course, the same condition. That's an option for all FS controls.

However, there's an easier option in this specific case because FSUIPC provides a special additional pair of controls (not FS ones) actually called Heading bug inc fast and Heading bug dec fast. They operate in 10s. In fact I think (not sure now, they are so old) that both change it to the next or previous 10 degree mark. I'm surprised you missed these as they are listed in the drop down assignments, and also in the Advanced User's list of controls a little after the 1005 you are using.

Regards

Pete

Link to comment
Share on other sites

  • 3 weeks later...

Thanks Pete,

I have now got this to work, the extract from my .ini file is below for anyone who wants to do the same this. But please change to suite your button & joystick config.

The following is the part of FSUIPC code which enables the fast / slow pointer rotation speed to be toggled when the rotary encoder push button is pressed.

It works with Heading Bug, VOR1, VOR2, Autopilot Airspeed, Autopilot Altitude and Autopilot verticle speed settings:

41=P0,14,C1005,4096 ; toggle flag for pseudo button (16 ,0) when button (0,14) pre

42=CP(F-16,0)0,6,C65880,0 ; HEADING_BUG_DEC if flag not set (slow)

43=CP(F+16,0)0,6,C1024,0 ; HEADING_BUG_DEC if flag set (fast)

44=CP(F-16,0)0,7,C65879,0 ; HEADING_BUG_INC if flag not set (slow)

45=CP(F+16,0)0,7,C1025,0 ; HEADING_BUG_INC if flag set (fast)

46=CP(F-16,0)0,10,C65662,0 ; VOR1 OBI DEC if flag not set (slow)

47=CP(F+16,0)0,10,C1026,0 ; VOR1 OBI DEC if flag set (fast)

48=CP(F-16,0)0,11,C65663,0 ; VOR1 OBI INC if flag not set (slow)

49=CP(F+16,0)0,11,C1027,0 ; VOR1 OBI INC if flag set (fast)

50=CP(F-16,0)0,12,C65664,0 ; VOR2 OBI DEC if flag not set (slow)

51=CP(F+16,0)0,12,C1028,0 ; VOR2 OBI DEC if flag set (fast)

52=CP(F-16,0)0,13,C65665,0 ; VOR2 OBI INC if flag not set (slow)

53=CP(F+16,0)0,13,C1029,0 ; VOR2 OBI INC if flag set (fast)

54=P0,15,C1005,4097 ; toggle flag for pseudo button (16 ,1) when button (0,15) pre

55=CP(F-16,1)0,0,C65897,0 ; AP_SPD_VAR_DEC if flag not set (slow)

56=CP(F+16,1)0,0,C1020,0 ; AP_SPD_VAR_DEC if flag set (fast)

57=CP(F-16,1)0,1,C65896,0 ; AP_SPD_VAR_INC if flag not set (slow)

58=CP(F+16,1)0,1,C1021,0 ; AP_SPD_VAR_INC if flag set (fast)

59=CP(F-16,1)0,2,C65893,0 ; AP_ALT_VAR_DEC if flag not set (slow)

60=CP(F+16,1)0,2,C1016,0 ; AP_ALT_VAR_DEC if flag set (fast)

61=CP(F-16,1)0,3,C65892,0 ; AP_ALT_VAR_INC if flag not set (slow)

62=CP(F+16,1)0,3,C1017,0 ; AP_ALT_VAR_INC if flag set (fast)

63=CP(F-16,1)0,4,C65895,0 ; AP_VS_VAR_DEC if flag not set (slow)

64=CP(F+16,1)0,4,C1022,0 ; AP_VS_VAR_DEC if flag set (fast)

65=CP(F-16,1)0,5,C65894,0 ; AP_VS_VAR_INC if flag not set (slow)

66=CP(F+16,1)0,5,C1023,0 ; AP_VS_VAR_INC if flag set (fast)

Thanks very much and on to the next issue :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.