Documentation for the "SwitchItem" structure?

  • pvogel
  • pvogel's Avatar Offline Autor
  • Junior Mitglied
  • Junior Mitglied
  • Beiträge: 22
  • Dank erhalten: 3

Documentation for the "SwitchItem" structure? wurde erstellt von pvogel

Posted 30 Dez. 2016 23:29 #1
I was not able to find any documentation for the "SwitchItem" structure. I would like to vibrate the gimbal associated with a selected switch (if the switch is P1, P2, P3, or P4 obviously) when the control is set to a certain proportional value. Sure, I could ask the user in the form if I should vibrate left or right gimbal, but I should be able to figure it out from the switch they selected!

Thanks,
Peter+
von pvogel

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • TeroS
  • TeroS's Avatar Offline
  • Platinum Mitglied
  • Platinum Mitglied
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370

TeroS antwortete auf Documentation for the "SwitchItem" structure?

Posted 30 Dez. 2016 23:56 #2

pvogel wrote: I was not able to find any documentation for the "SwitchItem" structure. I would like to vibrate the gimbal associated with a selected switch (if the switch is P1, P2, P3, or P4 obviously) when the control is set to a certain proportional value. Sure, I could ask the user in the form if I should vibrate left or right gimbal, but I should be able to figure it out from the switch they selected!

Thanks,
Peter+


I think you are after this:

"If P3 or P4 is over user chosen value then vibrate left stick" and "If P1 or P2 is over user chosen value then vibrate right stick"

It that was right, then it's something like this:
- Give user a choice to select a switch and value
- Make the conditions in loop

Then go.

Note that switches have values between -1.0 and 1.0, not -100% and 100%. This means that 25% equals 0.25.

So for example after defining Sw1 to be P3 or P4:

if(Sw1 >= 0.75) then
system.vibration(false, 3)
end

This would vibrate left stick with two short pulses when P1 is over 75%. You can find all the definitions in Lua API pdf.

Hope this helps, I had fun playing with vibrating sticks some months ago :)
von TeroS

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • pvogel
  • pvogel's Avatar Offline Autor
  • Junior Mitglied
  • Junior Mitglied
  • Beiträge: 22
  • Dank erhalten: 3

pvogel antwortete auf Documentation for the "SwitchItem" structure?

Posted 31 Dez. 2016 00:06 #3
Yes, that's what I'm after (I've written the code already, just hard-coded to shake the left stick for my mode 2 usage) the question is, from the "switchItem" object obtained from the inputBox selector, how do I know if it is P1, P2, P3 or P4 (or something else)?

Current state of the code is here:
github.com/pvogel1967/Lua-Apps/tree/master/Throttle%20Detent
Last Edit:31 Dez. 2016 00:07 von pvogel
Letzte Änderung: 31 Dez. 2016 00:07 von pvogel.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • TeroS
  • TeroS's Avatar Offline
  • Platinum Mitglied
  • Platinum Mitglied
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370

TeroS antwortete auf Documentation for the "SwitchItem" structure?

Posted 31 Dez. 2016 00:20 #4

pvogel wrote: Yes, that's what I'm after (I've written the code already, just hard-coded to shake the left stick for my mode 2 usage) the question is, from the "switchItem" object obtained from the inputBox selector, how do I know if it is P1, P2, P3 or P4 (or something else)?

Current state of the code is here:
github.com/pvogel1967/Lua-Apps/tree/master/Throttle%20Detent


If you want to hard-code the P1 and P2 to one stick vibrating and P3 and P4 to one gimbal then consider this for reading all axes in loop:

local P1, P2, P3, P4 = system.getInputs("P1", "P2", "P3", "P4")

Now you have the values of all gimbal-axes between -1.0 and 1.0 and can use them to do what you want. User does not have to select any switch either. After this all you need to do is to give user a possibility to choose the alarm-limits. And for good user-experience maybe the vibration patterns.
von TeroS

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • pvogel
  • pvogel's Avatar Offline Autor
  • Junior Mitglied
  • Junior Mitglied
  • Beiträge: 22
  • Dank erhalten: 3

pvogel antwortete auf Documentation for the "SwitchItem" structure?

Posted 31 Dez. 2016 00:42 #5

TeroS wrote:

pvogel wrote: Yes, that's what I'm after (I've written the code already, just hard-coded to shake the left stick for my mode 2 usage) the question is, from the "switchItem" object obtained from the inputBox selector, how do I know if it is P1, P2, P3 or P4 (or something else)?

Current state of the code is here:
github.com/pvogel1967/Lua-Apps/tree/master/Throttle%20Detent


If you want to hard-code the P1 and P2 to one stick vibrating and P3 and P4 to one gimbal then consider this for reading all axes in loop:

local P1, P2, P3, P4 = system.getInputs("P1", "P2", "P3", "P4")

Now you have the values of all gimbal-axes between -1.0 and 1.0 and can use them to do what you want. User does not have to select any switch either. After this all you need to do is to give user a possibility to choose the alarm-limits. And for good user-experience maybe the vibration patterns.


I understand all that. But I want the USER to be able to select the control for which they want to have a "detent" vibration. Then I want to apply the vibration to gimbal associated with that control. So I don't want to read all axes, I just want to read one, and then I want to put a gentle "bump" (vibration mode 2) when that one control is within 1% of the set value. Yes, I could let them choose a vibration pattern, but I'm starting simple :-)

Peter+
von pvogel

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • TeroS
  • TeroS's Avatar Offline
  • Platinum Mitglied
  • Platinum Mitglied
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370

TeroS antwortete auf Documentation for the "SwitchItem" structure?

Posted 31 Dez. 2016 10:34 #6
You need to have the switch-selection in form:

form.addRow(2)
form.addLabel({label="Select Axis"})
form.addInputbox(Ax,true,AxChanged)

Then you need to save user's selection (this needs to be above the form)

local function AxChanged(value)
Ax1 = value
system.pSave("Ax",value)
end

In your init-section you need to have the loading of the axis:

Ax = system.pLoad("Ax")

Now you have the users selected axis as "Ax" you can use, the axis-selection needs to be proportional.
von TeroS

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Moderatoren: ThornIG-Modellbau
Ladezeit der Seite: 1.032 Sekunden