Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
moschotto authored Feb 2, 2021
1 parent 64063fc commit 3047649
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 13 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OpenTX GPS LUA TELEMETRY screens - GPS last known quad postions v2.2
# OpenTX GPS LUA TELEMETRY screens - GPS last known postions v2.1

Copyright (C) by mosch
License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -13,7 +13,6 @@ GITHUB: https://github.com/moschotto?tab=repositories
### Radios with 212x64 pixel displays (e.g. x9d/x9+/x9E)
- /x9/GPSx9.lua
- /x9/GPSviewerX9.lua
- /x9/GPSviewerX9e.lua (use this if your radio has a scroll wheel)

### Radios with 128x64 pixel displays (e.g. x7 / x9 lite)
- /x7_x9lite/GPSx9L.lua
Expand All @@ -33,11 +32,9 @@ GPS coordinates and type it into to your mobile phone...

- distance to your home position - how far you need to walk ;)

- Reset telemetry data (home positon and distance):

[TARANIS] Reset via "long press enter"

[T16 etc] Reset via "long press enter" -> statistics -> "long press enter" to reset statistics and exit menu in under 10 seconds
-Reset Telemetry (home positon and distance):
[TARANIS] Reset telemetry data and total distance via "long press enter"
[T16 etc] Reset via "long press enter" -> statistics -> "long press enter" to reset statistics and exit menu in under 10 seconds


### Install Taranis models:
Expand Down
6 changes: 3 additions & 3 deletions T16/GPS/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,16 @@ function refresh(wgt)
--headline
if wgt.update == true then
lcd.setColor(CUSTOM_COLOR, lcd.RGB(0x9D, 0xD6, 0x00))
lcd.drawFilledRectangle(wgt.zone.x + 0, wgt.zone.y + 0, wgt.zone.x + 215, 25, CUSTOM_COLOR)
lcd.drawFilledRectangle(wgt.zone.x + 0, wgt.zone.y + 0, 225, 25, CUSTOM_COLOR)
lcd.drawText(wgt.zone.x + 5,wgt.zone.y + 5,wgt.gpsFIX , LEFT + SMLSIZE + TEXT_COLOR)
elseif wgt.update == false then
lcd.setColor(CUSTOM_COLOR, lcd.RGB(0xe6, 0x32, 24))
lcd.drawFilledRectangle(wgt.zone.x + 0, wgt.zone.y + 0, wgt.zone.x + 215, 25, CUSTOM_COLOR )
lcd.drawFilledRectangle(wgt.zone.x + 0, wgt.zone.y + 0, 225, 25, CUSTOM_COLOR )
lcd.drawText(wgt.zone.x + 5,wgt.zone.y + 5, "no GPS data available", LEFT + SMLSIZE + TEXT_COLOR)
end

--line horz.
lcd.drawLine(wgt.zone.x + 0, wgt.zone.y + 25, wgt.zone.x + 224, wgt.zone.y + 25, SOLID, LINE_COLOR)
--lcd.drawLine(wgt.zone.x + 0, wgt.zone.y + 25, wgt.zone.x + 224, wgt.zone.y + 25, SOLID, LINE_COLOR)

