From a74f038cba6666bbbff2c9a65a3cbad6e1724408 Mon Sep 17 00:00:00 2001 From: Sam <35611307+syund@users.noreply.github.com> Date: Wed, 15 Sep 2021 18:58:09 -0400 Subject: [PATCH] [866] Show fixed coordinates on screen and indicate when using fixed coordinates. --- src/GPSStatus.h | 34 +++++++++++++++++++++++++++++++--- src/graphics/Screen.cpp | 13 +++++++++---- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/GPSStatus.h b/src/GPSStatus.h index 237964eb0..3d1e5a6c7 100644 --- a/src/GPSStatus.h +++ b/src/GPSStatus.h @@ -1,8 +1,11 @@ #pragma once #include "Status.h" #include "configuration.h" +#include "NodeDB.h" #include +extern NodeDB nodeDB; + namespace meshtastic { @@ -47,11 +50,36 @@ class GPSStatus : public Status bool getIsConnected() const { return isConnected; } - int32_t getLatitude() const { return latitude; } + int32_t getLatitude() const { + if (radioConfig.preferences.fixed_position){ + DEBUG_MSG("WARNING: Using fixed latitude\n"); + NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); + return node->position.latitude_i; + } else { + return latitude; + } + } - int32_t getLongitude() const { return longitude; } + int32_t getLongitude() const { + if (radioConfig.preferences.fixed_position){ + DEBUG_MSG("WARNING: Using fixed longitude\n"); + NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); + return node->position.longitude_i; + } else { + return longitude; + } + } + + int32_t getAltitude() const { + if (radioConfig.preferences.fixed_position){ + DEBUG_MSG("WARNING: Using fixed altitude\n"); + NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); + return node->position.altitude; + } else { + return altitude; + } + } - int32_t getAltitude() const { return altitude; } uint32_t getDOP() const { return dop; } diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index fd3671fb9..f889cf95b 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -333,6 +333,11 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no // Draw GPS status summary static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) { + if (radioConfig.preferences.fixed_position) { + // GPS coordinates are currently fixed + display->drawString(x - 1, y - 2, "Fixed GPS"); + return; + } if (!gps->getIsConnected()) { display->drawString(x, y - 2, "No GPS"); return; @@ -367,10 +372,10 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) { String displayLine = ""; - if (!gps->getIsConnected()) { + if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) { // displayLine = "No GPS Module"; // display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); - } else if (!gps->getHasLock()) { + } else if (!gps->getHasLock() && !radioConfig.preferences.fixed_position) { // displayLine = "No GPS Lock"; // display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); } else { @@ -743,10 +748,10 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const auto gpsFormat = radioConfig.preferences.gps_format; String displayLine = ""; - if (!gps->getIsConnected()) { + if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) { displayLine = "No GPS Module"; display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); - } else if (!gps->getHasLock()) { + } else if (!gps->getHasLock() && !radioConfig.preferences.fixed_position) { displayLine = "No GPS Lock"; display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); } else {