-- ########################################################################################################################################################## -- # Switch57 V1.1 # -- # App zur Darstellung der Schalterbelegung # -- # Lua app f�r JETI DS12, DC16-2, DS/DC24 Sender # -- ########################################################################################################################################################## -- ########################################################################################################################################################## -- # # -- # MIT License # -- # # -- # # -- # Copyright (c) 2021 Thorsten Tiedge # -- # ------------------------------------------------------------------------------------------------------------------------------------------------------ # -- # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), # -- # I to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, # -- # and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # -- # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. # -- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # -- # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE # -- # USE OR OTHER DEALINGS IN THE SOFTWARE. # -- # ------------------------------------------------------------------------------------------------------------------------------------------------------ # -- # Sinngem��e �bersetzung (nicht offiziell) # -- # Jedem, der eine Kopie dieser Software und der zugeh�rigen Dokumentationsdateien (die "Software") erh�lt, wird hiermit kostenlos die Erlaubnis erteilt, # -- # ohne Einschr�nkung mit der Software zu handeln, einschlie�lich und ohne Einschr�nkung der Rechte zur Nutzung, zum Kopieren, �ndern, Zusammenf�hren, # -- # Ver�ffentlichen, Verteilen, Unterlizenzieren und/oder Verkaufen von Kopien der Software, und Personen, denen die Software zur Verf�gung gestellt wird, # -- # dies unter den folgenden Bedingungen zu gestatten: # -- # Der obige Urheberrechtshinweis und dieser Genehmigungshinweis m�ssen in allen Kopien oder wesentlichen Teilen der Software enthalten sein. # -- # DIE SOFTWARE WIRD OHNE M�NGELGEW�HR UND OHNE JEGLICHE AUSDR�CKLICHE ODER STILLSCHWEIGENDE GEW�HRLEISTUNG, EINSCHLIE�LICH, ABER NICHT BESCHR�NKT AUF # -- # DIE GEW�HRLEISTUNG DER MARKTG�NGIGKEIT, DER EIGNUNG F�R EINEN BESTIMMTEN ZWECK UND DER NICHTVERLETZUNG VON RECHTEN DRITTER, ZUR VERF�GUNG GESTELLT. # -- # DIE AUTOREN ODER URHEBERRECHTSINHABER SIND IN KEINEM FALL HAFTBAR F�R ANSPR�CHE, SCH�DEN ODER ANDERE VERPFLICHTUNGEN, OB IN EINER VERTRAGS- ODER # -- # HAFTUNGSKLAGE, EINER UNERLAUBTEN HANDLUNG ODER ANDERWEITIG, DIE SICH AUS, AUS ODER IN VERBINDUNG MIT DER SOFTWARE ODER DER NUTZUNG ODER ANDEREN # -- # GESCH�FTEN MIT DER SOFTWARE ERGEBEN. # -- # # -- ########################################################################################################################################################## -- # 09.05.2021 modifikation Geni # -- # Neue Bilder DC24_Schalter_L.png und DC24_Schalter_R.png mit 9 Zeilen für Knüppel RC Technik # -- ########################################################################################################################################################## collectgarbage() --[[one -- nach unbeabsichtigten globalen Variablen suchen setmetatable(_G, { __newindex = function(array, key, value) print(string.format("Changed _G: %s = %s", tostring(key), tostring(value))); rawset(array, key, value); end }); --]] ------------------------------------------------------------------------------- local imageLA, imageRA, imageLB, imageRB local trans, model, device, controls, text, switch, value, name, formID, formCenterL, formCenterR, centerL, centerR, options, option, timeB2, timeB3, timeB4 local folder, imageExtensions, transName, transDefault, transExtension = "Apps/Switch57/", {".png", ".jpg"}, "Sw-", "Global", ".jsn" local option = 1 local function setLanguage() local locale = system.getLocale() trans = {} if (locale == 'de') then trans.switchlabeling = "Schalterbeschriftung" trans.toggle = "Ansicht Sender vorne/hinten" trans.centerupperleft = "Text links oben zentriert" trans.centerupperright = "Text rechts oben zentriert" trans.selectswitch = "Schalter auswählen" trans.label = "Beschriftung" elseif (locale == 'it') then trans.switchlabeling = "Etichettatura interruttori" trans.toggle = "Vista trasmettitore davanti/indietro" trans.centerupperleft = "Testo centrato in alto a sinistra" trans.centerupperright = "Testo centrato in alto a destra" trans.selectswitch = "Seleziona interruttore" trans.label = "Etichettatura" elseif (locale == 'es') then trans.switchlabeling = "Nombre interruptor" trans.toggle = "Vista transmisora enfrente/atrás" trans.centerupperleft = "Texto izquierda arriba central" trans.centerupperright = "Texto derecha arriba central" trans.selectswitch = "Selección de interruptor" trans.label = "Nombre" else trans.switchlabeling = "Switch labeling" trans.toggle = "Toggle front/back view" trans.centerupperleft = "Center upper left text" trans.centerupperright = "Center upper right text" trans.selectswitch = "Select switch" trans.label = "Label" end end -------------------------------------------------------------------------------- -- Read translations local function loadModel(default) local model = model:gsub("[^\32-\126]", "") local file if (not default) then file = io.readall(folder..transName..model..transExtension) end if (not file) then file = io.readall(folder..transName..transDefault..transExtension) end controls = json.decode(file) text = controls[options[option]] end ------------------------------------------------------------------------------- local function saveModel(default) local text = json.encode(controls) local model = model:gsub("[^\32-\126]", "") local file if (not default) then file = io.open(folder..transName..model..transExtension, "w") end if (not file) then file = io.open(folder..transName..transDefault..transExtension, "w") end io.write(file, text) io.close(file) end ------------------------------------------------------------------------------- local function initModel() loadModel(true ) saveModel(false) end ------------------------------------------------------------------------------- local function loadImage(file) for _, extension in ipairs(imageExtensions) do local image = lcd.loadImage(folder..file..extension) if (image) then return image end end end ------------------------------------------------------------------------------- local function drawPageLA(width, height) local font if (device == "JETI DC-24" or device == "JETI DC-16 II") then if (imageLA == nil) then imageLA = loadImage("DC24_Schalter_L") end if (imageLA) then lcd.drawImage(0, 0, imageLA) end lcd.setColor(190, 196, 223) font = FONT_BOLD lcd.drawText(30, 3, controls.L1, font) lcd.drawText(30, 20, controls.SD, font) lcd.drawText(30, 36, controls.SA, font) lcd.drawText(30, 52, controls.SB, font) lcd.drawText(30, 70, controls.G6, font) lcd.drawText(30, 86, controls.SC, font) lcd.drawText(30, 103, controls.SK, font) --- Knüppelschalter lcd.drawText(30, 120, controls.SE, font) --- für Küppelschalter geopfert lcd.drawText(30, 137, controls.G8, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-24") then if (imageLA == nil) then imageLA = loadImage("DS24_Schalter_L") end if (imageLA) then lcd.drawImage(0, 0, imageLA) end font = FONT_BOLD lcd.setColor(190, 196, 223) lcd.drawText(45, 4, controls.SB, font) lcd.drawText(45, 26, controls.SA, font) lcd.drawText(45, 48, controls.SC, font) lcd.drawText(45, 70, controls.G6, font) lcd.drawText(45, 92, controls.SD, font) lcd.drawText(45, 114, controls.SI, font) lcd.drawText(45, 137, controls.G8, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-12") then if (imageLA == nil) then imageLA = loadImage("DS12_Schalter_L") end if (imageLA) then lcd.drawImage(0, 0, imageLA) end font = FONT_BOLD lcd.setColor(190, 196, 223) lcd.drawText(45, 4, controls.SC, font) lcd.drawText(45, 26, controls.SA, font) lcd.drawText(45, 48, controls.SB, font) lcd.drawText(45, 70, controls.G6, font) lcd.drawText(45, 92, controls.SI, font) lcd.drawText(45, 114, controls.G8, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-16 II") then if (imageLA == nil) then imageLA = loadImage("DS24_Schalter_L") end if (imageLA) then lcd.drawImage(0, 0, imageLA) end font = FONT_BOLD lcd.setColor(190, 196, 223) lcd.drawText(45, 4, controls.SB, font) lcd.drawText(45, 26, controls.SA, font) lcd.drawText(45, 48, controls.SC, font) lcd.drawText(45, 70, controls.G6, font) lcd.drawText(45, 92, controls.SD, font) lcd.drawText(45, 114, controls.SI, font) lcd.drawText(45, 137, controls.G8, font) lcd.setColor(0, 0, 0) end end ------------------------------------------------------------------------------- local function drawPageLB(width, height) local font if (device == "JETI DC-24" or device == "JETI DC-16 II") then if (imageLB == nil) then imageLB = loadImage("DC_Schalter_L_RS") end if (imageLB) then lcd.drawImage(0 , 0, imageLB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerL) then lcd.drawText(100 - (lcd.getTextWidth(font,controls.L1) / 2), 4, controls.L1, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L2) / 2), 26, controls.L2, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L3) / 2), 48, controls.L3, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L4) / 2), 70, controls.L4, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L5) / 2), 92, controls.L5, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L6) / 2), 114, controls.L6, font) else lcd.drawText(4, 4, controls.L1, font) lcd.drawText(4, 26, controls.L2, font) lcd.drawText(4, 48, controls.L3, font) lcd.drawText(4, 70, controls.L4, font) lcd.drawText(4, 92, controls.L5, font) lcd.drawText(4, 114, controls.L6, font) end lcd.setColor(190, 196, 223) lcd.drawText(45, 137, controls.SK, font) elseif (device == "JETI DS-24") then if (imageLB == nil) then imageLB = loadImage("DS24_Schalter_L_RS") end if (imageLB) then lcd.drawImage(0, 0, imageLB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerL) then lcd.drawText(100 - (lcd.getTextWidth(font,controls.L1) / 2), 4, controls.L1, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L2) / 2), 26, controls.L2, font) lcd.drawText(100 - (lcd.getTextWidth(font,controls.L3) / 2), 48, controls.L3, font) else lcd.drawText(4, 4, controls.L1, font) lcd.drawText(4, 26, controls.L2, font) lcd.drawText(4, 48, controls.L3, font) end lcd.setColor(190, 196, 223) lcd.drawText(45, 70, controls.SJ, font) lcd.drawText(45, 92, controls.G9, font) lcd.drawText(45, 114, controls.SM, font) lcd.drawText(45, 137, controls.SO, font) elseif (device == "JETI DS-12") then if (imageLB == nil) then imageLB = loadImage("DS12_Schalter_L_RS") end if (imageLB) then lcd.drawImage(0, 0, imageLB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerL) then lcd.drawText(100 - (lcd.getTextWidth(font, controls.L1) / 2), 4, controls.L1, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L2) / 2), 26, controls.L2, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L3) / 2), 48, controls.L3, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L4) / 2), 70, controls.L4, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L5) / 2), 92, controls.L5, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L6) / 2), 114, controls.L6, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L7) / 2), 137, controls.L7, font) else lcd.drawText(4, 4, controls.L1, font) lcd.drawText(4, 26, controls.L2, font) lcd.drawText(4, 48, controls.L3, font) lcd.drawText(4, 70, controls.L4, font) lcd.drawText(4, 92, controls.L5, font) lcd.drawText(4, 114, controls.L6, font) lcd.drawText(4, 137, controls.L7, font) end elseif (device == "JETI DS-16 II") then if (imageLB == nil) then imageLB = loadImage("DS16_Schalter_L_RS") end if (imageLB) then lcd.drawImage(0, 0, imageLB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerL) then lcd.drawText(100 - (lcd.getTextWidth(font, controls.L1) / 2), 4, controls.L1, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L2) / 2), 26, controls.L2, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L3) / 2), 48, controls.L3, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L4) / 2), 70, controls.L4, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L5) / 2), 92, controls.L5, font) lcd.drawText(100 - (lcd.getTextWidth(font, controls.L6) / 2), 114, controls.L6, font) else lcd.drawText(4, 4, controls.L1, font) lcd.drawText(4, 26, controls.L2, font) lcd.drawText(4, 48, controls.L3, font) lcd.drawText(4, 70, controls.L4, font) lcd.drawText(4, 92, controls.L5, font) lcd.drawText(4, 114, controls.L6, font) end lcd.setColor(190, 196, 223) lcd.drawText(45, 137, controls.SJ, font) end end ------------------------------------------------------------------------------- local function drawPageRA(width, height) local font if (device == "JETI DC-24" or device == "JETI DC-16 II") then if (imageRA == nil) then imageRA = loadImage("DC24_Schalter_R") end if (imageRA) then lcd.drawImage(0, 0, imageRA) end lcd.setColor(190, 196, 223) font = FONT_BOLD lcd.drawText(287 - lcd.getTextWidth(font, controls.SG), 3, controls.SG, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.SH), 20, controls.SH, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.SJ), 36, controls.SJ, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.SI), 52, controls.SI, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.G5), 70, controls.G5, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.G7), 86, controls.G7, font) lcd.drawText(287 - lcd.getTextWidth(font, controls.L2), 103, controls.L2, font) --- Knüppelschalter oben Sl lcd.drawText(287 - lcd.getTextWidth(font, controls.SL), 120, controls.SL, font) --- Knüppelschalter unter Sl lcd.drawText(287 - lcd.getTextWidth(font, controls.SF), 137, controls.SF, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-24") then if (imageRA == nil) then imageRA = loadImage("DS24_Schalter_R") end if (imageRA) then lcd.drawImage(0, 0, imageRA) end lcd.setColor(190, 196, 223) font = FONT_BOLD lcd.drawText(272 - lcd.getTextWidth(font, controls.SG), 4, controls.SG, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SH), 26, controls.SH, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SF), 48, controls.SF, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G5), 70, controls.G5, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SE), 92, controls.SE, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SK), 114, controls.SK, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G7), 137, controls.G7, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-12") then if (imageRA == nil) then imageRA = loadImage("DS12_Schalter_R") end if (imageRA) then lcd.drawImage(0, 0, imageRA) end lcd.setColor(190, 196, 223) font = FONT_BOLD lcd.drawText(272 - lcd.getTextWidth(font, controls.SD), 4, controls.SD, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SF), 26, controls.SF, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SE), 48, controls.SE, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G5), 70, controls.G5, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SK), 92, controls.SK, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G7), 114, controls.G7, font) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-16 II") then if (imageRA == nil) then imageRA = loadImage("DS24_Schalter_R") end if (imageRA) then lcd.drawImage(0, 0, imageRA) end lcd.setColor(190, 196, 223) font = FONT_BOLD lcd.drawText(272 - lcd.getTextWidth(font, controls.SG), 4, controls.SG, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SH), 26, controls.SH, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SF), 48, controls.SF, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G5), 70, controls.G5, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SE), 92, controls.SE, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SK), 114, controls.SK, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G7), 137, controls.G7, font) lcd.setColor(0, 0, 0) end end ------------------------------------------------------------------------------- local function drawPageRB(width, height) local font if (device == "JETI DC-24" or device == "JETI DC-16 II") then if (imageRB == nil) then imageRB = loadImage("DC_Schalter_R_RS") end if (imageRB) then lcd.drawImage(0, 0, imageRB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerR) then lcd.drawText(217 - (lcd.getTextWidth(font, controls.R1) / 2), 4, controls.R1, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R2) / 2), 26, controls.R2, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R3) / 2), 48, controls.R3, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R4) / 2), 70, controls.R4, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R5) / 2), 92, controls.R5, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R6) / 2), 114, controls.R6, font) else lcd.drawText(313 - (lcd.getTextWidth(font, controls.R1)), 4, controls.R1, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R2)), 26, controls.R2, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R3)), 48, controls.R3, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R4)), 70, controls.R4, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R5)), 92, controls.R5, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R6)), 114, controls.R6, font) end lcd.setColor(190, 196, 223) lcd.drawText(272 - lcd.getTextWidth(FONT_BOLD, controls.SL), 137, controls.SL, FONT_BOLD) lcd.setColor(0, 0, 0) elseif (device == "JETI DS-24") then if (imageRB == nil) then imageRB = loadImage("DS24_Schalter_R_RS") end if (imageRB) then lcd.drawImage(0, 0, imageRB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerR) then lcd.drawText(217 - (lcd.getTextWidth(font, controls.R1) / 2), 4, controls.R1, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R2) / 2), 26, controls.R2, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R3) / 2), 48, controls.R3, font) else lcd.drawText(313 - (lcd.getTextWidth(font, controls.R1)), 4, controls.R1, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R2)), 26, controls.R2, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R3)), 48, controls.R3, font) end lcd.setColor(255, 255, 255) lcd.drawText(272 - lcd.getTextWidth(font, controls.SL ), 70, controls.SL, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.G10), 92, controls.G10, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SN ), 114, controls.SN, font) lcd.drawText(272 - lcd.getTextWidth(font, controls.SP ), 137, controls.SP, font) elseif (device == "JETI DS-12") then if (imageRB == nil) then imageRB = loadImage("DS12_Schalter_R_RS") end if (imageRB) then lcd.drawImage(0, 0, imageRB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerR) then lcd.drawText(217 - (lcd.getTextWidth(font, controls.R1) / 2), 4, controls.R1, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R2) / 2), 26, controls.R2, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R3) / 2), 48, controls.R3, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R4) / 2), 70, controls.R4, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R5) / 2), 92, controls.R5, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R6) / 2), 114, controls.R6, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R7) / 2), 137, controls.R7, font) else lcd.drawText(313 - (lcd.getTextWidth(font, controls.R1)), 4, controls.R1, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R2)), 26, controls.R2, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R3)), 48, controls.R3, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R4)), 70, controls.R4, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R5)), 92, controls.R5, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R6)), 114, controls.R6, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R7)), 137, controls.R7, font) end lcd.setColor(0, 0, 0) elseif (device == "JETI DS-16 II") then if (imageRB == nil) then imageRB = loadImage("DS16_Schalter_R_RS") end if (imageRB) then lcd.drawImage(0, 0, imageRB) end lcd.setColor(255, 190, 96) font = FONT_BOLD if (centerR) then lcd.drawText(217 - (lcd.getTextWidth(font, controls.R1) / 2), 4, controls.R1, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R2) / 2), 26, controls.R2, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R3) / 2), 48, controls.R3, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R4) / 2), 70, controls.R4, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R5) / 2), 92, controls.R5, font) lcd.drawText(217 - (lcd.getTextWidth(font, controls.R6) / 2), 114, controls.R6, font) else lcd.drawText(313 - (lcd.getTextWidth(font, controls.R1)), 4, controls.R1, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R2)), 26, controls.R2, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R3)), 48, controls.R3, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R4)), 70, controls.R4, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R5)), 92, controls.R5, font) lcd.drawText(313 - (lcd.getTextWidth(font, controls.R6)), 114, controls.R6, font) end lcd.setColor(190, 196, 223) lcd.drawText(272 - lcd.getTextWidth(FONT_BOLD, controls.SJ), 137, controls.SJ, FONT_BOLD) lcd.setColor(0, 0, 0) end end -------------------------------------------------------------------------------------------------------Telemetriefenster 1 local function drawPageL(width, height) local method = value == 1 and drawPageLB or drawPageLA return method(width, height) end -- ---------------------------------------------------------------------------------------------------Telemetriefenster 2 local function drawPageR(width, height) local method = value == 1 and drawPageRB or drawPageRA return method(width, height) end -------------------------------------------------------------------------------- local function initForm(subform) form.setButton(1, ":tools", HIGHLIGHTED) form.setButton(2, ":file", timeB2 and HIGHLIGHTED or ENABLED) form.setButton(3, ":refresh", timeB3 and HIGHLIGHTED or ENABLED) --- hier muss geladen werden form.setButton(4, ":edit", timeB4 and HIGHLIGHTED or ENABLED) --- hier muss gespeichert werden formID = subform form.addRow(2) form.addLabel({label=trans.toggle, width=260}) form.addInputbox(switch, true, function(value) switch = value system.pSave("switch", value) end) form.addRow(2) form.addLabel({label=trans.centerupperleft, width=275}) formCenterL = form.addCheckbox(centerL, function(value) centerL = not value system.pSave("centerL", centerL and 1 or 0) form.setValue(formCenterL, centerL) end) form.addRow(2) form.addLabel({label=trans.centerupperright, width=275}) formCenterR = form.addCheckbox(centerR, function(value) centerR = not value system.pSave("centerR", centerR and 1 or 0) form.setValue(formCenterR, centerR) end) form.addLabel({label=trans.switchlabeling, font=FONT_BOLD}) form.addRow(2) form.addLabel({label=trans.selectswitch, width=250}) form.addSelectbox(options, option, true, function(value) option = value text = controls[options[option]] form.reinit(formID) end) form.addRow(2) form.addLabel({label=trans.label}) form.addTextbox(text, 25, function(value) text = value controls[options[option]] = text end) end -------------------------------------------------------------------------------- local function loop() value = system.getInputsVal(switch) if (timeB2 or timeB3 or timeB4) then local time = system.getTimeCounter() local limit = 1000 if (timeB2 and time - timeB2 > limit) then timeB2 = nil form.setButton(2, ":file", ENABLED) end if (timeB3 and time - timeB3 > limit) then timeB3 = nil form.setButton(3, ":refresh", ENABLED) end if (timeB4 and time - timeB4 > limit) then timeB4 = nil form.setButton(4, ":edit", ENABLED) end end end -------------------------------------------------------------------------------- local function keyForm(key) if (key == KEY_1 and formID ~= 1) then form.reinit(1) elseif (key == KEY_2) then timeB2 = system.getTimeCounter() initModel() form.reinit(formID) elseif (key == KEY_3) then timeB3 = system.getTimeCounter() loadModel() form.reinit(formID) elseif (key == KEY_4) then timeB4 = system.getTimeCounter() saveModel() form.reinit(formID) end end -------------------------------------------------------------------------------- local function init(code) local pLoad, registerForm, registerTelemetry = system.pLoad, system.registerForm, system.registerTelemetry model = system.getProperty("Model") device = system.getDeviceType() switch = system.pLoad("switch") centerL = pLoad("centerL", 0) == 1 centerR = pLoad("centerR", 0) == 1 options = {"SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SP", "L1", "L2", "L3", "L4", "L5", "L6", "L7", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "G5", "G6", "G7", "G8", "G9", "G10"} loadModel() registerForm(1, MENU_MAIN, "Switch57", initForm, keyForm) registerTelemetry(1, "Switch57 "..model.." left" , 4, drawPageL) registerTelemetry(2, "Switch57 "..model.." right", 4, drawPageR) collectgarbage() end -------------------------------------------------------------------------------- setLanguage() collectgarbage() return {init=init, loop=loop, author="Thorn/Lowpass", version="1.1", name="Switch57"}