--satellites
lcd.drawBitmap(sat_img, wgt.zone.x, wgt.zone.y + 30, 35)
Expand Down
Binary file added TBS_Tango/BMP/Sat16.bmp
Binary file not shown.
Binary file added TBS_Tango/BMP/distance16.bmp
Binary file not shown.
Binary file added TBS_Tango/BMP/drone16.bmp
Binary file not shown.
Binary file added TBS_Tango/BMP/home16.bmp
Binary file not shown.
Binary file added TBS_Tango/BMP/total_distance16.bmp
Binary file not shown.
185 changes: 185 additions & 0 deletions TBS_Tango/GPSviewerT.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
--[[#############################################################################
GPS Position viewer v1.1
Copyright (C) by mosch
License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
GITHUB: https://github.com/moschotto?tab=repositories
Description:
reads the "GPSpositions.txt" log-file which was generated by the GPS.lua script.
useful if want to check the last GPS coordinates after a crash, power loss etc.
copy "GPSviewer.lua" to the /SCRIPTS/TOOLS/ folder
################################################################################]]


local toolName = "TNS|GPSTLog Viewer|TNE"
local log_filename = "/LOGS/GPSpositions.txt"
local file_exist = false
local string_gmatch = string.gmatch
local coordinates = {}
local linectr = 0
local item = 0

local function splitstring(text)

if text ~= nil then
local text_split = {}
local i=0
--split by "," and store into array/table
for word in string_gmatch(text, "([^,]+)") do
text_split[i] = word
i = i + 1
end

return text_split
end
end

local function Viewer_Draw_LCD(item)

lcd.clear()
lcd.drawLine(0,0,0,95, SOLID, FORCE)
lcd.drawLine(127,0,127,95, SOLID, FORCE)
lcd.drawText(2,1,"GPS Position viewer v1.1" ,SMLSIZE)
lcd.drawFilledRectangle(1,0, 126, 9, GREY_DEFAULT)


lcd.drawLine(60,8, 60, 19, SOLID, FORCE)
lcd.drawText(64,11, "Sats:",SMLSIZE)
lcd.drawLine(97,8, 97, 19, SOLID, FORCE)
lcd.drawLine(0,19, 128, 19, SOLID, FORCE)
lcd.drawText(100,11, (item + 1).."/" .. linectr,SMLSIZE)

if item < 4 then
--first 4 rows static
local line0 = splitstring(coordinates[0])
local line1 = splitstring(coordinates[1])
local line2 = splitstring(coordinates[2])
local line3 = splitstring(coordinates[3])

if item == 0 then
lcd.drawText(2,11, "Time:" .. string.gsub(line0[3], "%s+", ""), SMLSIZE)
lcd.drawText(64,11, "Sats:" .. string.gsub(line0[4], "%s+","") ,SMLSIZE)
lcd.drawText(2,24, line0[1] .."," .. line0[2] ,SMLSIZE + BLINK + INVERS)
else
lcd.drawText(2,24, line0[1] .."," .. line0[2] ,SMLSIZE)
end

if item == 1 then
lcd.drawText(2,11, "Time:" .. string.gsub(line1[3], "%s+",""), SMLSIZE)
lcd.drawText(64,11, "Sats:" .. string.gsub(line1[4], "%s+","") ,SMLSIZE)
lcd.drawText(2,44, line1[1] .."," .. line1[2] ,SMLSIZE + BLINK + INVERS)
else
lcd.drawText(2,44, line1[1] .."," .. line1[2] ,SMLSIZE)
end

if item == 2 then
lcd.drawText(2,11, "Time:" .. string.gsub(line2[3], "%s+",""), SMLSIZE)
lcd.drawText(64,11, "Sats:" .. string.gsub(line2[4], "%s+","") ,SMLSIZE)
lcd.drawText(2,64, line2[1] .."," .. line2[2] ,SMLSIZE + BLINK + INVERS)
else
lcd.drawText(2,64, line2[1] .."," .. line2[2] ,SMLSIZE)
end

if item == 3 then
lcd.drawText(2,11, "Time:" .. string.gsub(line3[3], "%s+",""), SMLSIZE)
lcd.drawText(64,11, "Sats:" .. string.gsub(line3[4], "%s+","") ,SMLSIZE)
lcd.drawText(2,84, line3[1] .."," .. line3[2] ,SMLSIZE + BLINK + INVERS)
else
lcd.drawText(2,84, line3[1] .."," .. line3[2] ,SMLSIZE)
end
else

local line0 = splitstring(coordinates[item-3])
local line1 = splitstring(coordinates[item-2])
local line2 = splitstring(coordinates[item-1])
local line3 = splitstring(coordinates[item])

lcd.drawText(2,11, "Time:" .. string.gsub(line3[3], "%s+",""), SMLSIZE)
lcd.drawText(64,11, "Sats:" .. string.gsub(line3[4], "%s+","") ,SMLSIZE)
lcd.drawText(2,24, line0[1] .."," .. line0[2],SMLSIZE)
lcd.drawText(2,44, line1[1] .."," .. line1[2],SMLSIZE)
lcd.drawText(2,64, line2[1] .."," .. line2[2],SMLSIZE)
lcd.drawText(2,84, line3[1] .."," .. line3[2],SMLSIZE + BLINK + INVERS)

end

lcd.drawLine(0,95,127,95, SOLID, FORCE)


end

local function Viewer_Init()

lcd.clear()
local f2 = io.open(log_filename, "r")

--check if file exists
if f2 ~= nil then

file_exist = true
buffer = io.read(f2, 4096)
io.close(f2)

--read file contents into array/table
for line in string_gmatch(buffer, "([^\n]+)\n") do
coordinates[linectr] = line
linectr = linectr + 1
end

--draw inital screen
Viewer_Draw_LCD(0)

else
file_exist = false
end
end


-- Main
local function Viewer_Run(event)

if event == nil then
error("Cannot be run as a model script!")
return 2
else

if file_exist == true then

Viewer_Draw_LCD(item)
--handle scroll counter
if event == EVT_ROT_RIGHT or event == EVT_PLUS_FIRST then
if item < linectr-1 then
item = item + 1
end
end
if event == EVT_ROT_LEFT or event == EVT_MINUS_FIRST then
if item > 0 then
item = item - 1
end
end

else
--display error message
lcd.clear()
lcd.drawLine(0,0,0,64, SOLID, FORCE)
lcd.drawLine(127,0,127,64, SOLID, FORCE)
lcd.drawText(2,1,"GPS Postion viewer" ,SMLSIZE)
lcd.drawFilledRectangle(1,0, 126, 9, GREY_DEFAULT)
lcd.drawText(10,20, "Logfile does not exist", SMLSIZE)
lcd.drawText(10,30, log_filename, SMLSIZE + BLINK)
lcd.drawLine(0,62, 128, 62, SOLID, FORCE)
end

if event == EVT_VIRTUAL_EXIT then
return 2
end

end
return 0
end

return { init=Viewer_Init, run=Viewer_Run }
Loading

0 comments on commit 3047649

Please sign in to comment.