Jump to content
Sign in to follow this  
Slammer

Freq Rotating Switch Question

Recommended Posts

All,I'm having a problem with a freq switch that i can't get solved. I have a rotating switch as follows:<Gauge Name="UHF-FRAC" Version="1.0"> <Element> <Select> <Value>(L:UHF-FRAC, enum)</Value> <Case Value="0"> <Image Name="Knob_H_00.bmp" ImageSizes="40,41"/> </Case> <Case Value="1"> <Image Name="Knob_H_01.bmp" ImageSizes="40,41"/> </Case> <Case Value="2"> <Image Name="Knob_H_02.bmp" ImageSizes="40,41"/> </Case> <Case Value="3"> <Image Name="Knob_H_03.bmp" ImageSizes="40,41"/> </Case> <Case Value="4"> <Image Name="Knob_H_04.bmp" ImageSizes="40,41"/> </Case> <Case Value="5"> <Image Name="Knob_H_05.bmp" ImageSizes="40,41"/> </Case> </Select> </Element> <Mouse> <Cursor Type="Hand"/><Click>(L:UHF-FRAC, enum) 5 == if{ 0 (>L:UHF-FRAC, enum) } els{ (L:UHF-FRAC, enum) ++ (>L:UHF-FRAC, enum) }</Click> <Tooltip ID="">ROTATE FREQ DEC SWITCH</Tooltip> </Mouse></Gauge>When i click it the switch turns as advertised, only i want to couple it to the increase/decrease the frequency of the radio. I've tried to couple it to the following code but it does not work.<Gauge Name="UHF ROTATE + DECREASE" Version="1.0" Author="666"> <Update Frequency="4"/><!-- Radio Frequency Decrease --> <Element> <Select> <Value>(L:UHF-FRAC,enum) case if{(> K:COM_RADIO_WHOLE_DEC)} </Value> </Select> </Element></Gauge>Is there somebody out there to help me with this?Thanks in advance!Slammer

Share this post


Link to post
Share on other sites

If you want only one mouse area, then you need to set it up to detect left click and right click events:

