• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA Rotating knob

Messages
240
Country
germany
Hi all! :)

Just a quick question that I couldn't come up with a soluton yet:

I have a simple rotating knob...L:Var....it rotates from 0 - 6.

When it is at 6 and you click on it another time, I want it to turn FURTHER IN THE ORIGINAL DIRECTION back to 0. (to start over again)

At the moment it rotates ALL THE WAY BACK through 5, 4, 3, 2, 1 back to 0.

Which code do I have to use??


Here is my one:

Code:
<Gauge Name="Air conditioning temp select" Version="1.0">
   <Element>
      <Position X="27" Y="27"/>
      <Image Name="Startselect_Off.bmp" PointsTo="West" Bright="yes">
         <Axis X="27" Y="29"/>
      </Image>
      <Rotate>
         <Value Minimum="0" Maximum="6">(L:AirConSel,enum)</Value>
         <Nonlinearity>
            <Item Value="0" Degrees="180"/>
            <Item Value="1" Degrees="225"/>
            <Item Value="2" Degrees="304"/>
            <Item Value="3" Degrees="339"/>
            <Item Value="4" Degrees="30"/>
            <Item Value="5" Degrees="60"/>
            <Item Value="6" Degrees="135"/>
            <Item Value="0" Degrees="540"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="160"/>
      </Rotate>
   </Element>
 
   <Mouse>
      <Cursor Type="Hand"/>
      <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or if{ (L:AirConSel,enum) ++ s0 6 &gt; if{ 0 } els{ l0 } (>L:AirConSel, enum) }
        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or if{ (L:AirConSel,enum) -- s1 0 &lt; if{ 6 } els{ l1 } (>L:AirConSel, enum) }
      </Click>
   </Mouse>
</Gauge>

Many thanks in advance,

Steven
 
Messages
1,748
Country
unitedstates
http://www.fsdeveloper.com/wiki/index.php?title=XML:_Increment_Variable_w/Modulo_Reset

Modulo_Reset will give you a continues button!

Code:
<Mouse>
<Cursor Type="Hand"/>
<Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
(M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or if{ (L:AirConSel,enum) ++ 6 % (>L:AirConSel, enum) }
</Click>
</Mouse>

Remove this line ....It does not even read this line anyways!
<Item Value="0" Degrees="540"/>
 
Messages
240
Country
germany
Thank you very much for your help gentlemen!

Well, apparently I wasn't very clear in my statement.. The logic indeed wasn't the problem - the L:Var correctly increased 0-1-2-3-4-5-6-0-1-2-3..... (and corecctly decreased as well)
Stunning how many ways there are in xml to achieve the same thing :D

My real problem was the animation of the knob: in this part of the sequence -> 0-1-2-3-4-5-6-0-1-2... the visual knob slowly turned back counterclockwise instead of making this very small step in clockwise direction. Hope this is understandable.

However, I solved the problem by simply deleting the
<Delay DegreesPerSecond="160"/> part.
So now the knob may be still turning all the way back to 0, but at least you can#t see it anymore :p


Thanks,

Steven
 
Messages
191
Country
ireland
I know that this code is a lot simpler and more basic than yours, but I use this formula for all my rotating knobs in FS2004. (Yours looks a lot neater!)

Mine works fine however.

There are 8 positions for the knob.

This displays the knob...

Code:
    <!-- Autopilot Course Knob -->

    <Element>
    <Position X="53" Y="102"/>
        <Image Name="MCPCOURSESELECTOR.bmp" Luminous="No" PointsTo="North">
            <Axis X="19" Y="19"/>
        </Image>
        <Rotate>
        <Value>(L:OBIWheelCount,number) </Value>
        <Nonlinearity>
                    <Item Value="0" X="53" Y="83"/>
                    <Item Value="1" X="72" Y="83"/>
                    <Item Value="2" X="72" Y="102"/>
                    <Item Value="3" X="72" Y="121"/>
                    <Item Value="4" X="53" Y="121"/>
                    <Item Value="5" X="34" Y="121"/>
                    <Item Value="6" X="34" Y="102"/>
                    <Item Value="7" X="34" Y="83"/>
            </Nonlinearity>
              </Rotate>
   </Element>

This is the Mouse entry...

Code:
        <!-- Autopilot Course Increase/Decrease -->


    <Area Left="34" Right="53" Top="83" Bottom="121">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes"> 0 (&gt;K:VOR1_OBI_DEC)
                                    (L:OBIWheelCount,number) 0 &gt;
                                    if{ (L:OBIWheelCount,number) -- (&gt;L:OBIWheelCount,number) }
                                       els{ 7 (&gt;L:OBIWheelCount,number) }
                                  1 (&gt;L:DSD_XML_SOUND_04, number)
            </Click>
          </Area>
    <Area Left="54" Right="72" Top="83" Bottom="121">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes"> 0 (&gt;K:VOR1_OBI_INC)                                
                                    (L:OBIWheelCount,number) 7 &lt;
                                    if{ (L:OBIWheelCount,number) ++ (&gt;L:OBIWheelCount,number) }
                                       els{ 0 (&gt;L:OBIWheelCount,number) }
                                  1 (&gt;L:DSD_XML_SOUND_04, number)
            </Click>
          </Area>

Hope it might help you in some way...

Walter
 
Messages
240
Country
germany
Hello, Walter :)

