-- ############################################################################# -- # Throttle Stick "Soft" Detent - Lua application for JETI DC/DS transmitters -- # Developed by Peter A Vogel, donated to JETI Model s.r.o via pull request -- # Copyright (c) 2017, Peter A Vogel All rights reserved. -- # License donated to JETI Model s.r.o. for the benefit of JETI pilots -- # License: Share alike, can be used and changed non commercial -- # V1.0 - Initial release -- # V2.00 Changes and Extensions by Wolfgang Schreiner 29.10.2017 -- # Add On-Off-Switch and Vibration side select, now without language settings -- ############################################################################# --Configuration local input local bumpValue local haveBumped = false local Switch_Int local VibrPos local appName="Throttle Detent/Beep" -------------------------------------------------------------------- -- Form functions -------------------------------------------------------------------- -------------------------------------------------------------------- local function inputChanged(value) input = value system.pSave("input", input) end local function bumpValueChanged(value) bumpValue = value system.pSave("bumpValue", bumpValue) end local function IntSwitchChanged(value) Switch_Int = value system.pSave("Switch_Int", Switch_Int) end local function checkVibrPosClicked(value) VibrPos = value system.pSave("VibrPos", VibrPos) end -------------------------------------------------------------------- local function initForm(formID) local typeOptions={"left ", "right", "both", "no"} form.addRow(2) form.addLabel({label="Select Input, use Prop.",width=250}) form.addInputbox(input, true, inputChanged) form.addRow(2) form.addLabel({label="Bump Value (Cent.= 0%)",width=250}) form.addIntbox(bumpValue, -100, 100, 0, 0, 1, bumpValueChanged) form.addRow(2) form.addLabel({label="On-Off Switch",width=250}) form.addInputbox(Switch_Int, true, IntSwitchChanged) form.addRow(2) form.addLabel({label="Vibration",width=180}) form.addSelectbox(typeOptions,VibrPos,false, checkVibrPosClicked) end -------------------------------------------------------------------- -- Initialization -------------------------------------------------------------------- -- Init function local function init() input = system.pLoad("input", nil) bumpValue = system.pLoad("bumpValue", 0) VibrPos= system.pLoad("VibrPos",1) Switch_Int = system.pLoad("Switch_Int") --register our data form system.registerForm(1,MENU_ADVANCED,appName,initForm,nil,printForm) end -------------------------------------------------------------------- -- Loop function local function loop() local val = system.getInputsVal(input) if (not val) then return end local tol = 2 val = val * 100 local Sw_Int_val = system.getInputsVal(Switch_Int) if (not haveBumped and (val >= bumpValue-tol and val <= bumpValue+tol)) then haveBumped = true if (Sw_Int_val == 1) then if (VibrPos == 1) or (VibrPos == 3) then system.vibration(false, 2) end if (VibrPos == 2) or (VibrPos == 3) then system.vibration(true, 2) end system.playBeep(1, 430, 100) end end if (haveBumped and (val < bumpValue-tol or val > bumpValue+tol)) then haveBumped = false end end -------------------------------------------------------------------- return { init=init, loop=loop, author="P.Vogel-W.Schreiner", version="2.00", name="ThroDetent/Beep"}