<Mouse>  <Cursor Type="Hand"/>  <Click Kind="LeftSingle + RightSingle">	<!-- If the Right button is clicked, then increase knob rotation and freq. -->	(M:Event) 'RightSingle' scmp 0 ==	if{	  (L:UHF-FRAC, enum) ++ 5 min (>L:UHF-FRAC, enum)	  (>K:COM_RADIO_FRACT_INC_CARRY)	}	<!-- If the Left button is clicked, then decrease knob rotation and freq. -->	(M:Event) 'LeftSingle' scmp 0 ==	if{	  (L:UHF-FRAC, enum) -- 0 max (>L:UHF-FRAC, enum)	  (>K:COM_RADIO_FRACT_DEC_CARRY)	}  </Click>  <Tooltip>ROTATE FREQ DEC SWITCH</Tooltip></Mouse>


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Fr,Thanks for your help, it works fine. I only have one question:The switch contains 5 bitmaps, if decrease frequency bitmap disappears and if i increase beyond 5 the bitmap also disappears which is logical (given the 5 as maximum). Since it takes a lot of clicks to set the right freq i made 40 bitmaps. Is there an easier way to make a loop in this switch since 5 bitmaps covers 360 degrees? Thanks for your time and help! :( Ed

Share this post


Link to post
Share on other sites

I would only use ONE bitmap, and then "rotate" it something like this:

<Gauge Name="UHF-FRAC" Version="1.0">  <Element Name="Frequency Knob">	<Position X="346" Y="331"/>	<Image Name="Knob_H_00.bmp" Bright="Yes" PointsTo="North">	  <Axis X="20" Y="20"/>	</Image>	<Rotate>	  <Value>		<Value Minimum="0" Maximum="36">(L:UHF-FRAC, enum) 0 max 36 min</Value>	  </Value>	</Rotate>  </Element>  <Mouse>	<Cursor Type="Hand"/>	<Click Kind="LeftSingle + RightSingle">	  <!-- If the Right button is clicked, then increase knob rotation and freq. -->	  (M:Event) 'RightSingle' scmp 0 ==	  if{	  (L:UHF-FRAC, enum) ++ 36 min (>L:UHF-FRAC, enum)	  (>K:COM_RADIO_FRACT_INC_CARRY)	  }	  <!-- If the Left button is clicked, then decrease knob rotation and freq. -->	  (M:Event) 'LeftSingle' scmp 0 ==	  if{	  (L:UHF-FRAC, enum) -- 0 max (>L:UHF-FRAC, enum)	  (>K:COM_RADIO_FRACT_DEC_CARRY)	  }	</Click>	<Tooltip>ROTATE FREQ DEC SWITCH</Tooltip>  </Mouse></Gauge>


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Fr,Sorry, it doesn't show the bitmap. If i remove the <position> statement it will show the bitmap and changes the freq but doesn't turn the bitmap.RegardsEd

Share this post


Link to post
Share on other sites

I see no need to use an additional variable (L:UHF-FRAC, enum) to animate the bitmap.A code like this is enough. <Element> <Position X="60" Y="116"/> <Image Name="Radio_COM_knob.bmp" PointsTo="East"> <Axis X="15" Y="15"/> </Image> <Rotate> <Value>(A:COM ACTIVE FREQUENCY:1, Megahertz) 10 *</Value> <Nonlinearity> <Item Value="0" Degrees="0"/> <Item Value="2" Degrees="360"/> </Nonlinearity> </Rotate> </Element>... <Mouse> </Area> <Area Left="20" Top="76" Width="80" Height="40"> <Area Right="40"> <Cursor Type="DownArrow"/> <Click Event="COM_RADIO_FRACT_DEC" Repeat="Yes"/> </Area> <Area Left="40"> <Cursor Type="UpArrow"/> <Click Event="COM_RADIO_FRACT_INC" Repeat="Yes"/> </Area> <Tooltip ID="TOOLTIPTEXT_COMM1_FREQ"/> </Area> </Mouse>Herbert

Share this post


Link to post
Share on other sites
I see no need to use an additional variable (L:UHF-FRAC, enum) to animate the bitmap.
You are correct, there is no (obvious) need in this specific case. I was simply showing a method to use his existing custom L:variable. If one understands the method, then it may be applied to any other general case.Is there some particular reason you didn't encapsulate your XML script example in the forum's

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
You are correct, there is no (obvious) need in this specific case. I was simply showing a method to use his existing custom L:variable. If one understands the method, then it may be applied to any other general case.Is there some particular reason you didn't encapsulate your XML script example in the forum's
 tags? Doing so preserves the formatting of the XML script, and also allows readers to quickly cut-and-paste the entire script from the [code] box...  :(Hi Bill,Neither did I want to criticize your code - it's exellent as usual - nor is there any particular reason for the appearance of my code. I simply copied and pasted it. In deed I also was surprised, why the formatting got lost on the way, bid did not think about that any longer... Next time I'll try to make it better.But I've allmost retired from creating panel and gauges and visit this forum only occasionally. So there might not come up too many posts getting a reply from me... :( Best regards,Herbert

Share this post


Link to post
Share on other sites

Bill & Herbert,Thank you very much for your interest in my problem and the solutions you've given me it really helped a lot. In the mean time (since i did not seet the bitmap using Bills last posted code, i dunno why!) i had a look at the FS2X tutorials and found the <nonlinearity> code and together with the click statement of Bill (thanks a lot) i made the following code that also solves the problem not showing the bitmap when minimum or maximum values are surpassed. It looks like this:<Gauge Name="UHF-FRAC" Version="1.0"> <Image Name="UHF_Background.bmp" ImageSizes="60,60" Luminous="1"/>//-------------------- <Element Name="Frequency Knob"> <Position X="60" Y="60"/> <Image Name="Knob_H_00.bmp" Bright="Yes"> <Axis X="30" Y="30"/> </Image> <Rotate> <Value>(L:UHF-FRAC, enum)</Value> <Nonlinearity> <Item Value="0" X="70" Y="50"/> <Item Value="1" X="90" Y="50"/> <Item Value="2" X="90" Y="70"/> <Item Value="3" X="70" Y="70"/> </Nonlinearity> </Rotate> </Element> <Mouse> <Cursor Type="Hand"/> <Click Kind="LeftSingle + RightSingle"> <!-- If the Right button is clicked, then increase knob rotation and freq. --> (M:Event) 'RightSingle' scmp 0 == if{ (L:UHF-FRAC, enum) ++ (>L:UHF-FRAC, enum) (>K:COM_RADIO_FRACT_INC_CARRY) } <!-- If the Left button is clicked, then decrease knob rotation and freq. --> (M:Event) 'LeftSingle' scmp 0 == if{ (L:UHF-FRAC, enum) -- (>L:UHF-FRAC, enum) (>K:COM_RADIO_FRACT_DEC_CARRY) } </Click> <Tooltip>ROTATE FREQ DEC SWITCH</Tooltip> </Mouse></Gauge>I also removed the min/max statements and the knob keeps on rotating left and right constantly showing the bitmap.Bill, thank you very much again for your great inputs. Without this I would be bold and have sleepless nights! Awsome...Regards Ed

Share this post


Link to post
Share on other sites
nor is there any particular reason for the appearance of my code. I simply copied and pasted it.
After copy/paste, reselect all the script, and then click the button on the far right end of the editor (tooltip says: "Wrap in code tags")
This text is wrapped in "code tags"	 so all the indenting  and					   other formattingis preserved...

:(


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
<Gauge Name="UHF-FRAC" Version="1.0"><Image Name="UHF_Background.bmp" ImageSizes="60,60" Luminous="1"/>//--------------------<Element Name="Frequency Knob"><Position X="60" Y="60"/><Image Name="Knob_H_00.bmp" Bright="Yes"><Axis X="30" Y="30"/></Image><Rotate><Value>(L:UHF-FRAC, enum)</Value><Nonlinearity><Item Value="0" X="70" Y="50"/><Item Value="1" X="90" Y="50"/><Item Value="2" X="90" Y="70"/><Item Value="3" X="70" Y="70"/></Nonlinearity></Rotate></Element><Mouse><Cursor Type="Hand"/><Click Kind="LeftSingle + RightSingle"><!-- If the Right button is clicked, then increase knob rotation and freq. -->(M:Event) 'RightSingle' scmp 0 ==if{(L:UHF-FRAC, enum) ++ (>L:UHF-FRAC, enum)(>K:COM_RADIO_FRACT_INC_CARRY)}<!-- If the Left button is clicked, then decrease knob rotation and freq. -->(M:Event) 'LeftSingle' scmp 0 ==if{(L:UHF-FRAC, enum) -- (>L:UHF-FRAC, enum)(>K:COM_RADIO_FRACT_DEC_CARRY)}</Click><Tooltip>ROTATE FREQ DEC SWITCH</Tooltip></Mouse></Gauge>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...