Sign in to follow this  
Guest LOT

Rotating Knob Gauge

Recommended Posts

Hi all!I need to create a rotating knob on an ADF panel using the ADF Panel bitmap and the knob bitmap. The knob is supposed to have 4 positions:knob1dt.jpgSo far I managed to create only 2 positions:(G:Var1)Rotating Knob(G:Var1) ! (>G:Var1)Any ideas?

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Yes :-)G:Var1) ! (>G:Var1) means you use G: Var1 as a boolean, so one 0 and 1.Also don't use a G:var, since under some circumstances (like going from Windowed to FullScreen mode, v.v.) but use an L:var instead.Like:(L:RotatingKnob,enum) ++ d (>L:RotatingKnob,enum)4 ==if{ 0 (>L:RotatingKnob,enum) }If you want two clickspots (like up and down), use (mind the xx and yy):Rotating Knob(L:RotatingKnob,enum) ++ 3 min (>L:RotatingKnob,enum)Rotating Knob(L:RotatingKnob,enum) -- 0 max (>L:RotatingKnob,enum)Cheers, Rob

Share this post


Link to post
Share on other sites

Thanks, Rob! :) It works. I was a bit misled by Nick Pike's FS2004 XML Gauge Programming tutorial (1.4 and ) in which he is using G:Var for rotating.Now I'd like to add a sound to the knob with the dsd_xml_sound3.gau gauge. I configured the sounds.ini file as follows:---------------[Config]MaxSounds=1Lvar=dsd_xml_sound_idLvarStop=dsd_stop_sounds[sounds]Sound00=./THE_PATH/click.wav[LVars]Lvar00=dsd_xml_sound_id_00---------------Also I added the dsd_xml_sound_id_00 Lvar to the clickable areas:---------------Rotating Knob(L:RotatingKnob,enum) ++ 3 min (>L:RotatingKnob,enum) 1 (>L:dsd_xml_sound_id_00,number)Rotating Knob(L:RotatingKnob,enum) -- 0 max (>L:RotatingKnob,enum) 1 (>L:dsd_xml_sound_id_00,number)---------------I have the sound now but there is a little problem that you can still hear it when you click on extreme left and right positions (for (+) and (-) clickable areas). I have to change the logic so I can hear the sound only when rotating the knob. Any help would be appreciated. :)

Share this post


Link to post
Share on other sites

Hi,Try for the sound:(L:RotatingKnob,enum) s0 0 >= l0 3 <= and if{ 1 (>L:dsd_xml_sound_id_00,number) } Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

>Hi,>>Try for the sound:>>(L:RotatingKnob,enum) s0 0 >= l0 3 <= and >if{ 1 (>L:dsd_xml_sound_id_00,number) } >>Jan>>"Beatus ille qui procul negotiis..."Hi, Looks like something wrong with the syntax because the gauge won't show up. Any ideas?

Share this post


Link to post
Share on other sites

Hi,Possible(?);try:(L:RotatingKnob,enum) -- 0 max (>L:RotatingKnob,enum) (L:RotatingKnob,enum) 0 >= (L:RotatingKnob,enum) 3 <= && if{ 1 (>L:dsd_xml_sound_id_00,number) } (L:RotatingKnob,enum) ++ 3 min (>L:RotatingKnob,enum) (L:RotatingKnob,enum) 0 >= (L:RotatingKnob,enum) 3 <= && if{ 1 (>L:dsd_xml_sound_id_00,number) } Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

I think the problem is in using "<=" or in "and"I've never figured out when you could you these constructors like >, >=, < or <=. Hence, I always use:- ">" instead of ">"- "<" instead of "<"- "&&" instead of "and"That always works.Try it. At least the gauge loads now.But (sorry Jan if I'm wrong), it doesn't do what you what.If I understand correctly, you only want the sound if (L:RotatingKnob,enum) actually changes when you click the gauge, right ?So NOT with UP if it's already 3, or DOWN if it's already 0.If so, use:Rotating Knob(L:RotatingKnob,enum) 3 <if{ 1 (>L:dsd_xml_sound_id_00,number) }(L:RotatingKnob,enum) ++ 3 min (>L:RotatingKnob,enum)Rotating Knob(L:RotatingKnob,enum) 0 >if{ 1 (>L:dsd_xml_sound_id_00,number) }(L:RotatingKnob,enum) -- 0 max (>L:RotatingKnob,enum)Rob

