Jump to content
The simFlight Network Forums

Increment / Decrement For Macros


Recommended Posts

Dear Pete,

I have looked everywhere and tried everything with no luck. I have programmed a joystick button (2,0) as a 6 position switch using offset 66C0 to increment the range of a 3rd party HSI between 10,20,40,80,160 and 320 miles. I have identified the range Lvar and its corresponding parameters with which i have created the Macros files (CM) for each position. The current setup to INCREASE the range is as follows and works,

40=P2,0,Cx310066C0,x00050001

41=B66C0=0 P2,0,CM5:1,10 (starting point)

42=B66C0=1 P2,0,CM6:1,20

43=B66C0=2 P2,0,CM7:1,40

44=B66C0=3 P2,0,CM8:1,80

45=B66C0=4 P2,0,CM9:1,160

46=B66C0=5 P2,0,CM10:1,320

I have tried programming joystick button (2,1) also using offset 66C0 to DECREASE the range depending on the current offset value from joystick button (2,0) with no success, can you please lead me in the right direction on how the decrement code should be or look like. I imagine joystick buttons (2,0) and (2,1) need to be dependent of each other an if so do i need to use different offsets for each one? I have used the preselection concept and came up with the following but is not working. Please note the switch is not cyclic, it only travels between 0 and 5. Another point to note is the behavior of the Lvar, its value (parameter) changes accordingly but goes to zero immediately after nonetheless the range in the HSI gauge stays where it should. I just point put the latter since the Lvar behavior caught my attention and it may or may not be relevant to my query. The comments on brackets are not part of .INI file, I just included them to illustrate the reasoning.

47=P2,1,Cx410066C0,x00050001

48=B66C0=0 P2,1,CM5:1,10 (cannot go further down)

49=B66C0=1 P2,1,CM5:1,10

50=B66C0=2 P2,1,CM6:1,20

51=B66C0=3 P2,1,CM7:1,40

52=B66C0=4 P2,1,CM8:1,80

53=B66C0=5 P2,1,CM9:1,160

 

Regards,

Alan

 

 

 

Link to comment
Share on other sites

5 hours ago, tomf14 said:

40=P2,0,Cx310066C0,x00050001

41=B66C0=0 P2,0,CM5:1,10 (starting point)

42=B66C0=1 P2,0,CM6:1,20

43=B66C0=2 P2,0,CM7:1,40

44=B66C0=3 P2,0,CM8:1,80

45=B66C0=4 P2,0,CM9:1,160

46=B66C0=5 P2,0,CM10:1,320

Please show the actual part of the INI file, which will have those lines properly annotated so I can understand what they represent without resorting to the code!

5 hours ago, tomf14 said:

I imagine joystick buttons (2,0) and (2,1) need to be dependent of each other an if so do i need to use different offsets for each one?

No

5 hours ago, tomf14 said:

Another point to note is the behavior of the Lvar, its value (parameter) changes accordingly but goes to zero immediately after

Well, that's something internal to the coding for your add-on HSI.

Let me see the proper annotated assignments please.

Pete

 

Link to comment
Share on other sites

Dear Pete, as requested these are the actual lines from my INI file, i also include the macros section for reference, if anything else let me know. 

43=P2,0,Cx310066C0,x00050001
44=B66C0=0 P2,0,CM5:1,10
45=B66C0=1 P2,0,CM6:1,20
46=B66C0=2 P2,0,CM7:1,40
47=B66C0=3 P2,0,CM8:1,80
48=B66C0=4 P2,0,CM9:1,160
49=B66C0=5 P2,0,CM10:1,320
50=P2,1,Cx410066C0,x00050001
51=B66C0=0 P2,1,CM5:1,10
52=B66C0=1 P2,1,CM5:1,10
53=B66C0=2 P2,1,CM6:1,20
54=B66C0=3 P2,1,CM7:1,40
55=B66C0=4 P2,1,CM8:1,80
56=B66C0=5 P2,1,CM9:1,160

