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

Blinking Bitmaps

Messages
131
Country
unitedstates
I am making an Altitude Alerter, that alerts when you are withing 200 feet of your selected altitude, and once you have reached the selected altitude, it will alert when you deviate more than 200 feet.

This is a visual alerter, and the deviation alert blinks, as opposed to the "Level Off within 200 feet" witch is constant.

I have everything working, for test purposes I used a different color bitmap for the 2 alerts. Now that it is working, I want to make the deviation bitmap blink, but I cannot get it to work.

I have tried to use a variable that increment, once it is at a certain number it toggles a second variable that the Visible field on the bitmap reads, then resets the first variable. I think this approach should work, but I cannot get the code to keep incrementing.

Here is both notations, in case my RPN is messy.


Code:
if ( @SAD > 200 )
{
	(L:Blinker, number) + 1 ;
	if ( (L:Blinker, number) == 60 )
	{
		(L:Dev Alert Vis, bool) = ( ! (L:Dev Alert Vis, bool) ) ;
		(L:Blinker, number) = 0 ;
	}
} else
	(L:Dev Alert Vis, bool) = 0 ;
}

Code:
@SAD 200 > if{ (L:Blinker , number) 1 (L:Blinker , number) 60 == if{ (L:Dev Alert Vis , bool) ! + (>L:Dev Alert Vis , bool) 0 (>L:Blinker , number) } } els{ 0 (>L:Dev Alert Vis , bool) }

@SAD is a macro to for the difference indicated altitude, and selected altitude.

I put this code the script of an Update Object, tried freq 0 and 60, but L:Blinker increments to 1 after deviating more than 200 feet then stops.
 
Should your RPN's first if clause be incrementing it? If so there's no greater than in the code to indicate addition ordictate the output is to be set, i.e.

(L:Blinker , number) 1 + (>L:Blinker , number)

(Or rather it should be > not >)

Si
 
OK, I struggled with this all weekend, and while I am sure my previous method would work if I "got the bugs out", I came up with an easier method.

Code:
<SimGauge.Element id="Altitude Deviate">
    <FloatPosition>334.000,94.000</FloatPosition>
    <Visibility>(L:Leveled Off , bool) if{ @SAD 200 &gt; if{ 1 } } els{ 0 } </Visibility>
    <Select id="Select">
        <Expression id="Expression">
            <Script>(E:Absolute Time, seconds) 10 %</Script>
        </Expression>
        <Case id="Case">
            <ExpressionResult>1.000</ExpressionResult>
            <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
                <Transparent>True</Transparent>
            </Image>
        </Case>
        <Case id="Case">
            <ExpressionResult>3.000</ExpressionResult>
            <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
                <Transparent>True</Transparent>
            </Image>
        </Case>
        <Case id="Case">
            <ExpressionResult>5.000</ExpressionResult>
            <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
                <Transparent>True</Transparent>
            </Image>
        </Case>
        <Case id="Case">
            <ExpressionResult>7.000</ExpressionResult>
            <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
                <Transparent>True</Transparent>
            </Image>
        </Case>
        <Case id="Case">
            <ExpressionResult>9.000</ExpressionResult>
            <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
                <Transparent>True</Transparent>
            </Image>
        </Case>
    </Select>
</SimGauge.Element>

The expression gives you a 1 digit number that counts up by the second, going back to 0 after 9. Then the select case shows the bitmap you want to blink whenever the expression is an odd number. The entire element is then only visible when conditions are met.

The code is sloppy because there is so much repeat, anyone know if you can group multiple expression results together?
 
Here you have a simple example that might be useful for what you're looking for:

Code:
<SimGauge.Element id="Altitude Deviate">
    <FloatPosition>334.000,94.000</FloatPosition>
    <Visibility>(L:Leveled Off,bool) d @SAD 200 > and if{ p (P:Absolute Time,seconds) 1 % 0.5 > }</Visibility>
    <Image id="pfd_alt_alerter.bmp" Name="pfd_alt_alerter.bmp">
        <Transparent>True</Transparent>
    </Image>
</SimGauge.Element>

-The bitmap will be hidden when not leveled off yet -(L:Leveled off,bool) = 0 -
-It will be steady visible when leveled off but within 200 ft.
-It will blink on a half a second rate when outside 200 ft bound.

Tom
 
Hey guys, I was hoping that maybe one of you could help me out on my coding issues. I have been trying to create a gauge that will display a Tacan frequency for its corresponding VOR freq. I have had a tiny bit of luck in the select case string, however, there is a problem with the coding that will round the VOR frequency (116.50 to 117.45 all round to 117.00). I have tried multiple ways to work the select string syntax, however have been unsuccessful. Hopefully someone here will be able to shed a little light on my problem.

