├── BMP ├── RSSIh00.bmp ├── RSSIh01.bmp ├── RSSIh02.bmp ├── RSSIh03.bmp ├── RSSIh04.bmp ├── RSSIh05.bmp ├── RSSIh06.bmp ├── RSSIh07.bmp ├── RSSIh08.bmp ├── RSSIh09.bmp ├── RSSIh10.bmp ├── battery.bmp ├── check.bmp ├── dist.bmp ├── fm.bmp ├── gps_0.bmp ├── gps_1.bmp ├── gps_2.bmp ├── gps_3.bmp ├── gps_4.bmp ├── gps_5.bmp ├── gps_6.bmp ├── hgt.bmp ├── home.bmp ├── sat.bmp ├── sat0.bmp ├── sat1.bmp ├── sat2.bmp ├── sat3.bmp ├── speed.bmp └── timer_1.bmp ├── README.md ├── example.otx ├── incrsf.lua └── screenshot.png /BMP/RSSIh00.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh00.bmp -------------------------------------------------------------------------------- /BMP/RSSIh01.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh01.bmp -------------------------------------------------------------------------------- /BMP/RSSIh02.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh02.bmp -------------------------------------------------------------------------------- /BMP/RSSIh03.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh03.bmp -------------------------------------------------------------------------------- /BMP/RSSIh04.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh04.bmp -------------------------------------------------------------------------------- /BMP/RSSIh05.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh05.bmp -------------------------------------------------------------------------------- /BMP/RSSIh06.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh06.bmp -------------------------------------------------------------------------------- /BMP/RSSIh07.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh07.bmp -------------------------------------------------------------------------------- /BMP/RSSIh08.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh08.bmp -------------------------------------------------------------------------------- /BMP/RSSIh09.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh09.bmp -------------------------------------------------------------------------------- /BMP/RSSIh10.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/RSSIh10.bmp -------------------------------------------------------------------------------- /BMP/battery.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/battery.bmp -------------------------------------------------------------------------------- /BMP/check.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/check.bmp -------------------------------------------------------------------------------- /BMP/dist.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/dist.bmp -------------------------------------------------------------------------------- /BMP/fm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/fm.bmp -------------------------------------------------------------------------------- /BMP/gps_0.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_0.bmp -------------------------------------------------------------------------------- /BMP/gps_1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_1.bmp -------------------------------------------------------------------------------- /BMP/gps_2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_2.bmp -------------------------------------------------------------------------------- /BMP/gps_3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_3.bmp -------------------------------------------------------------------------------- /BMP/gps_4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_4.bmp -------------------------------------------------------------------------------- /BMP/gps_5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_5.bmp -------------------------------------------------------------------------------- /BMP/gps_6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/gps_6.bmp -------------------------------------------------------------------------------- /BMP/hgt.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/hgt.bmp -------------------------------------------------------------------------------- /BMP/home.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/home.bmp -------------------------------------------------------------------------------- /BMP/sat.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/sat.bmp -------------------------------------------------------------------------------- /BMP/sat0.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/sat0.bmp -------------------------------------------------------------------------------- /BMP/sat1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/sat1.bmp -------------------------------------------------------------------------------- /BMP/sat2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/sat2.bmp -------------------------------------------------------------------------------- /BMP/sat3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/sat3.bmp -------------------------------------------------------------------------------- /BMP/speed.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/speed.bmp -------------------------------------------------------------------------------- /BMP/timer_1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/BMP/timer_1.bmp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # inav-telemscript 2 | Just a rewrite of an existing telemetry script which does IFR like display on a Taranis, to work with inav, crossfire and open-tx 2.2.x 3 | 4 | ![screenshot](https://github.com/tgreer/inav-telemscript/blob/master/screenshot.png) 5 | 6 | Install is a case of putting BMP folder and incrsf.lua in /SCRIPTS/TELEMTRY on your SD card and setting one of your telemetry screens to a script and selecting incrsf. 7 | -------------------------------------------------------------------------------- /example.otx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/example.otx -------------------------------------------------------------------------------- /incrsf.lua: -------------------------------------------------------------------------------- 1 | -- 2018 Thomas Greer - Modified for inav/crossfire 2 | -- 2017 John Ihlein - Modifed to work with Dronin flight firmware 3 | -- Copyright (c) 2015 dandys. 4 | -- Copyright (c) 2014 Marco Ricci. 5 | -- This program is free software: you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation, either version 3 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | -- A copy of the GNU General Public License is available at . 16 | -- 17 | -- Radar is based on Volke Wolkstein MavLink telemetry script 18 | -- https://github.com/wolkstein/MavLink_FrSkySPort 19 | 20 | 21 | -- Debug Flag 22 | local debug = 0 23 | 24 | -- Various local variables 25 | local X1, Y1, X2, Y2, XH, YH 26 | local delta, deltaX, deltaY 27 | 28 | local firstPass = 1 29 | local homeSet = 0 30 | local prevGpss = 0 31 | local runcounter = 0 32 | local firstrun = 1 33 | local gpsFirstRun = 1 34 | local rssi = 0 35 | 36 | local textualRow = 164 37 | 38 | local colAH = 51 39 | local rowAH = 32 40 | local radAH = 22 41 | local pitchR = radAH / 25 42 | local attAH = FORCE + GREY(6) 43 | local attBox = FORCE + GREY(0) 44 | 45 | local colAlt = colAH + 31 46 | local colSpeed = colAH - 31 47 | 48 | local colHeading = colAH 49 | local rowHeading = rowAH - radAH 50 | local rowDistance = rowAH + radAH + 3 51 | 52 | local homeShape = { 53 | { 0, -5, -4, 4}, 54 | {-4, 4, 0, 2}, 55 | { 0, 2, 4, 4}, 56 | { 4, 4, 0, -5} 57 | } 58 | 59 | local yaw, pitch, roll = 0, 0, 0 60 | local altitude, speed = 0, 0 61 | local heading, direction = 0, 0 62 | local latitude, longitude = 0, 0 63 | local homeLatitude, homeLongitude = 0, 0 64 | local sats, verticalSpeed, rssi, cellVoltage = 0, 0, 0, 0, 0, 0 65 | local isArmed = 0 66 | 67 | 68 | -- Calculated data 69 | local heading_from, heading_to, distance_2D = 0, 0, 0 70 | 71 | -- Working variables 72 | local z1, z2 73 | local pilotLat, sin_pilotLat, cos_pilotLat 74 | local currLat, sin_currLat, cos_currlat 75 | local cos_currLon_pilotLon 76 | 77 | -- ************ 78 | -- Draw a shape 79 | -- ************ 80 | 81 | local sinShape, cosShape 82 | 83 | local function drawShape(col, row, shape, rotation) 84 | sinShape = math.sin(rotation) 85 | cosShape = math.cos(rotation) 86 | 87 | for index, point in pairs(shape) do 88 | lcd.drawLine( 89 | col + (point[1] * cosShape - point[2] * sinShape), 90 | row + (point[1] * sinShape + point[2] * cosShape), 91 | col + (point[3] * cosShape - point[4] * sinShape), 92 | row + (point[3] * sinShape + point[4] * cosShape), 93 | SOLID, 94 | FORCE) 95 | end 96 | end 97 | 98 | -- *************** 99 | -- Draw an ellipse 100 | -- *************** 101 | 102 | local function drawEllipse( col, row, width, height ) 103 | X1 = col + width 104 | Y1 = row 105 | 106 | for i = 12, 360, 12 do 107 | X2 = col + (width * math.cos(math.rad(i))) 108 | Y2 = row + (height * math.sin(math.rad(i))) 109 | lcd.drawLine( X1, Y1, X2, Y2, SOLID, 0 ) 110 | X1 = X2 111 | Y1 = Y2 112 | end 113 | end 114 | 115 | 116 | 117 | -- *************** 118 | -- GPS Calculation 119 | -- *************** 120 | 121 | 122 | 123 | local function gpsCalculation() 124 | if homeSet == 0 then 125 | heading_from = 0 126 | heading_to = 0 127 | distance_2D = 0 128 | else 129 | pilotLat = math.rad(homeLatitude) 130 | sin_pilotLat = math.sin(pilotLat) 131 | cos_pilotLat = math.cos(pilotLat) 132 | 133 | currLat = math.rad(latitude) 134 | sin_currLat = math.sin(currLat) 135 | cos_currlat = math.cos(currLat) 136 | 137 | cos_currLon_pilotLon = math.cos(math.rad(longitude - homeLongitude)) 138 | 139 | -- Heading_from & heading_to calculation 140 | z1 = math.sin(math.rad(longitude - homeLongitude)) * cos_currlat 141 | z2 = cos_pilotLat * sin_currLat - sin_pilotLat * cos_currlat * cos_currLon_pilotLon 142 | heading_from = (math.deg(math.atan2(z1, z2))) % 360 143 | heading_to = (heading_from - 180) % 360 144 | 145 | -- Distance_2D calculation (Spherical Law of Cosines) 146 | distance_2D = 6371009 * math.acos(sin_pilotLat * sin_currLat + cos_pilotLat * cos_currlat * cos_currLon_pilotLon) 147 | end 148 | end 149 | 150 | 151 | 152 | -- *********************** 153 | -- Draw artificial horizon 154 | -- *********************** 155 | 156 | local tanRoll, cosRoll, sinRoll 157 | local dPitch_1, dPitch_2, mapRatio 158 | 159 | local function drawHorizon() 160 | dPitch_1 = pitch % 180 161 | 162 | if dPitch_1 > 90 then 163 | dPitch_1 = 180 - dPitch_1 164 | end 165 | 166 | cosRoll = math.cos(math.rad(roll == 90 and 89.99 or (roll == 270 and 269.99 or roll))) 167 | 168 | if pitch > 270 then 169 | dPitch_1 = -dPitch_1 * pitchR / cosRoll 170 | dPitch_2 = radAH / cosRoll 171 | elseif pitch > 180 then 172 | dPitch_1 = dPitch_1 * pitchR / cosRoll 173 | dPitch_2 = -radAH / cosRoll 174 | elseif pitch > 90 then 175 | dPitch_1 = -dPitch_1 * pitchR / cosRoll 176 | dPitch_2 = -radAH / cosRoll 177 | else 178 | dPitch_1 = dPitch_1 * pitchR / cosRoll 179 | dPitch_2 = radAH / cosRoll 180 | end 181 | 182 | tanRoll = -math.tan(math.rad(roll == 90 and 89.99 or (roll == 270 and 269.99 or roll))) 183 | 184 | for i = -radAH, radAH, 1 do 185 | YH = i * tanRoll 186 | Y1 = YH + dPitch_1 187 | 188 | if Y1 > radAH then 189 | Y1 = radAH 190 | elseif Y1 < -radAH then 191 | Y1 = -radAH 192 | end 193 | 194 | Y2 = YH + 1.5 * dPitch_2 195 | 196 | if Y2 > radAH then 197 | Y2 = radAH 198 | elseif Y2 < -radAH then 199 | Y2 = -radAH 200 | end 201 | 202 | X1 = colAH + i 203 | 204 | if Y1 < Y2 then 205 | lcd.drawLine(X1, rowAH + Y1, X1, rowAH + Y2, SOLID, attAH) 206 | elseif Y1 > Y2 then 207 | lcd.drawLine(X1, rowAH + Y2, X1, rowAH + Y1, SOLID, attAH) 208 | end 209 | end 210 | 211 | lcd.drawLine(colAH - radAH - 1, rowAH - radAH, colAH - radAH - 1, rowAH + radAH + 1, SOLID, attBox) 212 | lcd.drawLine(colAH + radAH + 1, rowAH - radAH , colAH + radAH + 1, rowAH + radAH + 1, SOLID, attBox) 213 | lcd.drawLine(colAH - radAH - 1, rowAH + radAH + 1, colAH + radAH + 1, rowAH + radAH + 1, SOLID, attBox) 214 | end 215 | 216 | -- ************************** 217 | -- Draw pitch line indication 218 | -- ************************** 219 | 220 | local function drawPitch() 221 | sinRoll = math.sin(math.rad(-roll)) 222 | cosRoll = math.cos(math.rad(-roll)) 223 | 224 | delta = pitch % 15 225 | 226 | for i = delta - 30 , 30 + delta, 15 do 227 | XH = pitch == i % 360 and 23 or 13 228 | YH = pitchR * i 229 | 230 | X1 = -XH * cosRoll - YH * sinRoll 231 | Y1 = -XH * sinRoll + YH * cosRoll 232 | X2 = (XH - 2) * cosRoll - YH * sinRoll 233 | Y2 = (XH - 2) * sinRoll + YH * cosRoll 234 | 235 | if not ( -- test if not out of the box 236 | (X1 < -radAH and X2 < -radAH) -- The line is to far left 237 | or (X1 > radAH and X2 > radAH) -- The line is to far right 238 | or (Y1 < -radAH and Y2 < -radAH) -- The line is to high 239 | or (Y1 > radAH and Y2 > radAH) -- The line is to low 240 | ) then -- Adjusts X and Y not to get out of the frame (it's a little better, improve) 241 | 242 | mapRatio = (Y2 - Y1) / (X2 - X1) 243 | 244 | if X1 < -radAH then 245 | Y1 = (-radAH - X1) * mapRatio + Y1 246 | X1 = -radAH 247 | end 248 | 249 | if X2 < -radAH then 250 | Y2 = (-radAH - X1) * mapRatio + Y1 251 | X2 = -radAH 252 | end 253 | 254 | if X1 > radAH then 255 | Y1 = (radAH - X1) * mapRatio + Y1 256 | X1 = radAH 257 | end 258 | 259 | if X2 > radAH then 260 | Y2 = (radAH - X1) * mapRatio + Y1 261 | X2 = radAH 262 | end 263 | 264 | mapRatio = 1 / mapRatio 265 | 266 | if Y1 < -radAH then 267 | X1 = (-radAH - Y1) * mapRatio + X1 268 | Y1 = -radAH 269 | end 270 | 271 | if Y2 < -radAH then 272 | X2 = (-radAH - Y1) * mapRatio + X1 273 | Y2 = -radAH 274 | end 275 | 276 | if Y1 > radAH then 277 | X1 = (radAH - Y1) * mapRatio + X1 278 | Y1 = radAH 279 | end 280 | 281 | if Y2 > radAH then 282 | X2 = (radAH - Y1) * mapRatio + X1 283 | Y2 = radAH 284 | end 285 | 286 | lcd.drawLine(colAH + X1, rowAH + Y1, colAH + X2 + 1, rowAH + Y2, SOLID, FORCE) 287 | end 288 | end 289 | end 290 | 291 | -- ********************** 292 | -- Draw heading indicator 293 | -- ********************** 294 | 295 | local parmHeading = { 296 | { 0, 2, "N"}, { 30, 5}, { 60, 5}, 297 | { 90, 2, "E"}, {120, 5}, {150, 5}, 298 | {180, 2, "S"}, {210, 5}, {240, 5}, 299 | {270, 2, "W"}, {300, 5}, {330, 5} 300 | } 301 | 302 | local wrkHeading = 0 303 | 304 | local function drawHeading() 305 | lcd.drawLine(colHeading - 30, rowHeading, colHeading + 30, rowHeading, SOLID, FORCE) 306 | 307 | for index, point in pairs(parmHeading) do 308 | wrkHeading = point[1] - yaw 309 | 310 | if wrkHeading > 180 then 311 | wrkHeading = wrkHeading - 360 312 | end 313 | 314 | if wrkHeading < -180 then 315 | wrkHeading = wrkHeading + 360 316 | end 317 | 318 | delatX = (wrkHeading / 3.3) - 0 319 | 320 | if delatX >= -31 and delatX <= 31 then 321 | if point[3] then 322 | lcd.drawText(colHeading + delatX - 1, rowHeading - 8, point[3], SMLSIZE + BOLD) 323 | end 324 | 325 | if point[2] > 0 then 326 | lcd.drawLine(colHeading + delatX, rowHeading - point[2], colHeading + delatX, rowHeading, SOLID, FORCE) 327 | end 328 | 329 | end 330 | end 331 | 332 | lcd.drawFilledRectangle(colHeading - 34, rowHeading - 9, 3, 10, ERASE) 333 | lcd.drawFilledRectangle(colHeading + 32, rowHeading - 9, 3, 10, ERASE) 334 | 335 | lcd.drawFilledRectangle(colHeading -8, 1, 16, 8, ERASE) 336 | 337 | lcd.drawLine(colHeading - 9, 0, colHeading - 9, 8, SOLID, FORCE) 338 | lcd.drawLine(colHeading + 8, 0, colHeading + 8, 8, SOLID, FORCE) 339 | 340 | local heading10 = yaw % 100 341 | local heading100 = (yaw - heading10) / 100 342 | 343 | local heading1 = yaw % 10 344 | 345 | heading10 = (heading10 - heading1) / 10 346 | 347 | lcd.drawNumber(colHeading - 7, 2, heading100, LEFT+SMLSIZE) 348 | lcd.drawNumber(lcd.getLastPos(), 2, heading10, LEFT+SMLSIZE) 349 | lcd.drawNumber(lcd.getLastPos(), 2, heading1, LEFT+SMLSIZE) 350 | end 351 | 352 | local function drawDistance() 353 | deltaX = (distance_2D < 10 and 6) or (distance_2D < 100 and 8 or (distance_2D < 1000 and 10 or 12)) 354 | lcd.drawNumber(colAH + 3 - deltaX, rowAH + 10 , distance_2D, LEFT+SMLSIZE+INVERS) 355 | lcd.drawText(lcd.getLastPos(), rowAH + 10, "m", SMLSIZE+INVERS) 356 | drawShape(colAH, rowAH, homeShape, math.rad(heading_to - heading + 180)) 357 | end 358 | 359 | local function drawMode() 360 | if(isArmed ==0) then 361 | lcd.drawText(colAH - 19, rowAH - 20, "DISARMED", SMLSIZE+INVERS) 362 | end 363 | 364 | lcd.drawText(colAH - 8, rowAH + 25, modes, SMLSIZE) 365 | end 366 | 367 | -- ***************************************************** 368 | -- Vertical line parameters (to improve or even supress) 369 | -- ***************************************************** 370 | 371 | local parmLine = { 372 | {rowAH - 36, 5, 30}, -- +30 373 | {rowAH - 30, 3}, -- +25 374 | {rowAH - 24, 5, 20}, -- +20 375 | {rowAH - 18, 3}, -- +15 376 | {rowAH - 12, 5, 10}, -- +10 377 | {rowAH - 6, 3}, -- +5 378 | {rowAH, 5, 0}, -- 0 379 | {rowAH + 6, 3}, -- -5 380 | {rowAH + 12, 5, -10}, -- -10 381 | {rowAH + 18, 3}, -- -15 382 | {rowAH + 24, 5, -20}, -- -20 383 | {rowAH + 30, 3}, -- -25 384 | {rowAH + 36, 5, -30} -- -30 385 | } 386 | 387 | -- *********************** 388 | -- Draw altitude indicator 389 | -- *********************** 390 | 391 | local function drawAltitude() 392 | delta = altitude % 10 393 | deltaY = 1 + (1.2 * delta) 394 | 395 | lcd.drawLine(colAlt, -1, colAlt, 64, SOLID, FORCE) 396 | 397 | for index, line in pairs(parmLine) do 398 | lcd.drawLine(colAlt - line[2] - 1, line[1] + deltaY, colAlt - 1, line[1] + deltaY, SOLID, FORCE) 399 | 400 | if line[3] then 401 | lcd.drawNumber(colAlt + 4, line[1] + deltaY - 3, altitude + line[3] - delta, LEFT+SMLSIZE) 402 | end 403 | end 404 | 405 | lcd.drawFilledRectangle(colAlt - 5, 0, 5, 10, ERASE) 406 | lcd.drawFilledRectangle(colAlt + 1, 0, 18, 9, ERASE) 407 | 408 | lcd.drawNumber(colAlt + 4, 1 + rowAH - 3, altitude, LEFT+SMLSIZE+INVERS) 409 | lcd.drawText(colAlt + 5, 1, "m", SMLSIZE+FIXEDWIDTH) 410 | end 411 | 412 | 413 | -- ******************** 414 | -- Draw speed indicator 415 | -- ******************** 416 | 417 | local function drawSpeed() 418 | delta = speed % 10 419 | deltaY = 1 + (1.2 * delta) 420 | 421 | lcd.drawLine(colSpeed, -1, colSpeed, 64, SOLID, FORCE) 422 | 423 | for index, line in pairs(parmLine) do 424 | lcd.drawLine(colSpeed, line[1] + deltaY, colSpeed + line[2], line[1] + deltaY, SOLID, FORCE) 425 | 426 | if line[3] then 427 | lcd.drawNumber(colSpeed - 17, line[1] + deltaY - 3, speed + line[3] - delta, SMLSIZE) 428 | end 429 | end 430 | 431 | lcd.drawFilledRectangle(colSpeed + 1, 0, 5, 10, ERASE) 432 | lcd.drawFilledRectangle(colSpeed - 18, 0, 18, 9, ERASE) 433 | 434 | lcd.drawNumber(colSpeed - 17, 1 + rowAH - 3, speed, SMLSIZE+INVERS) 435 | lcd.drawText(colSpeed - 19, 1, "kmh", SMLSIZE+FIXEDWIDTH) 436 | end 437 | 438 | -- *************** 439 | -- Draw radar area 440 | -- *************** 441 | 442 | local colRadar, rowRadar = 132, 28 443 | 444 | --local radarShape1 = { 445 | -- {-4, 5, 0, -4}, 446 | -- {-3, 5, 0, -3}, 447 | -- {3, 5, 0, -3}, 448 | -- {4, 5, 0, -4} 449 | --} 450 | 451 | local radarShape2 = { 452 | {-3, 3, 0, -3}, 453 | {-2, 3, 0, -2}, 454 | { 2, 3, 0, -2}, 455 | { 3, 3, 0, -3} 456 | } 457 | 458 | local wrkDistance, radTmp 459 | 460 | local function drawRadar() 461 | local direction = getValue("s2") * 180 / 1024 462 | local directionRads = math.rad(direction) 463 | local cosDirection = math.cos(directionRads) 464 | local sinDirection = math.sin(directionRads) 465 | 466 | lcd.drawText(colRadar - 2, rowRadar - 4 ,"o" ,0) 467 | 468 | drawEllipse(colRadar, rowRadar, 24, 24) 469 | 470 | local iCosDirection 471 | local iSinDirection 472 | 473 | for i=7, 24, 4 do 474 | iCosDirection = i * cosDirection 475 | iSinDirection = i * sinDirection 476 | 477 | lcd.drawPoint(colRadar + iCosDirection, rowRadar - iSinDirection) 478 | lcd.drawPoint(colRadar - iCosDirection, rowRadar + iSinDirection) 479 | 480 | lcd.drawPoint(colRadar + iSinDirection, rowRadar + iCosDirection) 481 | lcd.drawPoint(colRadar - iSinDirection, rowRadar - iCosDirection) 482 | end 483 | 484 | lcd.drawText(colRadar - (24 * sinDirection) - 1, rowRadar - (24 * cosDirection) - 3, "N", SMLSIZE) 485 | 486 | local distanceRange = 0 487 | local firstRange = 100 488 | 489 | for i=0,10,1 do 490 | distanceRange = 2 ^ i * firstRange 491 | wrkDistance = -distance_2D / distanceRange * 28 492 | 493 | if distance_2D < distanceRange then 494 | if i > 0 then 495 | drawEllipse(colRadar, rowRadar, 12, 12) 496 | end 497 | break 498 | end 499 | end 500 | 501 | radTmp = math.rad(direction - heading_from) 502 | drawShape(colRadar + wrkDistance * math.sin(radTmp), rowRadar + wrkDistance * math.cos(radTmp), radarShape2, math.rad(heading - direction)) 503 | 504 | deltaX = (distanceRange < 10 and 6) or (distanceRange < 100 and 8 or (distanceRange < 1000 and 10 or 12)) 505 | lcd.drawNumber(colRadar + 3 - deltaX, rowDistance , distanceRange, LEFT+SMLSIZE) 506 | lcd.drawText(lcd.getLastPos(), rowDistance, "m", SMLSIZE) 507 | 508 | end 509 | 510 | -- *************************** 511 | -- Draw textual telemetry data 512 | -- *************************** 513 | 514 | 515 | 516 | local function drawTextualTelemetry() 517 | 518 | local y = -4 519 | lcd.drawNumber(textualRow + 18, y + 4, distance_2D, LEFT+MIDSIZE) 520 | lcd.drawText(lcd.getLastPos(), y + 8, "m", SMLSIZE) 521 | y = 30 522 | lcd.drawNumber(textualRow + 14, y + 2, cellVoltage * 10, PREC1+LEFT+MIDSIZE) 523 | lcd.drawText(lcd.getLastPos(), y + 6, "V", SMLSIZE) 524 | y = 42 525 | lcd.drawText(textualRow, y + 4, latitude, LEFT+SMLSIZE) 526 | lcd.drawText(textualRow, y + 12, longitude, LEFT+SMLSIZE) 527 | end 528 | 529 | 530 | 531 | -- ************* 532 | -- Draw function 533 | -- ************* 534 | 535 | 536 | 537 | local function blankGauges() 538 | lcd.drawFilledRectangle(0,0,163,64,ERASE) 539 | end 540 | 541 | local function gpsWidget(xCoord,yCoord) 542 | 543 | local satImg = "/SCRIPTS/TELEMETRY/BMP/gps_0.bmp" 544 | if sats > 5 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_6.bmp" 545 | elseif sats > 4 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_5.bmp" 546 | elseif sats > 3 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_4.bmp" 547 | elseif sats > 2 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_3.bmp" 548 | elseif sats > 1 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_2.bmp" 549 | elseif sats > 0 then satImg = "/SCRIPTS/TELEMETRY/BMP/gps_1.bmp" 550 | end 551 | if prevGpss ~= sats then 552 | lcd.drawPixmap(xCoord+13, yCoord+3, satImg) 553 | lcd.drawNumber(xCoord+14, yCoord+2, sats, SMLSIZE) 554 | end 555 | if firstrun == 1 then 556 | lcd.drawPixmap(xCoord+13, yCoord+3, satImg) 557 | lcd.drawNumber(xCoord+14, yCoord+2, sats, SMLSIZE) 558 | end 559 | end 560 | 561 | local function drawThings() 562 | lcd.drawFilledRectangle(163,0,212,64,ERASE) 563 | lcd.drawPixmap(textualRow, -4, "/SCRIPTS/TELEMETRY/BMP/dist.bmp") 564 | lcd.drawPixmap(textualRow, 11, "/SCRIPTS/TELEMETRY/BMP/sat.bmp") 565 | gpsWidget(textualRow,11) 566 | lcd.drawPixmap(textualRow -3, 29, "/SCRIPTS/TELEMETRY/BMP/battery.bmp") 567 | end 568 | 569 | -- ************* 570 | -- Main function 571 | -- ************* 572 | 573 | local function getTelemetryValues() 574 | 575 | if debug == 1 then 576 | altitude = 130 577 | cellVoltage = 14.2 578 | latitude = 0 579 | longitude = 0 580 | roll = 10 581 | pitch = 15 582 | yaw = 30 583 | rss1 = 38 584 | rss2 = 47 585 | speed = 100 586 | modes = "ANGL" 587 | isArmed = 1 588 | distance_2D = 144 589 | 590 | else 591 | altitude = getValue("Alt") 592 | cellVoltage = getValue("RxBt") 593 | gpspos = getValue("GPS") 594 | 595 | if (type(gpspos) == "table") then 596 | latitude = gpspos["lat"] 597 | longitude = gpspos["lon"] 598 | else 599 | latitude = 0 600 | longitude = 0 601 | end 602 | 603 | roll = math.deg(getValue("Roll")) 604 | pitch = -1 * math.deg(getValue("Ptch")) 605 | yaw = math.deg(getValue("Yaw")) 606 | rss1 = getValue("1RSS") 607 | rss2 = getValue("2RSS") 608 | rssi = math.max(rss1,rss2) 609 | speed = getValue("GSpd") 610 | sats = getValue("Sats") 611 | modes = getValue("FM") 612 | 613 | 614 | end 615 | 616 | if pitch < 0 then 617 | pitch = 360 + pitch 618 | end 619 | 620 | if yaw < 0 then 621 | yaw = 360 + yaw 622 | end 623 | 624 | 625 | if (prevGpss < 5 and sats >=5) or (sats >= 5 and firstPass) then 626 | homeSet = 1 627 | homeLatitude = latitude 628 | homeLongitude = longitude 629 | end 630 | 631 | if firstPass == 1 then 632 | firstPass = 0 633 | end 634 | 635 | prevGpss = sats 636 | 637 | end 638 | 639 | local function runTask(event) 640 | if debug == 1 then 641 | if event == EVT_ENTER_BREAK then 642 | rssi = 60 643 | elseif event == EVT_PLUS_FIRST then 644 | sats = sats + 1 645 | elseif event == EVT_MINUS_FIRST then 646 | sats = sats - 1 647 | elseif event == EVT_ENTER_LONG then 648 | rssi = 20 649 | end 650 | end 651 | 652 | if rssi < 0 then 653 | rssi = 0 654 | elseif rssi > 100 then 655 | rssi = 100 656 | end 657 | 658 | if rssi > 25 then 659 | 660 | if firstrun == 1 then 661 | drawThings() 662 | firstrun = 0 663 | end 664 | drawTextualTelemetry() 665 | gpsCalculation() 666 | blankGauges() 667 | drawAltitude() 668 | drawSpeed() 669 | drawHeading() 670 | drawPitch() 671 | gpsWidget(textualRow,11) 672 | drawHorizon() 673 | drawMode() 674 | drawRadar() 675 | if runcounter == 20 then 676 | firstrun = 1 677 | runcounter = 0 678 | else 679 | runcounter = runcounter + 1 680 | end 681 | else 682 | lcd.clear() 683 | lcd.drawText(32, 25, "No Connection...", BLINK+DBLSIZE) 684 | firstrun = 1 685 | end 686 | end 687 | 688 | return {init=init, background=getTelemetryValues, run=runTask} -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgreer/inav-telemscript/f16d4bb55cac6caae98dd64320b93568dc86749d/screenshot.png --------------------------------------------------------------------------------