[MacroFiles]
1=isg_nd_mode
2=isg_nd_tcas
3=isg_nd_vnav
4=isg_nd_nav
5=isg_nd_rng010
6=isg_nd_rng020
7=isg_nd_rng040
8=isg_nd_rng080
9=isg_nd_rng160
10=isg_nd_rng320

Link to comment
Share on other sites

Not knowing what is in each MCRO file, I would change all the conditional P2,0 and P2,1 statements
 to U2,0 and U2,1 so that the INC/DEC takes place on the Press and the action takes place on the Release. This should avoid any 'race condition' that might be caused by having the same button/switch performing two actions on each Press. That would also change the UP entry conditionals to 1,2,3,4 & 5 and the DOWN to 0,1,2,3,4 as you only get to 320 going up and 10 going down

Additionally you might want to use the unsigned byte specifications for the INC/DEC lines, 1100 and 2100 vs 3100, 4100.

Just curious, what is in each 'range' MCRO file?  I should think a single MCRO file with multiple lines (entries) would work. Then instead of the multiple 1-line MCRO's.  CM5:1, 10  CM6:1,20 etc you would have CM5:1, 10  CM5:2, 20 CM5:3,40 etc

I use the same conditional assignment technique extensively in my INI file to have multiple assignments for each of my switches on my Saitek Pro throttle quadrants. 66C0 holds my 'mode' number. Some of my aircraft have 9 or 10 'modes so I can control 90 to 100 functions with just 10 switches plus the 2 to INC/DEC 66C0.

I have one MCRO file for each of my aircraft that define all the L:Vars for the aircraft and thus the controls available for assignment. Some MCROs have over 100 entries and are 'aircraft specific.

Here is my MCRO list:[MacroFiles]
1=APchart
2=747 OHD
3=A2A_J3
4=A2A_B377
5=A2A_P47
6=A2A_B17G
7=L1049H
8=A2A_Spit
9=A2A_P40
10=A2A_P51D
11=AF_F4U
12=91stBG_Guns
13=A2A_P51D_Civ
14=B25J
15=Avro_Lanc
16=A2A_C172
17=Avro_Anson
18=A2A_P180
19=A3_B29
20=A2A_C182
21=AF_P51H
22=A2A_PA-24
23=A2A_T6
24=PBY
25=A2A_L049

It seems to me that your list could be reduced to a single file with multiple lines.

  Paul

Link to comment
Share on other sites

Paul, thank you for your excellent advice, it worked! Here is the code for the range switch,

43=P2,0,Cx110066C0,x00050001
44=B66C0=1 U2,0,CM6:1,20
45=B66C0=2 U2,0,CM7:1,40
46=B66C0=3 U2,0,CM8:1,80
47=B66C0=4 U2,0,CM9:1,160
48=B66C0=5 U2,0,CM10:1,320
49=P2,1,Cx210066C0,x00040001
50=B66C0=0 U2,1,CM5:1,10
51=B66C0=1 U2,1,CM6:1,20
52=B66C0=2 U2,1,CM7:1,40
53=B66C0=3 U2,1,CM8:1,80
54=B66C0=4 U2,1,CM9:1,160

Regarding the macro files, each one contains the following Lvar definition

[Macros]
1=L:isg_nd_range_clicked=Set

I created a mcro file for each range step and assigned the parameter through the FSUIPC menu. I see how it is more practical to define each range in a single macro file and will do that soon. I hope this helps others and thank you again for your support.

Regards,

Alan

 

 

 

Link to comment
Share on other sites

Glad you have it running Alan. Just another observation.

Regarding multiple macros, since the content of each is identical you really only need one with the line 1 =  to thew L:Var that you listed above. It is the parameter that is defined in each 'step' that does the work. That is, the parameter is passed to L:isg_nd_range_clicked regardless of the content of 66C0 and the desired range setting..

So. all your 'CM' entries can simply be CM:5,1 No need for the additional identical MCRO's. That makes the code easier to understand.

 Paul

Link to comment
Share on other sites

  • 2 years later...

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
×
×
  • 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.