#How do I simply toggle a switch using a preset?

1 messages · Page 1 of 1 (latest)

trail pasture
#

Hi All,

I'm coming from SPAD.Next where things are a little....simplier.

Can anybody tell me how I toggle an LVAR value between 0 and 1 using a preset. I understand I've got to use RPN code. For example, I'm trying to have the LVAR L:S_OH_OXYGEN_CREW_OXYGEN rotate between 0 and 1 on each button press. I want to have the variable toggle for EVERY press - Not set a 1 on press and a 0 on release.

The connector template profile thingy (whatever its called in Mobiflight) I've downloaded and am modifying currently has the button setup as a PRESS = 1 and RELEASE = 0. I can't figure out what RPN code it is going to take to just have 0/1 TOGGLE on every press of the button, regardless of weather its a release or a press.

This is what is set at the moment which I'm guessing is setting it to 0 on release only. I can't work out what the hell its doing on press....

Any advice on how to implement this incredably simple yet beyond me peice of programming? 🙂

obsidian crypt
#

yeah, you should not have anything on Release then?

#

because the (L:lvarname) ! (>L:lvarname) is indeed reading the value, inverting it, and then sending it back to the lvar.

#

does the PRESS event work correctly for you, before you release the switch?

#

What aircraft is this? And is setting the L-var working? If you just do

1 (>L:varname) on press, and 0 on release, to just check that it even works?

trail pasture
#

Thanks mate - That works. I really need to learn more about RPN scripts/code to understand the language and how to change values etc.

boreal condor
#

How would you do a custom event in Spad?

obsidian crypt
#

yeah generally momentary pushbuttons that are meant to toggle a function on and off only use the Press -event, because you will always get the Release immediately after.

An example case for using both Press and Release would be something like a warning lights test, that is active while you hold the button pressed.

trail pasture
#

Yeah, this is with the Rowsfire A107 where the buttons a push puttons but "click" in. So they have a definitive PRESS & RELEASE as two seperate motion. Whlist the buttons push in, click in place and hold there until you press and release them, there is vertually no discernable difference visually on the actual hardware that the button is either in or out.

boreal condor
trail pasture
#

Yeah its not clear to me why the programmed those buttons get way they did

boreal condor
#

But can you explain how you would do it in SPAD or what you find would be more intuitive?

trail pasture
#

I guess its what you get used to. I find the GUI in SPAD much more intuitive and ... well, it seems to offer more guidance. To toggle a value between 0 and 1 I click on the button/switch I want to have as an input, click "EDIT ACTION" and then simply select "TOGGLE BIT". As you can see other options exist to change values, increment values etc etc etc.... In Mobiflight it appears I need to use RPN code to acheive this. Which is fine, if you know how to write that. I don't so rely on SPAD to do the doing for me...I just use the GUI to reflect what I want done.

Note that this is not the device or button I was seeking assistance with...just an example. Unfortunatly SPAD does not yet have support for the A107 (hence I'm using mobiflight for it)

boreal condor
#

ideally there is a preset available and you dont have to deal with the RPN snippet behind it.

#

but yeah. Interesting but makes me wonder that it is also extremely limited.

#

but a RPN editor would be a cool thing for sure

obsidian crypt
#

or we could have a preset more like a template that can handle the B-vars in msfs2024, that could have a "set value", "toggle", "set ON", "set OFF", etc instead of doing them as separate presets?

Or try to create something where you set an input type for the device like above, and then manipulate a switch in the cockpit and try to listen to changes in events, and create your preset that way, with option of sharing it with others.

#

I think Spad can do something like that too? Or was it some other app?

trail pasture
boreal condor
#

I actually have used it only for a bit to see how it "looks" and is structured.

#

Looking at your screenshot - it looks very technical.

boreal condor
trail pasture
#

I'm trying to learn it, but not understanding RPN coding and how to read, change and adjust the various variables makes for a steeper learning curve

#

It took me a while to. Learn spad having moved from AxisAndAohs, but its actually very simple

boreal condor
#

like is said, most of the times you should not have to deal with the preset code

#

are those not available for the airplane which you are configuring?

#

this preset simply has the wrong name. It should be called ... Crew Button Toggle

#

Like you said: this set 0 to the L Var

#

the simple equivalent would be 1 (>L:S_OH_OXYGEN_CREW_OXYGEN)

#

@nova coral wdyt - why is the preset toggling if it is called "... Press""

nova coral
#

I think it is a button in the cockpit and the action of pressing will toggle the function.

#

If it were a latching switch it would say ON

#

And OFF

boreal condor
#

then there should not be a RELEASE preset

#

And the preset still could be name TOGGLE

#

because that is what the preset is doing

nova coral
#

Yes, could be. You are entering the realm of naming conventions which we never had one.

#

It is whatever made sense to the person that created the event.

boreal condor
#

I understand that. At the same time it is not set in stone and if we notice something like this we could fix it right away.

#

It doesn't make sense if we these events are not symmetrical

#

They are called Press and Release but they do different things... first toggles and the second one actually triggers only the release.

nova coral
#

Then there is a few thousand events that need correction.

#

I myself have used press countless of times. There is also Push used.

#

I usually put a note in the description if the release is required.

boreal condor
#

You are using Press for a label that is for a Toggle event. Yes?

#

I think this would make an excellent task for an AI agent.

#

look at the presets... check Press has Release. Check Press is not a toggle. Suggest renaming Press to toggle. Etc.

#

Enforce consistency for systems

obsidian crypt
#

would it make sense to have the input config have a template? Like "Add input -> toggle switch -> it would have ON state and OFF state?

#

might be too rigid though

nova coral
#

I understand what you are saying, but this is what now makes sense to you, almost five years after having Hubhop working.

I suggested a very long time ago that we needed a naming convention for everyone to use and we needed quality checks for all inputs into Hubhop. That, as far as I know, has not gone very far.

Not all developers use the word toggle to name their actions in the sim. In general, I have followed what the cockpit tooltips and code labels use.

trail pasture
#

I'm grateful for the discussion from the developers - Thats really good to see that you're open to change and adjustment. For what its worth, there are other buttons on this panel that use the same sort of naming conventions. From my recollections the batteries were the same - The switchs are all either PRESS or RELEASE (ON or OFF) but the way the configuration was setup it was 1 on press and 0 on release. Given the switches on the hardware don't show any visual difference if they're either ON (PRESSED) or OFF (RELEASED), I think it would be far simplier to have the user select a "TOGGLE" option and use the corrosponding present rather than have to rely simply on PRESS and RELEASE.

You can see see on my image of SPAD above (and this is only a very simple example of what the software can do) that you have options to SET a particular value, increment/decrement by different values, clear values, limit the values....endless posibilitys...