local appName = "BT_Gain" -- virtuelle Geber-Indizes local ctrlIdxA, ctrlIdxB, ctrlIdxC -- SwitchItem (Poti) – wird in der Konfig-Form ausgewählt und geladen/gespeichert local inputSwitch = nil local KEY_INPUT = "BT_Gain_input" -- Basiswerte in Prozent (0–100) und ihre Persistenz-Keys local baseVarioPct = 35 local baseBeepPct = 50 local basePlayerPct = 100 local KEY_VARIO = "BT_Gain_vario" local KEY_BEEP = "BT_Gain_beep" local KEY_PLAYER = "BT_Gain_player" -------------------------------------------------------------------- -- Loop-Funktion mit dynamischem Poti und echter Null-Schwelle local function loop() local raw = system.getInputsVal(inputSwitch) or 0 local scaled = (raw + 1) / 2 if scaled < 0.05 then scaled = 0 end if ctrlIdxA then local outA = scaled * (baseVarioPct / 100) * 2 - 1 system.setControl(1, outA, 0, 0) end if ctrlIdxB then local outB = scaled * (baseBeepPct / 100) * 2 - 1 system.setControl(2, outB, 0, 0) end if ctrlIdxC then local outC = scaled * (basePlayerPct / 100) * 2 - 1 system.setControl(3, outC, 0, 0) end end -------------------------------------------------------------------- -- Formular zum Konfigurieren und Speichern local function initForm() form.setTitle(appName) -- Poti-Auswahl über Inputbox form.addRow(2) form.addLabel({ label = "Eingangs-Poti" }) form.addInputbox( inputSwitch, true, -- proportionale Controls erlauben function(v) inputSwitch = v system.pSave(KEY_INPUT, v) -- speichern end ) -- Basis Vario form.addRow(2) form.addLabel({ label = "Basis Vario [%]" }) form.addIntbox( baseVarioPct, 0, 100, baseVarioPct, 0, 1, function(v) baseVarioPct = v system.pSave(KEY_VARIO, v) end ) -- Basis Beep form.addRow(2) form.addLabel({ label = "Basis Beep [%]" }) form.addIntbox( baseBeepPct, 0, 100, baseBeepPct, 0, 1, function(v) baseBeepPct = v system.pSave(KEY_BEEP, v) end ) -- Basis Player form.addRow(2) form.addLabel({ label = "Basis Player [%]" }) form.addIntbox( basePlayerPct, 0, 100, basePlayerPct,0, 1, function(v) basePlayerPct = v system.pSave(KEY_PLAYER, v) end ) end -------------------------------------------------------------------- -- Init: Laden aller Parameter, Registrieren von Controls & Form local function init() -- persistente Werte laden (vor loop) inputSwitch = system.pLoad(KEY_INPUT, inputSwitch) baseVarioPct = system.pLoad(KEY_VARIO, baseVarioPct) baseBeepPct = system.pLoad(KEY_BEEP, baseBeepPct) basePlayerPct = system.pLoad(KEY_PLAYER, basePlayerPct) -- virtuelle Geber registrieren ctrlIdxA = system.registerControl(1, "Gain Vario", "GVA") ctrlIdxB = system.registerControl(2, "Gain Beep", "GBE") ctrlIdxC = system.registerControl(3, "Gain Player", "GPL") -- Formular unter Modell → Anwendungen einbinden system.registerForm(1, MENU_APPS, appName, initForm) -- erste Kompilierung in Bytecode (.lc) -- system.compile() ...ist noch ausgeblendet... end -------------------------------------------------------------------- -- App-Interface return { init = init, loop = loop, author = "wsTech ChatGPT MT", version = "1.0", name = appName }