Share this post


Link to post
Share on other sites

Hi Jan,Using "<" as smaller-than" gives a syntax error.Which, come to think of it, is logical. Because "<" is the opening symbol of the next tag. Which also explains why ">" DOES work :-)Cheers, Rob

Share this post


Link to post
Share on other sites

Hi,Totally correct.That is why i always use more click area's like:0 (>L:RotatingKnob,enum)1 (>L:dsd_xml_sound_id_00,number)1 (>L:RotatingKnob,enum)1 (>L:dsd_xml_sound_id_00,number)2 (>L:RotatingKnob,enum)1 (>L:dsd_xml_sound_id_00,number)3 (>L:RotatingKnob,enum)1 (>L:dsd_xml_sound_id_00,number)Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Jan, did you also noticed my post above (#7) about "<" being illegal as "smaller-than" operator (gives a syntax error)??Cheers, ROb

Share this post


Link to post
Share on other sites

Hi,I use this approach, works good when there is complex code embedded:Cant of positions : 3 (0-2)Up:(Lvar) ++ 3 min (>Lvar)If lvar = 1 then complex codeIf lvar = 2 then complex codeLVar 3 == if{ 2 (>Lvar) }Down:(Lvar) -- -1 max (>Lvar)If lvar = 0 then complex codeIf lvar = 1 then complex codeLVar -1 == if{ 0 (>Lvar) }Tom

Share this post


Link to post
Share on other sites

Hi,I know, but the forum translates my > and < in the wrong characters.I use the right ones.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Thanks, guys! Now it's all right. I used Rob's solution. Now I need to create a pressed/released button on the panel. Its mechanics should work like a "mouse button". I put it as follows: (L:Button,bool)Button(L:Button,bool) ! (>L:Button,bool)Now the problem is that I'd like to add 2 sounds to it: when you press it you can hear L:dsd_xml_sound_id_03 (that sounds once) and when you release it you can hear L:dsd_xml_sound_id_04.Also when using the above code continuous button press/release actionshappen when you press & hold the mouse button. I have change the codeso that when you press the button it remains pressed. Any suggestions?

Share this post


Link to post
Share on other sites

Hi,Play with:(M:Event) 'LeftSingle' scmp 0 == if{ 1 (>L:dsd_xml_sound_id_03,enum) 1 (>L:Button,bool) } (M:Event) 'Leave' scmp 0 == if{ 1 (>L:dsd_xml_sound_id_04,enum) 0 (>L:Button,bool) } Hope it helps,Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Hi,Thanks, but when using your code you can hear the sounds but the bitmaps won't change. Also when you click & hold the mouse button the sounds come repeatedly. I rewrote the code as follows: Button (L:Button,bool) ! (>L:Button,bool) (L:Button,bool) 1 < if{ 1 (>L:dsd_xml_sound_id_03,number) } (L:Button,bool) 0 > if{ 1 (>L:dsd_xml_sound_id_04,number) } Now when you single click the button all seems perfect but when you hold the mouse button down the sounds and bitmaps start to change repeatedly and even change the order they apear and sound. Any ideas to solve this?

Share this post


Link to post
Share on other sites

Hi,The solution goes through Jan's original code, slightly amended:(M:Event) 'LeftSingle' scmp 0 == (L:Button,bool) ! and if{ 1 (>L:dsd_xml_sound_id_03,enum) 1 (>L:Button,bool) } (M:Event) 'Leave' scmp 0 == if{ 1 (>L:dsd_xml_sound_id_04,enum) 0 (>L:Button,bool)} It is important that you understand the meaning of and how to code inside this tag, otherwise you won't get the result you're looking for no matter the hard you try. I recommend you to go back to Nick's tutorial Chapter 2, Interaction Sections, where this topic is well detailed.Tom

Share this post


Link to post
Share on other sites

