-- 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.0" -------------- 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*100,1,100,0,0,1,function(value) Empfindlichkeit=value/100;system.pSave("Empfindlichkeit",value/100); end) form.addRow(2) form.addLabel({label="Grenzwert max:"}) form.addIntbox(Grenzwertmax*100,1,100,0,0,1,function(value) Grenzwertmax=value/100;system.pSave("Grenzwertmax",value/100); 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",0.01) Grenzwertmax = system.pLoad("Grenzwertmax",0.2) 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") if math.abs(P1) > 0.98 then rechts = 1 end if math.abs(P2) > 0.98 then rechts = 2 end if math.abs(P3) > 0.98 then links = 3 end if math.abs(P4) > 0.98 then links = 4 end if rechts == 1 then print(P2) if Empfindlichkeit < math.abs(P2) and Grenzwertmax > math.abs(P2)then system.playFile(playedFileTR,AUDIO_IMMEDIATE) print("oje1") end end if rechts == 2 then if Empfindlichkeit < math.abs(P1) and Grenzwertmax > math.abs(P1)then system.playFile(playedFileTR,AUDIO_IMMEDIATE) print("oje2") end end if links == 3 then if Empfindlichkeit < math.abs(P4) and Grenzwertmax > math.abs(P4)then system.playFile(playedFileTL,AUDIO_IMMEDIATE) print("oje3") end end if links == 4 then if Empfindlichkeit < math.abs(P3) and Grenzwertmax > math.abs(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}