Skip to content

Commit

Permalink
Add last GPS coordinates to disconnected display
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Dec 19, 2021
1 parent a80b96f commit 622e40c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ A simple widget to display ExpressLRS LinkStats telemetry as well as common Beta
## What is "Range"?
Range is an estimation of the model's distance. Technically, it is just the percentage of the RSSI from -50dBm (0% range) to the sensitivity limit for your selected packet rate (e.g. -105dBm for 500Hz) where it would indicate 100% range. Range does not account for dynamic power, so the indicated range may decrease as power goes up and increase as power goes down.

## Can the last GPS coordinates be added?
When an RX disconnects, OpenTX/EdgeTX no longer returns the "last known" values, it just returns 0. I could save the last value on every update to make it available, but this is better handled by just adding a "Value" type widget with the GPS item on it, which will keep the last known value even on disconnect. The GPS speed, altitude and satellite count are shown on the fullscreen layout of this widget though.
## Can you display GPS info?
The GPS speed, altitude and satellite count are shown on the fullscreen layout of this widget. If the model disconnects and valid GPS coordinates are available, it is displayed on the "Disconnected" mode display.
28 changes: 27 additions & 1 deletion src/WIDGETS/ELRST/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ local function drawRssiLq(widget, tlm, Y)
return Y
end

local function drawGps(widget, Y)
lcd.drawText(1, Y, "Lat", COLOR_THEME_DISABLED)
lcd.drawText(widget.zw - 32, Y, "N/S", COLOR_THEME_DISABLED)
lcd.drawText(widget.zw / 2, Y, tostring(widget.gps.lat), COLOR_THEME_SECONDARY1 + CENTER)

lcd.drawText(1, Y+TH, "Lon", COLOR_THEME_DISABLED)
lcd.drawText(widget.zw - 32, Y+TH, "E/W", COLOR_THEME_DISABLED)
lcd.drawText(widget.zw / 2, Y+TH, tostring(widget.gps.lon), COLOR_THEME_SECONDARY1 + CENTER)
end

local function refresh(widget, event, touchState)
-- Runs periodically only when widget instance is visible
-- If full screen, then event is 0 or event value, otherwise nil
Expand All @@ -282,9 +292,25 @@ local function refresh(widget, event, touchState)
local tlm = { rssi1 = getV("1RSS") }
if not widget.DEBUG and (tlm.rssi1 == nil or tlm.rssi1 == 0) then
lcd.drawText(widget.zw / 2, Y, "No RX Connected", COLOR_THEME_PRIMARY1 + CENTER)
lcd.drawText(widget.zw / 2, Y+TH, "or sensors discovered", COLOR_THEME_SECONDARY1 + CENTER)
Y = Y + TH
if widget.gps == nil then
lcd.drawText(widget.zw / 2, Y, "or sensors discovered", COLOR_THEME_SECONDARY1 + CENTER)
else
if widget.size < 3 then
Y = Y + TH/2
lcd.drawText(widget.zw / 2, Y, "Last GPS position", COLOR_THEME_PRIMARY1 + CENTER + SMLSIZE)
Y = Y + TH
end
drawGps(widget, Y)
end
widget.ctx = nil
return
else
-- Save the GPS to be able to display it if connection is lost
local gps = getV("GPS")
if gps and gps ~= 0 then
widget.gps = gps
end
end

if widget.DEBUG then
Expand Down

0 comments on commit 622e40c

Please sign in to comment.