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

XML gauge needle pointing wrong way SOLVED

Messages
35
Country
ca-quebec
SOLVED: http://www.fsdeveloper.com/forum/threads/xml-gauge-needle-pointing-wrong-way.438922/#post-760278


Hi,

Searched the forum but couldn't find something for this (doesn't mean there was none, just that I couldn't see it in front of my face). :)

The flap position needle is defined towards west and the brake pressure needle is defined towards east. But the flap needle points the same way as the brake pressure needle when both are 0.



Both needles behave and turn as they should.



Code:
<Gauge Name="KK_BrakePressure" Version="1.0">
  <Image Name="BrakePressureBackground.bmp"/>

    <!-- ========================= BrakePressure ===================== -->
  <Element>
    <Position X="50" Y="50"/>
    <Image Name="BrakePressureNeedle.bmp" PointsTo="East">
      <Axis X="13" Y="35"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="40">(L:KK_BrakePressure,number)</Value>
      <Delay DegreesPerSecond="18"/>
      <Nonlinearity>
        <Item Value="0" Degrees="90"/>
        <Item Value="10" Degrees="150"/>
        <Item Value="20" Degrees="210"/>
        <Item Value="30" Degrees="270"/>
        <Item Value="40" Degrees="330"/>
      </Nonlinearity>
    </Rotate>
  </Element>
</Gauge>

Code:
<Gauge Name="KK_FlapPosition" Version="1.0">
  <Image Name="FlapPositionBackground.bmp"/>

    <!-- ========================= Flap Position - Left ============== -->
  <Element>
    <Position X="60" Y="60"/>
    <Image Name="FlapLeftNeedle.bmp" PointsTo="East">
      <Axis X="8" Y="55"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="10624">(L:KK_FlapLeft,number)</Value>
      <Nonlinearity>
        <Item Value="0" Degrees="270"/>
        <Item Value="1062" Degrees="315"/>
        <Item Value="2560" Degrees="0"/>
        <Item Value="5120" Degrees="45"/>
        <Item Value="5888" Degrees="90"/>
        <Item Value="8525" Degrees="135"/>
        <Item Value="10624" Degrees="180"/>
      </Nonlinearity>
    </Rotate>
  </Element>

    <!-- ========================= Flap Position - Right ============== -->
  <Element>
    <Position X="60" Y="60"/>
    <Image Name="FlapRightNeedle.bmp" PointsTo="East">
      <Axis X="8" Y="55"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="10624">(L:KK_FlapRight,number)</Value>
      <Nonlinearity>
        <Item Value="0" Degrees="270"/>
        <Item Value="1062" Degrees="315"/>
        <Item Value="2560" Degrees="0"/>
        <Item Value="5120" Degrees="45"/>
        <Item Value="5888" Degrees="90"/>
        <Item Value="8525" Degrees="135"/>
        <Item Value="10624" Degrees="180"/>
      </Nonlinearity>
    </Rotate>
  </Element>
</Gauge>

I don't get it. I've tried DegreesPointTo=270 for west and 90 for east; same results. The flap needle would point backwards from where it should.

All needle BMPs are painted the same way; vertically with tip pointing upwards.

I defined the flap position needle as east for a temporary fix, but there has to be something wrong.

Robert
 
Last edited:
As far as I know, the rotation is applied as an offset to the starting value and not as an absolute. If your bitmap points up, try defininig the starting location as "north" and then apply some offsets from there across the indicator's value range.
 
That's my problem, trial and error makes no sense to me. I'm a programmer by trade and used to following syntax, but the definition of PointsTo and Degrees are not clear to me. The FS-X SDK says PointsTo is "the starting position". It doesn't say initial state, which in programming means "where the needle should point until it gets data".

The FS-X SDK says PointsTo is:
The starting position, often of a needle.
One of:
NORTH
EAST
SOUTH
WEST

It says this of linearity table, it doesn't say if it's in relation to PointsTo or starting at PointsTo:
Non-linearity values should be listed as they appear on the gauge, clockwise around the face, or left to right. If gauge values increase when rotating clockwise (or moving left to right), values in the non-linearity table should start at the minimum and increase.

- if PointsTo is the start of the linearity table, West and 0 degrees would work, it doesn't.

- if PointsTo is a reference that the linearity table should use in a relative position, North and -90 degrees and West and 0 degrees should both work, they don't (same with North 270, but the actual rotation is fine in all 3 cases).


