Bitte ändert euer Passwort!
Im März 2026 wurde das Forum gehackt. Dabei hatten die Angreifer Zugriff auf die Datenbank und somit Zugriff auf eure Passwörter. Auch wenn das Forum kein Passwort im Klartext speichert, können die Angreifer eure Passwörter knacken. Bitte ändert daher dringend euer Passwort für das Forum. Solltet ihr das gleiche Passwort auch an anderer Stelle verwenden, ändert es bitte unbedingt an allen Stellen!
Documentation for the "SwitchItem" structure?
- pvogel
- Autor
- Offline
- Junior Mitglied
-
- Beiträge: 22
- Thanks: 3
Documentation for the "SwitchItem" structure?
30 Dez. 2016 22:29Thanks,
Peter+
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
- TeroS
-
- Offline
- Platinum Mitglied
-
- RC-Thoughts
- Beiträge: 527
- Thanks: 370
Re: Documentation for the "SwitchItem" structure?
30 Dez. 2016 22:56pvogel 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
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
- pvogel
- Autor
- Offline
- Junior Mitglied
-
- Beiträge: 22
- Thanks: 3
Re: Documentation for the "SwitchItem" structure?
30 Dez. 2016 23:06 - 30 Dez. 2016 23:07Current state of the code is here:
github.com/pvogel1967/Lua-Apps/tree/master/Throttle%20Detent
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
- TeroS
-
- Offline
- Platinum Mitglied
-
- RC-Thoughts
- Beiträge: 527
- Thanks: 370
Re: Documentation for the "SwitchItem" structure?
30 Dez. 2016 23:20pvogel 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.
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
- pvogel
- Autor
- Offline
- Junior Mitglied
-
- Beiträge: 22
- Thanks: 3
Re: Documentation for the "SwitchItem" structure?
30 Dez. 2016 23:42TeroS 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+
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
- TeroS
-
- Offline
- Platinum Mitglied
-
- RC-Thoughts
- Beiträge: 527
- Thanks: 370
Re: Documentation for the "SwitchItem" structure?
31 Dez. 2016 09:34form.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.