--[[ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ]] local lGname = "ScreenSize" local function printTelem2(w,h) lcd.setColor(0,0,0) lcd.drawText(10,10,w.."x"..h) a = math.floor(((system.getInputs("P5")+1)/2)*100) b = math.floor(((system.getInputs("P6")+1)/2)*100) lcd.setColor(255,0,0) lcd.drawText(10,30,300+a.."x"..140+b) lcd.drawRectangle(0,0,300+a,140+b) end local once = true local function printTelem(width, height) local w = width - 1 local h = height - 1 if (height > 159) then -- DC24 II w = width - 2 h = height - 25 end -- cross lcd.drawText(w / 2, h / 2, w .. " x " .. h .."px") lcd.drawText(w / 2, (h / 2) + 15, width.. " x " .. height .."px") lcd.drawLine(w / 2, 0, w / 2, h) lcd.drawLine(0, h / 2, w, h / 2) lcd.drawLine(0, 0, w, h) lcd.drawLine(0, h, w, 0) lcd.drawLine(0, 0, w, 0) lcd.drawLine(0, h, w, h) lcd.drawLine(0, 0, 0, h) lcd.drawLine(w, 0, w, h) local txTel = system.getTxTelemetry(); lcd.drawText(10,20,string.format("R %02.1fV Q%03u%% A1 %02u A2 %02u", txTel.rx1Voltage, txTel.rx1Percent, txTel.RSSI[1],txTel.RSSI[2])) if (once) then print(string.format("R %02.1fV Q%03u%% A1 %02u A2 %02u", txTel.rx1Voltage, txTel.rx1Percent, txTel.RSSI[1],txTel.RSSI[2])) once = false end end local function printForm(width, height) local w = width - 1 local h = height - 1 local y = 0 lcd.setColor(0,0,0) lcd.drawText(0, height - 20, width .."x" .. height .. "px") lcd.drawText(0, y, "NORM=" .. lcd.getTextWidth(FONT_NORMAL, "D") .. "," .. lcd.getTextHeight(FONT_NORMAL), FONT_NORMAL) y = y + lcd.getTextHeight(FONT_NORMAL) lcd.drawText(0, y, "MINI=" .. lcd.getTextWidth(FONT_MINI, "D") .. "," .. lcd.getTextHeight(FONT_MINI), FONT_MINI) y = y + lcd.getTextHeight(FONT_MINI) lcd.drawText(0, y, "BOLD=" .. lcd.getTextWidth(FONT_BOLD, "D") .. "," .. lcd.getTextHeight(FONT_BOLD), FONT_BOLD) y = y + lcd.getTextHeight(FONT_BOLD) lcd.drawText(0, y, "BIG =" .. lcd.getTextWidth(FONT_BIG, "D") .. "," .. lcd.getTextHeight(FONT_BIG), FONT_BIG) y = y + lcd.getTextHeight(FONT_BIG) lcd.drawText(0, y, "MAXI=" .. lcd.getTextWidth(FONT_MAXI, "D") .. "," .. lcd.getTextHeight(FONT_MAXI), FONT_MAXI) -- cross lcd.drawText(w / 2 + (4 * lcd.getTextWidth(FONT_NORMAL, "D")), h / 2, w.." x " .. h.."px") lcd.drawLine(w / 2, 0, w / 2, h) lcd.drawLine(0, h / 2, w, h / 2) lcd.drawLine(0, 0, w, h) lcd.drawLine(0, h, w, 0) lcd.drawLine(0, 0, w, 0) lcd.drawLine(0, h, w, h) lcd.drawLine(0, 0, 0, h) lcd.drawLine(w, 0, w, h) end local function init() system.setProperty("NativeDraw", 1) system.registerTelemetry(1, lGname, 5, printTelem) system.registerForm(1, MENU_MAIN, lGname, nil, nil, printForm) end collectgarbage() return {init=init, author="Pju", version="1.0", name=lGname}