Either way, PointsTo East and 0 = 90 degrees should never even come close to starting as West with a value of 0, and yet it does.

The Flap Position XML was written first. I put it aside in frustration and used it as base for a Brake Position XML. Brake Position works just fine and Flap Position does not.

The only thing I can think of is that I'm hitting some sort of twilight zone because I'm starting in the "negatives" at 90 degrees from North.

Unless you're saying that XML is a hit and miss affair in FS-X?

Robert
 
Um, you stated that the flaps needle points west, but your XML script states east!
Code:
    <Image Name="FlapLeftNeedle.bmp" PointsTo="East">
 
Um, you stated that the flaps needle points west, but your XML script states east!
Code:
    <Image Name="FlapLeftNeedle.bmp" PointsTo="East">

Yup, as I said in post 1:

The flap position needle is defined towards west and the brake pressure needle is defined towards east. But the flap needle points the same way as the brake pressure needle when both are 0.
.
.
.
I defined the flap position needle as east for a temporary fix, but there has to be something wrong.

The Flap Position needle is behaving backwards compared to Brake Pressure Needle. If I want to point the Flap needle West I have to point it East.

I'm going to try a simple test of North 0 degrees and see what happens.

Robert
 
We don't understand. In your first post you say the flap needle is defined towards west, and in the last post you say it's defined as pointing east. What I see is that you defined it as pointing east and at the 0 position it is pointing east (90 degrees). Makes sense to me.
 
Try with X,Y coordinates of the gauge face for the needle values. In this example even though it says <Image Name="NEEDLE_1.bmp" Luminous="1" PointsTo="North" ImageSizes="11,35"> The needle actually point to South West in a cold and dark cockpit. See <Item Value="-1" X="15" Y="58"/> Whereas <Item Value="0" X="40" Y="8"/> is North ie. 12 o'clock.
Code:
Gauge Name="Flap Indicator" Version="1.0">
   <Image Name="FLAP.bmp" Luminous="1" ImageSizes="80,80"/>
   <Element>
      <Position X="39.5" Y="39.5"/>
      <Image Name="NEEDLE_1.bmp" Luminous="1" PointsTo="North" ImageSizes="11,35">
         <Axis X="5" Y="29"/>
      </Image>
      <Rotate>
         <Value Minimum="-1" Maximum="100">(A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent)</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="-1"/>
         </Failures>
         <Nonlinearity>
            <Item Value="-1" X="15" Y="58"/>
            <Item Value="0" X="40" Y="8"/>
            <Item Value="32.22" X="71" Y="30"/>
            <Item Value="44.44" X="70" Y="37"/>
            <Item Value="77.78" X="63" Y="58"/>
            <Item Value="100" X="40" Y="70"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="60"/>
      </Rotate>
   </Element>
 
We don't understand. In your first post you say the flap needle is defined towards west, and in the last post you say it's defined as pointing east. What I see is that you defined it as pointing east and at the 0 position it is pointing east (90 degrees). Makes sense to me.

Ok, I may have explained myself badly. So I simplified the XML to a single needle with only 3 positions;

- Left Flap = 0
- PointsTo="North"
- <Item Value="0" Degrees="0"/>

This is what I was trying to explain, the needle behaves at a 90 degree offset from where it should.



Code:
<Gauge Name="KK_FlapPosition" Version="1.0">
  <Image Name="FlapPositionBackground.bmp"/>

    <!-- ========================= Flap Position - Left ============== -->
  <Element>
    <Position X="60" Y="60"/>
    <Image Name="FlapLeftNeedle.bmp" PointsTo="North">
      <Axis X="8" Y="55"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="10624">(L:KK_FlapLeft,number)</Value>
      <Nonlinearity>
        <Item Value="0" Degrees="0"/>
        <Item Value="1062" Degrees="45"/>
        <Item Value="2560" Degrees="90"/>
      </Nonlinearity>
    </Rotate>
  </Element>
</Gauge>

The needle should have been pointing North.

Robert
 
You are defining the needle direction through the use of an L:Var.

Nothing in the code you have shown indicates where that L:Var gets it's value.

Could the problem be somewhere upstream?

cheers,
Lane
 
We don't understand. In your first post you say the flap needle is defined towards west, and in the last post you say it's defined as pointing east. What I see is that you defined it as pointing east and at the 0 position it is pointing east (90 degrees). Makes sense to me.

