-------------------------------------------------------------------------------- -- Locals for the application local lastTime = 0 local filename = "Motoraus.wav" local Switch, Delay -------------------------------------------------------------------------------- -- Store settings when changed by user local function SwitchChanged(value) Switch = value system.pSave("Switch", Switch) end local function onDelayChanged(value) Delay = value system.pSave("Delay",Delay) end local function checkClicked(value) show = not value form.setValue(componentIndex, show) if show then system.pSave("CBox", 1) else system.pSave("CBox", 0) end end -------------------------------------------------------------------------------- -- Setup local function initForm(subform) form.addRow(2) form.addLabel({label="Motor-AUS Schalter",width=250}) form.addInputbox(Switch, true, SwitchChanged) form.addRow(2) form.addLabel({label= "Wiederholung der Warnung [s]",width=250}) form.addIntbox(Delay,0,32767,0,0,1,onDelayChanged) form.addRow(2) form.addLabel({label="Checkbox Motor-AUS",width=270}) componentIndex = form.addCheckbox(sow,checkClicked) end --------------------------------------------------------------------------------- -- Runtime functions local function loop() -- Differenzzeit berechnen local newTime = system.getTimeCounter() Sw_Int_val = system.getInputsVal(Switch) if (Sw_Int_val == 1) and (newTime > (lastTime + Delay * 1000)) then lastTime = newTime system.playFile(filename, AUDIO_BACKGROUND) if show then system.messageBox("Motor-AUS", 1) end end end ------------------------------------------------------------------------- -- Application initialization local function init() local value lastTime = system.getTimeCounter() Switch = system.pLoad("Switch") Delay = system.pLoad("Delay",10) value = system.pLoad("CBox", 1) if value == 1 then show = true else show = false end system.registerForm(1,MENU_APPS,"Setup Motor-AUS Warnung",initForm) end -------------------------------------------------------------------------------- return {init=init, loop=loop, author="user", version="0.3", name= "MotAusWarn"}