local appName = "Assist Gyroempf. der 3 Achsen" local controls = system.getDeviceType() == "JETI DC-24" and 10 or 4 local switch, poti local ctrl1, ctrl2, ctrl3 local channel1, channel2, channel3 local lastG1, lastG2, lastG3 = 0, 0, 0 local lastS local function initForm(subform) form.addRow(2) form.addLabel({label="Schalter", width=240}) form.addInputbox(switch, true, function(value) switch=value system.pSave("switch",value) end) form.addRow(2) form.addLabel({label="POTI", width=240}) form.addInputbox(poti, true, function(value) poti=value system.pSave("poti",value) end) form.addRow(2) form.addLabel({label="Box 1", width=160}) form.addIntbox(channel1, 1, controls, 1, 0, 1, function(value) channel1=value system.pSave("channel1",value) end) form.addRow(2) form.addLabel({label="Box 2", width=160}) form.addIntbox(channel2, 1, controls, 2, 0, 1, function(value) channel2=value system.pSave("channel2",value) end) form.addRow(2) form.addLabel({label="Box 3", width=160}) form.addIntbox (channel3, 1, controls, 3, 0, 1, function(value) channel3=value system.pSave("channel3",value) end) end -- Init function local function init() switch = system.pLoad("switch") poti = system.pLoad("poti") channel1 = system.pLoad("channel1", 1) channel2 = system.pLoad("channel2", 2) channel3 = system.pLoad("channel3", 3) ctrl1 = system.registerControl(channel1, "Gyro-Empfindlichkeit 1", "G1") ctrl2 = system.registerControl(channel2, "Gyro-Empfindlichkeit 2", "G2") ctrl3 = system.registerControl(channel3, "Gyro-Empfindlichkeit 3", "G3") system.registerForm(1,MENU_ADVANCED,appName,initForm) end -- Loop function local function loop() local valS = system.getInputsVal(switch) local valP = system.getInputsVal(poti) if (valS and valP) then if (not lastS or lastS ~= valS) then local value = 0 if (valS == -1) then value = lastG1 elseif (valS == 0) then value = lastG2 elseif (valS == 1) then value = lastG3 end if (math.abs(valP - value) > 0.04) then return end system.playBeep(0, 4000, 250) end if (valS == -1) then lastG1 = valP system.setControl(ctrl1, valP, 0, 0) elseif (valS == 0) then lastG2 = valP system.setControl(ctrl2, valP, 0, 0) elseif (valS == 1) then lastG3 = valP system.setControl(ctrl3, valP, 0, 0) end lastS = valS end end return { init=init, loop=loop, author="Thorn fuers JetiForum.de", version="1.00",name=appName}