Here's the link for my thread:
http://www.fsdeveloper.com/forum/showthread.php?t=12829
 
Hey guys, I was hoping that maybe one of you could help me out on my coding issues. I have been trying to create a gauge that will display a Tacan frequency for its corresponding VOR freq. I have had a tiny bit of luck in the select case string, however, there is a problem with the coding that will round the VOR frequency (116.50 to 117.45 all round to 117.00). I have tried multiple ways to work the select string syntax, however have been unsuccessful. Hopefully someone here will be able to shed a little light on my problem.

Here's the link for my thread:
http://www.fsdeveloper.com/forum/showthread.php?t=12829

You are trying to achieve (int(Freq * 100))/100





Geoff_D
 
Last edited:
Hey guys, I was hoping that maybe one of you could help me out on my coding issues. I have been trying to create a gauge that will display a Tacan frequency for its corresponding VOR freq. I have had a tiny bit of luck in the select case string, however, there is a problem with the coding that will round the VOR frequency (116.50 to 117.45 all round to 117.00). I have tried multiple ways to work the select string syntax, however have been unsuccessful. Hopefully someone here will be able to shed a little light on my problem.

Here's the link for my thread:
http://www.fsdeveloper.com/forum/showthread.php?t=12829

The problem here is (A:NAV ACTIVE FREQUENCY:n,MHz) won't return the real freq ie 116.50 but instead the floating point equivalent ie 116.4999999etc therefore the comparison in <Value> with 116.50 won't be true ever.
A solution would be to force the exact value with something like:

(A:NAV ACTIVE FREQUENCY:n,MHz) 100 * near int 100 /

Tom
 
(A:NAV ACTIVE FREQUENCY:n,MHz) 100 * near int 100 /
Tom

Tried this with and without the 'near', but the numbers are still being rounded up to the nearest integer.

Also, I'm having small technical issues tring to get an Angle of Attack readout to display properly. Right now, I use the code %(((A:INCIDENCE ALPHA, degrees)) 10 + )%!1.1f! to take the incidence and add 10 (which is pretty accurate to the plane), but it only displays '10'.

Matt
 
Another menthod is to decide in what Frequency spacing you want to display to, and then make sure your frequency is a INTEGER Multiple of that frequency.

ie If you want 25Khz spacings ( 0.025 Mhz)

You want to calculate 0.025 * int(Freq / 0.025))

ie 0.025 * int(freq * 40 )

I'll leave it to you to figure out the XML, ( I am usless at reverse polish )

In case case you want to use "int" ( do not use "near" )

Geoff_D
 
Tried this with and without the 'near', but the numbers are still being rounded up to the nearest integer.

Also, I'm having small technical issues tring to get an Angle of Attack readout to display properly. Right now, I use the code %(((A:INCIDENCE ALPHA, degrees)) 10 + )%!1.1f! to take the incidence and add 10 (which is pretty accurate to the plane), but it only displays '10'.

Matt

You can test something like this to see that it works:

If tuned a freq like 116.70

<String>NAV1 Freq %((A:NAV ACTIVE FREQUENCY:1,MHz) 100 * near int 100 /)%!3.2f!</String> will show 116.70

and

<String>NAV1 Freq %((A:NAV ACTIVE FREQUENCY:1,MHz) 100 * near int 100 / 116.70 ==)%!d!</String> will show 1 (TRUE) which means both values are equal.

However, <String>NAV1 Freq %((A:NAV ACTIVE FREQUENCY:1,MHz) 116.70 ==)%!d!</String> will show 0 (FALSE), because of floating point issues.

Now, %(((A:INCIDENCE ALPHA, degrees)) 10 + )% has too many parenthesis, remove these ones:

(((A:INCIDENCE ALPHA, degrees)) 10 + )

and see what happens.

Tom
 
