mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
Merge pull request #867 from syund/Show-fixed-GPS-coordinates-on-screen
[866] Show fixed coordinates on screen and indicate fixed GPS
This commit is contained in:
commit
0f14ed0a6c
@ -1,8 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Status.h"
|
#include "Status.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
extern NodeDB nodeDB;
|
||||||
|
|
||||||
namespace meshtastic
|
namespace meshtastic
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -47,11 +50,36 @@ class GPSStatus : public Status
|
|||||||
|
|
||||||
bool getIsConnected() const { return isConnected; }
|
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; }
|
uint32_t getDOP() const { return dop; }
|
||||||
|
|
||||||
|
@ -333,6 +333,11 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no
|
|||||||
// Draw GPS status summary
|
// Draw GPS status summary
|
||||||
static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
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()) {
|
if (!gps->getIsConnected()) {
|
||||||
display->drawString(x, y - 2, "No GPS");
|
display->drawString(x, y - 2, "No GPS");
|
||||||
return;
|
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)
|
static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
||||||
{
|
{
|
||||||
String displayLine = "";
|
String displayLine = "";
|
||||||
if (!gps->getIsConnected()) {
|
if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) {
|
||||||
// displayLine = "No GPS Module";
|
// displayLine = "No GPS Module";
|
||||||
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
// 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";
|
// displayLine = "No GPS Lock";
|
||||||
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
} else {
|
} else {
|
||||||
@ -743,10 +748,10 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
|
|||||||
auto gpsFormat = radioConfig.preferences.gps_format;
|
auto gpsFormat = radioConfig.preferences.gps_format;
|
||||||
String displayLine = "";
|
String displayLine = "";
|
||||||
|
|
||||||
if (!gps->getIsConnected()) {
|
if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) {
|
||||||
displayLine = "No GPS Module";
|
displayLine = "No GPS Module";
|
||||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
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";
|
displayLine = "No GPS Lock";
|
||||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user