2D Gauge Help

#1
Good day all,
I wondered if any one would be able to help I have built a 2d panel to replicate the virtual cockpit. (As so many payware aircraft only come with a virtual cockpit really annoys but that a different topic lol).
Progress so far if anyone is interested
Virtual

2D

I would now like to sort out the RPM Gauge as the current one realy doesn't match.
Current

One I would lIke to use

The trouble is the first one has two needles the second one one only. No big deal I though changed the background bmp and original needles look fine. However the trouble I have is the rpm indicated are in different locations on the new bmp so it doesn't read correctly. I have tried fiddling around with code (through panel editor) however I don't really understand it so would anyone be able to provide some advice.
Many thanks
Matt
 
#2
Hi,

You would need to learn some XML to be able to make your changes to the existing gauge (assuming it's an XML gauge. Make a backup of the XML file first, BEFORE editing it.

Open the gauge XML code in an editor. This can be anything from Notepad to a dedicated editor program. I normally use Wordpad.

1. Find the code for the needles. You should find two - one referencing A: variables for engine 1, and the other referencing engine 2. Each will probably be contained within <Element> and </Element> tags. Normally you should be able to delete everything between and including those two tags to delete the engine 2 needle. This code (in this case for engine 1, note the A:General eng rpm:1, RPM variable in the code) usually looks something like this:

Code:
   <Element>
      <Position X="128" Y="128"/>
      <Image Name="ENG_1_ND3.bmp" PointsTo="East" >
         <Axis X="50" Y="10"/>
      </Image>
      <Rotate>
         <Value Minimum="0" Maximum="3500">(A:General eng rpm:1, RPM)</Value>
         <Failures>
            <SYSTEM_ENGINE Action="0"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="62" Y="206"/>
            <Item Value="1000" X="26" Y="106"/>
            <Item Value="1500" X="51" Y="57"/>
            <Item Value="2000" X="99" Y="27"/>
            <Item Value="2500" X="156" Y="24"/>
            <Item Value="3000" X="204" Y="55"/>
            <Item Value="3500" X="230" Y="105"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="180"/>
      </Rotate>
   </Element>
2. Now look at the code referencing the engine 1 needle. Hopefully you will see a NonLinearity section. It might look something like this:

Code:
         <Nonlinearity>
            <Item Value="0" X="62" Y="206"/>
            <Item Value="1000" X="26" Y="106"/>
            <Item Value="1500" X="51" Y="57"/>
            <Item Value="2000" X="99" Y="27"/>
            <Item Value="2500" X="156" Y="24"/>
            <Item Value="3000" X="204" Y="55"/>
            <Item Value="3500" X="230" Y="105"/>
         </Nonlinearity>
Now your new gauge only goes up to 3000 RPM, so you can delete the line that has "3500" in it, if you like.
Open the gauge background bitmap in any editor (Photoshop, PSP, Paint, GIMP, etc.) and put the mouse over the number 0. On the image you posted, I get a pixel location of 115, 240. So the first line in this section needs to be changed to:

<Item Value="0" X="115" Y="240"/>

Then do the same with all the other numbers, editing the lines above to the pixel location of that number.

3. Note that in the code above the NonLinearity section there is a max value of 3500 (Maximum="3500"). If present, this could be changed to 3000.

After those changes you should have your new gauge up and working (hopefully).

Hope this helps,
 
#7
To Mashby: I could not agree more, I really dislike VC, which is why I don't buy Carenado anymore. Also because I have either purchased or made hardware so I can focus on the instruments so I find VC awkward and more unrealistic to use. Now to the subject of 2D gauge help: I'm confused of the function of the <Value Minimum=" " Maximum="> Here is the code:

Code:
attempt 1:

       <Element> <Select>
            <Value Minimum="-25" Maximum="25">(L:SS180, number) (&gt;L:SS_COUNT, number)</Value>
         </Select>
       </Element>   

attempt 2:

      <Element> <Select>
            <Value Minimum="-25" Maximum="25">(L:SS180, number) (&gt;L:SS_COUNT, number) -25 max 25 min</Value>
         </Select>
      </Element>   

attempt 3:
 
       <Element> <Select>
            <Value>(L:SS180, number) (&gt;L:SS_COUNT, number)</Value>
         </Select>
       </Element>     

       <Element> <Select>
            <Value Minimum="-25" Maximum="25">(L:SS_COUNT, number) </Value>
         </Select>
      </Element>

attempt 4:

       <Element> <Select>
            <Value>(L:SS180, number) (&gt;L:SS_COUNT, number)</Value>
         </Select>
       </Element>     

       <Element> <Select>
            <Value Minimum="-25" Maximum="25">(L:SS_COUNT, number) -25 max 25 min </Value>
         </Select>
      </Element>

WORKS but confused about above failing:

      <Element> <Select>
            <Value>(L:SS180, number) (&gt;L:SS_COUNT, number)</Value>
         </Select>
      </Element>   

      <Element> <Select>
            <Value>
     (L:SS_COUNT, number) 25 &gt; if{ 25 (&gt;L:SS_COUNT, number) }
     (L:SS_COUNT, number) -25 &lt; if{ 25 /-/ (&gt;L:SS_COUNT, number) } </Value>
         </Select>
      </Element>

displaying to verify numbers:

<Element>
    <Position X="410" Y="25"/>
      <Text X="150" Y="19" Length="30" Font="quartz" FontSize="13" Fix="Yes" Color="white">
          <String>%SSCount: %((L:SS_COUNT, number))%!3d!</String>
      </Text>
</Element>
As can be seen, I started with the simplest and went from there but to no avail. I had to write two <Element> parts to make it work. So why doesn't the <Value Minimum Maximum> work as expected and as shown in several publications?

Also, I noticed that there several gauges and some panels (i.e.: FS9 default C172's panel_background_1024.bmp) that are 256 color format. 1) Some have color and some are quite detailed. Using MSPaint, I try to change the color of an item and all I get are shades of grey. So I saved the bmp as a 24-bit, changed color but when I go back to save as 256 color, detail gets lost. What graphic program should I use to modify color in 256 color bmp's?
 

Heretic

Resource contributor
#8
Attempt 2 was close to what works for me.

Code:
<Element><Select><Value>
(L:SS180, number) -25 max 25 min (&gt;L:SS_COUNT, number)
</Value></Select></Element>
The variable's value is read and checked for maximum and minimum limits before being written to the new variable.


As for the graphics edior, try GIMP or Paint.net. These are the most popular free ones.

https://www.gimp.org/
https://www.getpaint.net/[/code]
 
#9
hello. Thank you for the min max info. it does work, a bit confused why the others don't work but I can go on. As far as gimp and Paint.Net, I have those, and inkscape, and Paint Shop Pro (v 4.10 when it was shareware), but I couldn't get neither to work. The graphics aren't too important but it would be nice to modify 256 color by adding color. I'll keep playing a bit on those.
 
#10
The other are used by output ops

Code:
  <Element>
    <Position X="134" Y="776"/>
    <Image Name="PRS_Cabin_VS_Needle.bmp" PointsTo="West" Luminous="yes">
    <Axis X="10" Y="5" />
    </Image>
    <Rotate>
      <Value Minimum="-2000" Maximum="2000">
        (L:PRS_Cabin_at_ALT_CHK,feet/minute) 0 &gt;
        if{
          (L:PRS_Cabin_at_ALT_CHK,feet/minute)
          }
       els{
          (L:PRS_Cabin_VertSpd,feet/minute)
          }
      (L:ElecM_DC28_Battery_XFR_Bus_V,Volt) 20 &gt;= *
      </Value>
      <Nonlinearity>
        <Item Value="-2000" Degrees="-175"/>
        <Item Value="-1500" Degrees="-134"/>
        <Item Value="-1000" Degrees="-89"/>
        <Item Value="-800" Degrees="-71"/>
        <Item Value="-500" Degrees="-45"/>
        <Item Value="-200" Degrees="-18"/>
        <Item Value="-100" Degrees="-9"/>
        <Item Value="0" Degrees="0"/>
        <Item Value="500" Degrees="45"/>
        <Item Value="1000" Degrees="90"/>
        <Item Value="1500" Degrees="133"/>
        <Item Value="2000" Degrees="171"/>
      </Nonlinearity>
      <Delay DegreesPerSecond="120"/>
    </Rotate>
  </Element>
 

DragonflightDesign

Resource contributor
#11
When doing the graphics, always do them in 24-bit first and then reduce to 8-bit. The fewer colours you use, the better the end result. Also, to reduce on-screen banding, the last thing to do before reducing the colour depth is to spatter a 1% Noise filter with a Gaussian scatter. Dunno why it works, but it does.

I think I need to write that tutorial on understanding how FSX/P3D treat colours in gauges... been thinking about it for a while :scratchch
 
#12
So many are doing 3d gauges now and no 2D panels...

You might be able to get around this by finding existing gauges all over the internet at freeware websites. FS2004 gauges should work fine in FSX. You can download them and experiment, trading them out in the panel config file (location and coordinates).

This might make it easier on your work load. So many gauges have already been done.

Simviation.com FlightSim.com and other websites that still have freeware planes and various addons. Some have panel downloads with custom gauges.
 
#14
Hello.
To Eduhir: Thanks for the info. But I must admit, I don't understand the explanation: "The other are used by output ops." And again, I don't know why the original Min Max didn't work.
<Value Minimum="-25" Maximum="25">(L:SS180, number) (&gt;L:SS_COUNT, number)</Value>
Heretic's logic worked great so I used it.

To DragonFlightDesign: Thanks for the info. I may have not made my question clear. I am trying to modify existing 256-color BMP's. When I use MSPaint, to modify color, all I get using MSPaint are shades of grey. As I mentioned before, I would convert the 256-color to 24-bit, make my color changes, then saved as 256-color but then the original resolution gets reduced. I tried the above mentioned graphics program but must admit, I didn't see a way to do it either. Perhaps the question is: How did the original BMP's with color and higher resolution get made in 256-color format in the first place?
Here's the reason this became an issue with me: I do use a checklist but still I wanted a visual alert when I have the GPS selected instead of NAV (A: GPS Drives Nav1). So I wanted to modify the GPS part of the FS9's default C172's panel_background_1024.bmp (a 256-color formatted BMP), an orange color and keep its original resolution. A write-up might be a good and welcomed idea.
 
#18
When doing the graphics, always do them in 24-bit first and then reduce to 8-bit. The fewer colours you use, the better the end result. Also, to reduce on-screen banding, the last thing to do before reducing the colour depth is to spatter a 1% Noise filter with a Gaussian scatter. Dunno why it works, but it does.

I think I need to write that tutorial on understanding how FSX/P3D treat colours in gauges... been thinking about it for a while :scratchch
Sorry if I'm going totally off topic, would be interesting to open a dedicated thread on the subject, anyway, from my limited experience, XML gauges only like 8-bit bitmaps (256 colours LUT based...that's why banding is an issue as your gauge has to share the same LUT with all the others so you can't "monopolize" a lot of the LUT entries just for your single gauge), while with C/C++ gauges it is ALSO possible to "link" (as resource) 24bit ("true color") bitmaps. Not sure they will remain 24 bit all the way down to the graphics adapter, but surely banding gets severely limited. In any case I'd be VERY interested in your tutorial as I'm sure I'm missing a lot of interesting details like the banding limiting filter you described!
Thank you!
Marco
 
#20
I've noted that, Ed. I nearly always use 'local palette' (as it is in CC) but it's one of those things that I've been doing for so long that I've lost the reason why I started it. Very occasionally I find that 'local perceptual' produces a better result but I've no idea why. I'm no CC Guru.

Marco: there's a comment in JB3DG's D2D template code that notes how a 24-bit resource hits the screen. IIRC (IIRC! - because I don't have the code in front of me), a 24-bit resource with alpha channel arrives at the screen as a 16-bit bitmap. No alpha channel = 8-bit bitmap. If you want chapter and verse, download the D2D template and read Jon's very detailed comments.
 
Top