Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA:

Documentation for the "SwitchItem" structure? 30 Dez 2016 23:29 #1

  • pvogel
  • pvogels Avatar Autor
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Beiträge: 22
  • Dank erhalten: 3
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+

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Documentation for the "SwitchItem" structure? 30 Dez 2016 23:56 #2

  • TeroS
  • TeroSs Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370

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 :)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Documentation for the "SwitchItem" structure? 31 Dez 2016 00:06 #3

  • pvogel
  • pvogels Avatar Autor
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Beiträge: 22
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Letzte Änderung: von pvogel.

Documentation for the "SwitchItem" structure? 31 Dez 2016 00:20 #4

  • TeroS
  • TeroSs Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370

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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Documentation for the "SwitchItem" structure? 31 Dez 2016 00:42 #5

  • pvogel
  • pvogels Avatar Autor
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Beiträge: 22
  • Dank erhalten: 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


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+

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Documentation for the "SwitchItem" structure? 31 Dez 2016 10:34 #6

  • TeroS
  • TeroSs Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • RC-Thoughts
  • Beiträge: 527
  • Dank erhalten: 370
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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Seite:
  • 1
  • 2
Moderatoren: ThornIG-Modellbau
Ladezeit der Seite: 0.237 Sekunden
Powered by Kunena Forum