--[[ telemetry screen for sail boat by antoine froment Version 1.0 - August 2014 ]] local function vgauge(vx, vy, vw, vh, vfill, vmaxfill) --draw border lcd.drawRectangle(vx, vy ,vw, vh) -- calculate height local vlen = vh * vfill / vmaxfill local vheight = vy + ( vh - vlen) -- dont go negative if vlen < 2 then vlen = 2 end --draw fill inside border lcd.drawFilledRectangle(vx + 1, vheight + 1, vw - 2,vlen - 2, 0) end local function run(event) -- display A1 lcd.drawChannel(128, 5, 202, LEFT+XXLSIZE) -- calculating percent A1 lipo2s -- formula for lipo 2S %=(T-7,1068)/0,0118 -- formula for lipo 3S %=(T-10,6602)/0,0177 -- formula for lipo 4S %=(T-14,2136)/0,0236 -- formula for lipo 5S %=(T-17.767)/0,0295 local percent1 = (getValue(202)-7.1068)/0.0118 if percent1 < 0 then percent1 = 0 end -- display percent on gauge lcd.drawNumber(100, 50, percent1, MIDSIZE) lcd.drawText(lcd.getLastPos(), 53, "%", SMLSIZE) -- gauge for A1 lcd.drawGauge(5, 49, 200, 14, percent1, 100) -- display tx-voltage lcd.drawChannel(3, 5, "tx-voltage", LEFT+MIDSIZE) -- calculating percent tx voltage local settings = getGeneralSettings() local percent2 = (getValue("tx-voltage")-settings.battMin) * 100 / (settings.battMax-settings.battMin) -- display percent on gauge tx-voltage lcd.drawNumber(76, 6, percent2, MIDSIZE) lcd.drawText(lcd.getLastPos(), 7, "%", SMLSIZE) -- display gauge for tx voltage lcd.drawGauge(30, 7, 79, 14, percent2, 100) -- formatting rssi in variable local rssi = (getValue(200)) -- display Rssi text lcd.drawText(7, 26, "Rx", MIDSIZE) -- display RSSI value lcd.drawNumber(78, 27, rssi, MIDSIZE) -- display RSSI gauge lcd.drawGauge(30, 26, 79, 14, getValue(200), 100) -- display cursor for throttle stick position lcd.drawRectangle(206, 2, 5, 60, ROUND) vgauge(206, 2, 5, 59, getValue(77)+1024, 2048) vgauge(206, 2, 5, 59, getValue(77)+924, 2048) end return { run=run }