I think you're looking at the Brake Pressure XML. I put it up to show that one was behaving normally.
 
You are defining the needle direction through the use of an L:Var.

Nothing in the code you have shown indicates where that L:Var gets it's value.

Could the problem be somewhere upstream?

cheers,
Lane

It comes from a LUA script in FSUIPC.

Code:
--  Flap Position
--   fsuipc    = 0x30F0        2 bytes (16 bits), type UW, in degrees * 256, LEFT
--   fsuipc    = 0x30F4        2 bytes (16 bits), type UW, in degrees * 256, RIGHT
--   Flap Positions        UP, 1°,  5°,  15°, 20°, 25°, 30°
--   Flap values        0,  1062,2560,5120,5888,8525,10624

while 1 do

  if ipc.readUW(0x30F0) == nil then            -- Left flap position
    FlapLeft_in = 0
  else
    FlapLeft_in = ipc.readUW(0x30F0)
  end
  ipc.writeLvar("L:KK_FlapLeft", FlapLeft_in)

  if ipc.readUW(0x30F4) == nil then            -- Right flap position
    FlapRight_in = 0
  else
    FlapRight_in = ipc.readUW(0x30F4)
  end
  ipc.writeLvar("L:KK_FlapRight", FlapRight_in)

  ipc.sleep(100)
end

The data is fine. That's why I displayed it on-screen (done within the LUA script).

I pretty much gave up on getting the Flaps gauge to work as it should. I just pointed it West with these entries:

Code:
        <Item Value="0" Degrees="90"/>
        <Item Value="1062" Degrees="135"/>
        <Item Value="2560" Degrees="180"/>
        <Item Value="5120" Degrees="225"/>
        <Item Value="5888" Degrees="270"/>
        <Item Value="8525" Degrees="315"/>
        <Item Value="10624" Degrees="360"/>

And that did the job, starts West with value 0 pointing at 270 degrees. It shouldn't, but it works. The needle rotates in the proper direction, stopping at the proper angles.

Thanks guys.
 
Tip by Doug Dawson: Non-linearity tables, as read from top to bottom, must always describe clockwise motion, even if the natural motion of the needle is counter-clockwise.
 
Here is a brake pressure gauge with two needles the left one counter clockwise and the right clockwise. Look at this and the previous example I put up. I would suggest that you adapt your code using my examples. They both work. And then you should be able see where you are going wrong.
Code:
<Gauge Name="brake_pressure" Version="1.0">
  <Image Name="hydraulic_pressure_background.bmp"  Luminous="1"/>
 
  <!-- ========================= Brake Pressure Gauge ========== -->
  <Element>
    <Position X="35" Y="155"/>
    <Image Name="hydr_press_left_needle.bmp" PointsTo="East" UseTransparency="Yes"  Luminous="1">
      <Axis X="-64" Y="6"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="100">(A:Brake Left Position, percent)</Value>
      <Nonlinearity>
         <Item Value="100" X="121" Y="69"/>
         <Item Value="50" X="156" Y="156"/>
         <Item Value="0" X="121" Y="243"/>
      </Nonlinearity>
<Delay DegreesPerSecond="60"/>
    </Rotate>
  </Element>
 
    <Element>
      <Position X="275" Y="155"/>
      <Image Name="hydr_press_right_needle.bmp" PointsTo="West" UseTransparency="Yes"  Luminous="1">
        <Axis X="120" Y="6"/>
      </Image>
      <Rotate>
        <Value Minimum="0" Maximum="100">(A:Brake Right Position, percent)</Value>
        <Nonlinearity>
           <Item Value="0" X="188" Y="243"/>
           <Item Value="50" X="156" Y="156"/>
           <Item Value="100" X="188" Y="69"/>
        </Nonlinearity>
<Delay DegreesPerSecond="60"/>
      </Rotate>
    </Element>
 
  <Mouse>
    <Tooltip>Brake hydraulic pressure</Tooltip>
  </Mouse>
</Gauge>
 
Try with X,Y coordinates of the gauge face for the needle values...


That was how I first started and had a 90 degree offset. So I switched to Degrees, thinking it would be easier.

I put the original Level-D gauge back in to show the selector and needle setting. I also added text to show the LVAR in the XML gauge matches with the LVAR in the LUA script; both are 0.