>Hi,>>The solution goes through Jan's original code, slightly>amended:>Thanks Tom! Works perfectly. Now I have to add a knob that works like this:It has 3 positions: Left (-20 degree angle), Right (20 degree angle), and the main Center position. knobgg5.jpgWhen you turn it to the right (or left) and then release it it should return back to its cneter postion. Like in the above press/release button example it should also produce 2 sounds (that sound once): when turned and held - L:dsd_xml_sound_id_05; when the knob returns back - L:dsd_xml_sound_id_06. Any clues?

Share this post


Link to post
Share on other sites

Hi, You could try something like:(M:Event) 'LeftSingle' scmp 0 == if{ 1 (>L:sound 1,enum) "click" -1 (>L:your action,enum) "switch left" } (M:Event) 'Leave' scmp 0 == if{ 1 (>L:sound 2,enum) "clack" 0 (>L:your action,enum) "switch center" }and(M:Event) 'LeftSingle' scmp 0 == if{ 1 (>L:sound 1,enum) "click" 1 (>L:your action,enum) "switch right" } (M:Event) 'Leave' scmp 0 == if{ 1 (>L:sound 2,enum) "clack" 0 (>L:your action,enum) "switch center" }Hope it helps,Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

You can use a single bmp, centered, and then use the axis commands to make it rotate 20 deg to the left and 20 to the right..Soemthing like: (L:Knob position,enum) And in the sections-Left Area(M:Event) 'LeftSingle' scmp 0 ==if{ (L:Knob position,enum) -1 != (>L:dsd_xml_sound_id_05) -1 (>L:Knob position,enum) }(M:Event) 'Leave' scmp 0 ==if{ (L:Knob position,enum) 0 != (>L:dsd_xml_sound_id_06) 0 (>L:Knob position,enum) }-Right Area replace -1 with 1 and that's itHope this works in real as I think it should be :-)Tom

Share this post


Link to post
Share on other sites

