diff --git a/README.md b/README.md index b8e3114..78cc7cf 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +## 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. \ No newline at end of file diff --git a/src/WIDGETS/ELRST/main.lua b/src/WIDGETS/ELRST/main.lua index 1662518..428e00d 100644 --- a/src/WIDGETS/ELRST/main.lua +++ b/src/WIDGETS/ELRST/main.lua @@ -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 @@ -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