I still get a 90 degree offset using coordinates:



Code:
<Gauge Name="KK_FlapPosition" Version="1.0">
  <Image Name="FlapPositionBackground.bmp"/>

    <!-- ========================= Flap Position - Left ============== -->
  <Element>
    <Position X="60" Y="60"/>
    <Image Name="FlapLeftNeedle.bmp" PointsTo="West">
      <Axis X="8" Y="55"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="10624">(L:KK_FlapLeft,number)</Value>
      <Nonlinearity>
        <Item Value="0" X="2" Y="60"/>
        <Item Value="1062" X="19" Y="19"/>
        <Item Value="2560" X="60" Y="2"/>
        <Item Value="5120" X="101" Y="19"/>
        <Item Value="5888" X="118" Y="60"/>
        <Item Value="8525" X="101" Y="101"/>
        <Item Value="10624" X="60" Y="118"/>
      </Nonlinearity>
    </Rotate>
  </Element>

  <Element>
    <Position X="130" Y="30"/>
    <FormattedText
       X="120"
       Y="20"
       Font="Arial"
       FontSize="16"
       LineSpacing="0"
       Adjust="Left"
       Color="White"
       Bright="Yes">
      <String>Left  = %((L:KK_FlapLeft))%!5d!</String>
    </FormattedText>
  </Element>

    <!-- ========================= Flap Position - Right ============== -->
  <Element>
    <Position X="60" Y="60"/>
    <Image Name="FlapRightNeedle.bmp" PointsTo="West">
      <Axis X="8" Y="55"/>
    </Image>
    <Rotate>
      <Value Minimum="0" Maximum="10624">(L:KK_FlapRight,number)</Value>
      <Nonlinearity>
        <Item Value="0" X="2" Y="60"/>
        <Item Value="1062" X="19" Y="19"/>
        <Item Value="2560" X="60" Y="2"/>
        <Item Value="5120" X="101" Y="19"/>
        <Item Value="5888" X="118" Y="60"/>
        <Item Value="8525" X="101" Y="101"/>
        <Item Value="10624" X="60" Y="118"/>
      </Nonlinearity>
    </Rotate>
  </Element>

  <Element>
    <Position X="130" Y="70"/>
    <FormattedText
       X="120"
       Y="20"
       Font="Arial"
       FontSize="16"
       LineSpacing="0"
       Adjust="Left"
       Color="White"
       Bright="Yes">
      <String>Right = %((L:KK_FlapRight))%!5d!</String>
    </FormattedText>
  </Element>
</Gauge>

Stumped.
 
Get this. I changed to PointsTo = North and kept the coordinates as in the previous post and it works!

I can't explain why though.

 
Not sure why that works and others don't, but that is how I configure all my needle gauges - Points to North and use pixel locations for the non-linearity table. I got that from Ken Mitchell, one of the original XML panel guys.
 
Guys,

There is a basic logic on rotating images, typically needles and alike.

The property "PointsTo" relates to the side of the image that is going to be rotated around the image's center of rotation in relationship with the nonlinearity values.

In these two images:

Needle1
Needle1.jpg
Needle2
Needle2.jpg


Needle1 image points naturally to the North, so if "PointsTo=North" is defined, it will rotate as expected, the green side around the center of rotation.
However, if "PointsTo=West" is defined the red side will rotate instead, giving erroneous positions if the same nonlinearity table is used.

Needle2 image points naturally to the East, so "PointsTo=East" will make it rotate as expected. Any other different than East will return different postions.

Note that "Degrees" property relates to the amount of degrees the image's "active" side will rotate from its neutral, loading position. Values can be positive (rotates clockwise) or negative (counterclockwise)

Tom
 
Ooooooh, so PointsTo describes how the needle is drawn in the bitmap. That's why they only have the 4 main cardinal points available.


The starting position, often of a needle...

I thought the SDK meant the direction you "wanted" for the needle to be placed at start-up.


Totally different things.

Robert
 
And that explains why the Brake Pressure needle was working fine. It is drawn tip to the north, but I used PointsTo East.

So value 0 = 90 degrees turns it 1/4 turn, and the tip ends up facing East, pure luck.


Tom, you should write the manual for the next SDK. This one sucks royally. I find it extremely dry, somewhat like an IBM manual from OS/360 days.
 
Back
Top