Thanks for your help!

For rotations I always use Degrees instead of the X and Y coordinates as this is a lot more natural for me :] I wonder if this is only FSX specific?


The logic for my knob worked from the beginning, but the visual appearance in the sim was my problem....I solved it by deleting the
<Delay DegreesPerSecond="160"/> tag.

If you wonder what I'm talking about :D you can test my code with and without this Delay tag..you will see what I meant :)

Code:
<Gauge Name="Air conditioning temp select" Version="1.0">
   <Element>
      <Position X="27" Y="27"/>
      <Image Name="Startselect_Off.bmp" PointsTo="West" Bright="yes">
         <Axis X="27" Y="29"/>
      </Image>
      <Rotate>
         <Value Minimum="0" Maximum="6">(L:AirConSel,enum)</Value>
         <Nonlinearity>
            <Item Value="0" Degrees="180"/>
            <Item Value="1" Degrees="225"/>
            <Item Value="2" Degrees="304"/>
            <Item Value="3" Degrees="339"/>
            <Item Value="4" Degrees="30"/>
            <Item Value="5" Degrees="60"/>
            <Item Value="6" Degrees="135"/>
          </Nonlinearity> 
          <Delay DegreesPerSecond="160"/>  //delete this line      
      </Rotate>
   </Element>
   <Mouse>
      <Cursor Type="Hand"/>
      <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or if{ (L:AirConSel,enum) ++ 7 % (>L:AirConSel, enum) }
        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or if{ (L:AirConSel,enum) -- d 0 &lt; 7 * + (>L:AirConSel, enum) }
      </Click>
   </Mouse>
</Gauge>


Tom, thank you for suggesting a simpler code for the click event ;)

Steven
 
Messages
191
Country
ireland
I must thank Steven and the other contributors for this topic.

I spent a very pleasant afternoon amending the code in all of my gauges with rotating knobs to conform with Steven's methodology.

The degrees method for displaying the knob makes life so much easier. :coffee:

Walter
 
Messages
1,748
Country
unitedstates
Yep removing the delay prevents the user from seeing the rewind in the animation and you end up with a knob that looks like it can turn forever.
 
Messages
240
Country
germany
Yep removing the delay prevents the user from seeing the rewind in the animation and you end up with a knob that looks like it can turn forever.

Exactly what I wanted :)



Steven
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
...
The logic for my knob worked from the beginning, but the visual appearance in the sim was my problem....I solved it by deleting the
<Delay DegreesPerSecond="160"/> tag.

That happens because <Delay...> command uses a damping factor, which needs calculating the current position from interpolated values, start point up to the ending point.

Now, when you go from 6 to 0, the system takes the nonlinearity table as a reference, so the only way to damp is by going back from 6-5-4 etc to 0, because 0 and 6 are both lower and upper limits.

You can actually use some tricks to overcome this behavior if you want to do so, for example:

Code:
<Value Minimum="-1" Maximum="7">(L:AirConSel,enum)</Value>
<Nonlinearity>
  <Item Value="-1" Degrees="135"/>
  <Item Value="0" Degrees="180"/>
  <Item Value="1" Degrees="225"/>
  <Item Value="2" Degrees="304"/>
  <Item Value="3" Degrees="339"/>
  <Item Value="4" Degrees="30"/>
  <Item Value="5" Degrees="60"/>
  <Item Value="6" Degrees="135"/>
  <Item Value="7" Degrees="180"/>
</Nonlinearity>
<Delay DegreesPerSecond="160"/>

When checking (L:AirConSel,enum) for current value, you should check for

(L:AirConSel,enum) 6 == (L:AirConSel,enum) -1 == or


Also for

(L:AirConSel,enum) 0 == (L:AirConSel,enum) 7 == or


And the rest as usual.

Now, in the <Area> code:

Code:
<Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
  (L:AirConSel,enum) -1 == if{ 6 (>L:AirConSel,enum) }
  (L:AirConSel,enum) 7 == if{ 0 (>L:AirConSel,enum) }
  (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
  if{ (L:AirConSel,enum) ++ (>L:AirConSel, enum) }
  els{ (L:AirConSel,enum) -- (>L:AirConSel, enum) }
</Click>

Not tested, but should work Ok.

Tom
 
Last edited:
Top