Thanks! Perfect as always ;) Now I face a more complicated task. I need to make the ADF Loop Antenna Control Switch ("Knob position" gauge) work for 3 ADF modes switched by ADF Mode Selector ("RotatingKnob" gauge (see the above posts)): the main COMP (compass) mode; ANT (nondirectional antenna) mode; and the LOOP (loop antenna) mode.The Cold Dark ADF panel:http://harrierpanels.avsim.ru/XML/adf_cold_dark.htmlOld ADF receivers have several operating modes that the pilot can select. In the COMP mode, both the loop and the sense antennas are used, the pointer is activated, and the ADF tries to point to the station. (This is the normal mode of operation.) Switching the loop antenna control switch to either left or right position will cause the loop antenna and pointer to move left or right. Releasing the switch causes the loop antenna and pointer to rotate and point to the station again.The ADF COMP Mode:http://harrierpanels.avsim.ru/XML/adf_comp_mode.htmlI added some code to the "Knob position" gauge but it does not seem to work properly :) By switching the Loop Antenna Control Switch to the left or right position it does make the RMI pointer or needle rotate accordingly but when the ADF catches the station it doesn't work. Now the "Knob position" gauge looks like this: (L:Knob position,enum)ADF Loop Antenna Control Switch: Rotate Left (M:Event) 'LeftSingle' scmp 0 == if{ (L:Knob position,enum) -1 != (>L:dsd_xml_sound_id_05,number) -1 (>L:Knob position,enum) } (M:Event) 'Leave' scmp 0 == if{ (L:Knob position,enum) 0 != (>L:dsd_xml_sound_id_06,number) 0 (>L:Knob position,enum) } (L:Var7, number) 1 - s0 0 < if{ 359 } els{ l0 } (>L:Var7, number) ADF Loop Antenna Control Switch: Rotate Right (M:Event) 'LeftSingle' scmp 0 == if{ (L:Knob position,enum) 1 != (>L:dsd_xml_sound_id_05,number) 1 (>L:Knob position,enum) } (M:Event) 'Leave' scmp 0 == if{ (L:Knob position,enum) 0 != (>L:dsd_xml_sound_id_06,number) 0 (>L:Knob position,enum) } (L:Var7, number) 1 + 360 % (>L:Var7, number) The gauge is supposed to work in connection with the "RotatingKnob" gauge, ADF Signal Strength gauge, and the RMI gauge provided that the Main Battery is on: (A:Electrical master battery,bool) (or there's a powerfrom the generator (A:General ENG1 Generator Active,bool)), Avionics is on: (A:Avionics master switch,bool), ADF Power is on: (L:ADFPower, bool), and the ADF Mode Selector is in any of the 3 positions except OFF: (L:RotatingKnob,enum) 0 >. The gauges' codes are below: (L:RotatingKnob,enum)ADF Mode Selector (L:RotatingKnob,enum) 0 > if{ 1 (>L:dsd_xml_sound_id_04,number) } (L:RotatingKnob,enum) -- 0 max (>L:RotatingKnob,enum) ADF Mode Selector (L:RotatingKnob,enum) 3 < if{ 1 (>L:dsd_xml_sound_id_03,number) } (L:RotatingKnob,enum) ++ 3 min (>L:RotatingKnob,enum) ------------------------------------------------------ (A:Electrical master battery,bool) if{ (L:ADFPower, bool) (L:RotatingKnob,enum) && if{ (A:Adf signal:1,number) 200000 min } els{ 0 } } (A:General ENG1 Generator Active,bool) if{ (L:ADFPower, bool) (L:RotatingKnob,enum) && if{ (A:Adf signal:1,number) 200000 min } els{ 0 } } ------------------------------------------------------ (A:ADF Signal:1,bel) ! if{ (L:Var7, number) (L:Var3, number) + (>L:Var7, number) (L:Var7, number) 20 (P:Absolute time,minutes) 60 % + > if{ -0.05 (>L:Var3, number) } (L:Var7, number) (A:Plane heading degrees gyro,degrees) /-/ < if{ (P:Absolute time,seconds) 60 % 200 / (>L:Var3, number) } } els{ 0 (>L:Var7, number) } (L:Var9, number) 0 == if{ 0.1 (>L:Var3, number) -0.4 (>L:Var4, number) 1 (>L:Var9, number) }(A:Electrical master battery,bool) if{ (L:ADFPower, bool) (L:RotatingKnob,enum) && if{ (A:ADF Radial:1,radians) (L:Var7, number) 20 / + } els{ 0 } } (A:General ENG1 Generator Active,bool) if{ (L:ADFPower, bool) (L:RotatingKnob,enum) && if{ (A:ADF Radial:1,radians) (L:Var7, number) 20 / + } els{ 0 } } ------------------------------------------------------In the ANT mode, the loop antenna is disabled and all receiving is done through the sense antenna. I guess the RMI pointer will move (or won't?:-)) if you switch the loop antenna control switch left or right and stay where you leave it but it has no use for the antenna. (This is the best mode for listening to your favorite ball game.) It is also good for identifying the station. Thus, for this mode I need a code to be added to the "Knob position" gauge (and the RMI gauge) that will cause the RMI pointer to rotate with the help of the loop antenna control switch and to freeze where you leave it (when you release the loop antenna control switch). :)The ADF LOOP Mode:http://harrierpanels.avsim.ru/XML/adf_loop_mode.htmlIf the LOOP mode is selected, the sense antenna is disabled and all the receiving is done through the loop antenna. Switching the loop antenna control switch to either left or right position will cause the loop antenna and pointer to rotate in the selected direction for as long as the switch is held. Releasing the control switch causes the loop antenna and pointer to stay where it is. You may also notice that the reception gets better when the pointer is 90 degrees away from the station and worse when the pointer is either pointed directly at or 180 degrees away from the station. As to the Signal Strength Indicator in the LOOP mode when the pointer and the loop antenna point directly to the NDB station I guess the signal strength indicator needle will indicate the minimum signal strenght. That's it. I need a code for this mode as well (in connection with the Signal Strength Indicator needle if possible) and would love to hear your ideas! ;)

Share this post


Link to post
Share on other sites

LOT,I'd like to help, but you put a lot of code, info and links on your message and I don't have time at this moment to read it all, analyze it and try to compose a suitable example. Besides, it is not my style to develope kind of complete gauges for anybody, but instead give straight examples that can be used as a guide. Also I believe the other people that collaborated in this thread think the same.I hope you will understand this :-)This being said, I suggest you try to read carefully all the related info that can be found in this forum, give on testing (your code doesn't look bad at first sight) and then post specific sections (one at a time) where you keep lost. Tom

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