-- Sticktraining --------------- local appName="Sticktraining" local switch local Empfindlichkeit local Grenzwertmax local rechts = 0 local links = 0 local playedFileTR local playedFileTL local value local version = "1.1" -------------- local function initForm(formID) --form.addLabel({label="Sticktraining",font=2}) form.addRow(2) form.addLabel({label="Schalter zum aktivieren:"}) form.addInputbox(switch,true, function(value) switch=value;system.pSave("switch",value); end ) form.addRow(2) form.addLabel({label="Signal rechts:"}) form.addAudioFilebox(playedFileTR, function(value) playedFileTR=value; system.pSave("fileTR",value); end) form.addRow(2) form.addLabel({label="Signal links:"}) form.addAudioFilebox(playedFileTL, function(value) playedFileTL=value; system.pSave("fileTL",value); end) form.addRow(2) form.addLabel({label="Empfindlichkeit:"}) form.addIntbox(Empfindlichkeit,1,100,0,0,1,function(value) Empfindlichkeit=value; system.pSave("Empfindlichkeit",value); end) form.addRow(2) form.addLabel({label="Grenzwert max:"}) form.addIntbox(Grenzwertmax,1,100,0,0,1,function(value) Grenzwertmax=value; system.pSave("Grenzwertmax",value); end) form.addRow(1) form.addLabel({label="Designd by dit71 - v."..version, font=FONT_MINI, alignRight=true}) end -- Init function local function init() playedFileTR = system.pLoad("fileTR","") playedFileTL = system.pLoad("fileTL","") switch = system.pLoad("switch") Empfindlichkeit = system.pLoad("Empfindlichkeit",1) Grenzwertmax = system.pLoad("Grenzwertmax",20) system.registerForm(1,MENU_APPS,appName,initForm,keyPressed,printForm) end -------------- -- Loop function local function loop() local val = system.getInputsVal(switch) --print(val) if(val and val>0) then local P1,P2,P3,P4 = system.getInputs("P1","P2","P3","P4") P1=math.abs(P1)*100 P2=math.abs(P2)*100 P3=math.abs(P3)*100 P4=math.abs(P4)*100 if P1 > 98 then rechts = 1 end if P2 > 98 then rechts = 2 end if P3 > 98 then links = 3 end if P4 > 98 then links = 4 end if rechts == 1 then -- print(P2) if Empfindlichkeit < P2 and Grenzwertmax > P2 then system.playFile(playedFileTR,AUDIO_IMMEDIATE) -- print("oje1") end end if rechts == 2 then if Empfindlichkeit < P1 and Grenzwertmax > P1 then system.playFile(playedFileTR,AUDIO_IMMEDIATE) -- print("oje2") end end if links == 3 then if Empfindlichkeit < P4 and Grenzwertmax > P4 then system.playFile(playedFileTL,AUDIO_IMMEDIATE) -- print("oje3") end end if links == 4 then if Empfindlichkeit < P3 and Grenzwertmax > P3 then system.playFile(playedFileTL,AUDIO_IMMEDIATE) -- print("oje4") end end --print(P1,P2,P3,P4) end end ----------------- return { init=init, loop=loop, author="dit71", version=version,name=appName}