I can get the string to dispaly properly, however, when using the select case command, it won't allow the formatting %(..)%!3.2f! because it is trying to assign a value rather than a string. That has basically been the issue I have been dealing with since I began... trying to transfer a string command into a value. I've been thinking of another way to restructure the code so that instead of it trying to display the Tacan equivalent, I can have the Tacan freq be the primary display and change the Nav freq based on that. However, the only problem I can think of is how to initialize the proper tacan freq on startup without referencing a nav freq (FSX probably starts out every plane on the same set of frequencies so that might work, I just haven't looked into it that deeply yet). By the way, thanks with the AOA help, works like a charm now.

Matt

By the way Geoff_D, I can see where you are trying to go with that code, but I'm not sure of how to fit it into a command.
 
I can get the string to dispaly properly, however, when using the select case command, it won't allow the formatting %(..)%!3.2f! because it is trying to assign a value rather than a string. That has basically been the issue I have been dealing with since I began... trying to transfer a string command into a value.

You can't use formatting syntax with <Select> <Case> structures. Neither is the need to assing values instead of strings, or something alike.

If you post the conflictive code, I might show you the way to make it work.

Tom
 
Matt

By the way Geoff_D, I can see where you are trying to go with that code, but I'm not sure of how to fit it into a command.

Like

<String>NAV1 Freq %((A:NAV ACTIVE FREQUENCY:1,MHz) 40 * int 0.025 * 116.70 ==)%!d!</String>

may be faster than

<String>NAV1 Freq %((A:NAV ACTIVE FREQUENCY:1,MHz) 100 * near int 100 / 116.70 ==)%!d!</String>

as there is no "near"

Plus you get to ensure that you are on whatever Freq spacing you choose to be on.

BTW: Wonder if FS11 will support 8.33 kHz COM freq spacing ??

Geoff_D
 
Hey guys, I was hoping that maybe one of you could help me out on my coding issues. I have been trying to create a gauge that will display a Tacan frequency for its corresponding VOR freq. I have had a tiny bit of luck in the select case string, however, there is a problem with the coding that will round the VOR frequency (116.50 to 117.45 all round to 117.00). I have tried multiple ways to work the select string syntax, however have been unsuccessful. Hopefully someone here will be able to shed a little light on my problem.

Here's the link for my thread:
http://www.fsdeveloper.com/forum/showthread.php?t=12829

I'm still not at all clear just what you want to accomplish. TACAN operates in the UHF band(960-1215 MHz), only the paired DME transmitter operates in the VHF band.

There is a way to utilize the DME at a non-colocated TACAN (i.e., a "standalone" TACAN, or the DME of a co-located TACAN/ILS installation where the ILS isn't also linked to the TACAN's DME transmitter.

This article describes the "manual method" for this:

http://www.flightsim.com/cgi/kds?$=main/howto/tacan.htm
 
I'm still not at all clear just what you want to accomplish. TACAN operates in the UHF band(960-1215 MHz), only the paired DME transmitter operates in the VHF band.

In the T-45, we have a Tacan and a VOR. Both offer azimuth and DME (when the VOR is a VOR/DME or VORTAC). But in FSX, they utilize the F-18 nav package, which only allows one VOR for navigation. What I was trying to do, is still utilize the VOR for navigation, but also include a method of tuning the VOR through a corresponding Tacan freq (as can be found on charts and approach plates) since the Tacan is our primary nav source. Then, what I also wanted to do, using the same coding, is create a DME only readout for when I am flying a VOR or ILS approach and need DME for identifying fixes. Hope that helps.

I wasn't sure if there is a way to create a local variable, using the string formatting to give me the proper readout (since I can make it display the frequency properly), and then use that variable for <value> in the Select expression. I've done some programming in VB, but this stuff is frustrating because there are so few examples of coding, and there really is no way to debug. Thanks for all help so far!

Matt
 
I wasn't sure if there is a way to create a local variable, using the string formatting to give me the proper readout (since I can make it display the frequency properly), and then use that variable for <value> in the Select expression. I've done some programming in VB, but this stuff is frustrating because there are so few examples of coding, and there really is no way to debug. Thanks for all help so far!

Matt

Well, as you keep off from posting your intended code, I ripped off my laziness and followed your link to see that directly :D

<Case Value="111.90"> won't work ever because <Case> only accepts integer values. Ie "1", "2", "1250" "-123.00" etc.

However, there is a rather simple shortcut that overcomes this:

Let's say you need to test for three freq: 116.50, 115.70 and 113.25

So, following Geoff's example which is very valid:

Code:
<Value>
  (A:NAV ACTIVE FREQUENCY:1,MHz) 40 * int 0.025 * s0
  116.50 == l0 115.70 == 2 * l0 113.25 == 3 * + + 
</Value>
<Case Value="1"> (* this is for 116.50 *)
 <Image1>
<Case Value="2"> (* this is for 115.70 *)
 <Image2>
<Case Value="3"> (* this is for 113.25 *)
 <Image3>
etc.

Hope this makes sense to you now :)

Tom
 
In the T-45, we have a Tacan and a VOR. Both offer azimuth andWhat I was trying to do, is still utilize the VOR for navigation, but also include a method of tuning the VOR through a corresponding Tacan freq (as can be found on charts and approach plates) since the Tacan is our primary nav source.

I'm afraid I still don't fully grasp what you're trying to accomplish. TACAN selection is normally made by "channel selection," i.e., one selects channel 29X and they will be tuned to the UHF TACAN freq. as well as the paired VHF freq. of 109.20...

For a complete channel/freq chart see page 8 of this document:
http://www.ntia.doc.gov/osmhome/redbook/4d.pdf
 
Back
Top