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

circle gauge problem - needle revolves back

mkr

Messages
11
i think i need some assistance again :)

i made a gauge that contains 2 needles for rpm measurement. a big needle that shows rpms from 0-100% (distributed over a 3/4 circle, no full circle, works fine)

and 1 small needle that shows fractions of the main needle (big needle rotating from 10 to 20% means the small needle makes 1 full round from 0 to 10=0 / big needle on 15 would mean small needle on 5 (at 6 o'clock position) ) and so on.

my problem is that the small needle revolves all the way back (counterclockwise) from 9.9 to 0 instead of keeping the clockwise movement it had all the way before from 0..9

is there any way to tell fsx that a needle should cover a full-circle instead of just, lets say an arc ?


i matched beginning and end in my nonlinearity function to the pixel but this has no effect:

Code:
NONLINEARITY  grpm_ndl2_nonlinearity[] =
{
	{{122+GRPM_OFFSET_X_BG,  96+GRPM_OFFSET_Y_BG},  00, 0},
	{{135+GRPM_OFFSET_X_BG, 104+GRPM_OFFSET_Y_BG},  10, 0},
	{{144+GRPM_OFFSET_X_BG, 115+GRPM_OFFSET_Y_BG},  20, 0},
	{{145+GRPM_OFFSET_X_BG, 129+GRPM_OFFSET_Y_BG},  30, 0},
	{{138+GRPM_OFFSET_X_BG, 142+GRPM_OFFSET_Y_BG},  40, 0},
	{{122+GRPM_OFFSET_X_BG, 145+GRPM_OFFSET_Y_BG},  50, 0},
	{{108+GRPM_OFFSET_X_BG, 141+GRPM_OFFSET_Y_BG},  60, 0},
	{{ 98+GRPM_OFFSET_X_BG, 129+GRPM_OFFSET_Y_BG},  70, 0},
	{{ 98+GRPM_OFFSET_X_BG, 114+GRPM_OFFSET_Y_BG},  80, 0},
	{{109+GRPM_OFFSET_X_BG, 104+GRPM_OFFSET_Y_BG},  90, 0},
	{{122+GRPM_OFFSET_X_BG,  96+GRPM_OFFSET_Y_BG}, 100, 0}
};

(100 means 10 in the above code, its just x10 for a finer resolution)


it keeps behaving this way:
0>1 clockwise
1>2 clockwise
...
9>0 all the way back counterclockwise



any ideas ?
 
Last edited:
The needle should move backwards when the current value is less than the previous value.
The trick here is to not reset the return value to a number less than 1 until after your callback has returned a value in excess of 10 at lease once.
In your callback function, you could try something like this:
Code:
static double PreviousValue;
double CurrentValue;

CurrentValue = fmod(EngineRPM.var.var_value.n,10.);
if ( PreviousValue > 9. && PreviousValue < 10. && CurrentValue < 1.)
{
CurrentValue += 10.;
}
PreviousValue = CurrentValue;
return CurrentValue;

Doug
 
does not work for me, it spins to the virtual 11 = 1 and then turns back counterclockwise.

i think i will expand my nonlinearity function to cover all values from 0-100 and pass the full value in my callback function so that instead of flipping the value from 9 to 0 (or from 10 to 1) i will keep adding to it
 
I think MAKE_NEEDLE (with NONLINEARITY table) is not the proper macro for those "carousell-kind" needles. I'd better choose MAKE_SPRITE, like it is used in HSI or Attitude cards.

Tom
 
The code below is from one of my n1 gauges in fs9. Both needles are on the same face "N1_back.bmp". don't be put off by the if{ 24 } that just limits A:Turb eng3 N1, percent to 24% during reverse thrust.
vololiberista



Code:
<Gauge Name="Engine 3 N1" Version="1.0">
   <Image Name="N1_back.bmp" Luminous="1"/>
//-------------------------------------
   <Element>
      <Position X="186" Y="164"/>
      <Image Name="Needle_N1_small.bmp" Luminous="1" PointsTo="North">
         <Axis X="13" Y="70"/>
      </Image>
      <Rotate>
        <Value>(A:Turb eng3 N1, percent) s0 (A:General eng3 throttle lever position, part) 0 &lt; (A:Turb eng3 N1, percent) 1 &gt; and if{ 24 } els{ l0 }</Value>
         <Nonlinearity>
            <Item Value="0" X="185" Y="92"/>
            <Item Value="9.9" X="180" Y="92"/>
         </Nonlinearity>
<Delay DegreesPerSecond="400"/>
         <Failures>
            <SYSTEM_ELECTRICAL Action="Freeze"/>
		<SYSTEM_ENGINE Action="0"/>
         </Failures>
         <Delay DegreesPerSecond="700"/>
      </Rotate>
   </Element>

<Element>
      <Position X="282" Y="270"/>
      <Image Name="Needle_N1_big.bmp" Luminous="1" PointsTo="North">
         <Axis X="47" Y="225"/>
      </Image>
      <Rotate>
         <Value>(A:Turb eng3 N1, percent) s0 (A:General eng3 throttle lever position, part) 0 &lt; (A:Turb eng3 N1, percent) 1 &gt; and if{ 24 } els{ l0 }</Value>
         <Nonlinearity>
            <Item Value="0" X="280" Y="47"/>
            <Item Value="20" X="460" Y="138"/>
            <Item Value="40" X="490" Y="334"/>
            <Item Value="60" X="343" Y="473"/>
            <Item Value="80" X="153" Y="442"/>
            <Item Value="100" X="62" Y="267"/>
            <Item Value="110" X="105" Y="179"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="70"/>
         <Failures>
            <SYSTEM_ELECTRICAL Action="Freeze"/>
		<SYSTEM_ENGINE Action="0"/>
         </Failures>
      </Rotate>
   </Element>
   
//--------------------------------------
   <Mouse>    
         <Tooltip>Engine 3 N1: %((A:Turb eng3 N1, percent) near)%!d!%%</Tooltip>  
   </Mouse>
</Gauge>
 
@vololiberista:

i think both of your gauges are just normal "arc" projections with no "ever-revolving" (dont know another word now) needles.

(i tried to remove all entries from the nonlinearity list except 0 and 99 anyway in the MAKE_NEEDLE approach but same result)


what i need is a way to get a needle that can keep spinning and spinning clockwise till the end of days and doesnt stop spinning when it reaches 12 o'Clock and returns counter-clockwise to 0 and starts moving clockwise again.


just like on a water counter the small needle that shows your 0.0001m³ values.


@Taguilo: i tried MAKE_SPRITE but this seems more tricky than i thought, until now all i got is a black box outside my gauges rectangle, far from having a rotating needle :)
you dont happen to have a real basic example of a rotating sprite where i can see what the return value of the callback function should be (is it degress 0..360 ? or arc-measures of PI, or values 0..100 for a full rotation ? microsoft's documentation is not really helpful when it comes to that )
 
mkr,

I have a working example of an analog clock that I can post when I get a moment.

Doug

Edit: example attached.
Next edit: example really attached...
 

Attachments

Last edited:
@Taguilo: i tried MAKE_SPRITE but this seems more tricky than i thought, until now all i got is a black box outside my gauges rectangle, far from having a rotating needle :)
you dont happen to have a real basic example of a rotating sprite where i can see what the return value of the callback function should be (is it degress 0..360 ? or arc-measures of PI, or values 0..100 for a full rotation ? microsoft's documentation is not really helpful when it comes to that )

The problem with MAKE_SPRITE is that you need to define a mask bitmap linked to the rotating bmp. I agree it is more tricky and tedious to code.
Anyway, Doug has given you a good example, though for a clock it is only needed a single way rotation -clockwise obviously- but in your needle you need both a clockwise and counterclockwise, depending whether the RPM are increasing or decreasing.
So, the best solution I find is to discard the nonlinearity table, using NULL in place of its name, and in the callback convert your rpm units to degrees.
For example (pseudocode):

Code:
#include <math.h>
FLOAT64 needle_callback( PELEMENT_NEEDLE pelement )
{
     FLOAT64 fUnit = (lookup_var RPM system var) or (your own RPM var);
    /* ensure it is expressed in percent of 100, for example 45.56 */

     FLOAT64 fReturn = fmod(fUnit,10) * 36;    

     return fReturn;
}
And that's it, should work fine.

Tom
 
So, the best solution I find is to discard the nonlinearity table, using NULL in place of its name, and in the callback convert your rpm units to degrees.
For example (pseudocode):

Code:
#include <math.h>
FLOAT64 needle_callback( PELEMENT_NEEDLE pelement )
{
     FLOAT64 fUnit = (lookup_var RPM system var) or (your own RPM var);
    /* ensure it is expressed in percent of 100, for example 45.56 */

     FLOAT64 fReturn = fmod(fUnit,10) * 36;    

     return fReturn;
}
And that's it, should work fine.

Tom


so i could still use a MAKE_NEEDLE with above callback ? or is this for a MAKE_SPRITE approach ?
 
Yes, of course, its for a MAKE_NEEDLE macro.

For example:

Code:
MAKE_NEEDLE
(
      rpm_needle,
      BMP_YOUR_RPM_NEEDLE,
      NULL,
      rpm_fail,
      IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE,
      0,
      backX, backY,
      needleX, needleY,
      MODULE_VAR_NONE,needle_callback,
      NULL,
      lag
)
Notice NULL is passed instead of a nonlinearity table's name.

Also, if you don't get a good refresh with the macro callback, you could better use the gauge's callback function and do all your actualizations there.

Tom
 
works fine now, i used the make_needle without nonlinearity function.

thanks a lot tom + doug
 
Back
Top