Various position fixes (#3297)

* Guard against no movement

* Add newlines

* Fix printfs
This commit is contained in:
Ben Meadors 2024-02-26 20:24:36 -06:00 committed by GitHub
parent ce0e5c0ce7
commit e6a2c06346
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 11 deletions

View File

@ -319,7 +319,6 @@ bool GPS::setup()
delay(250); delay(250);
_serial_gps->write("$CFGMSG,6,1,0\r\n"); _serial_gps->write("$CFGMSG,6,1,0\r\n");
delay(250); delay(250);
} else if (gnssModel == GNSS_MODEL_UBLOX) { } else if (gnssModel == GNSS_MODEL_UBLOX) {
// Configure GNSS system to GPS+SBAS+GLONASS (Module may restart after this command) // Configure GNSS system to GPS+SBAS+GLONASS (Module may restart after this command)
// We need set it because by default it is GPS only, and we want to use GLONASS too // We need set it because by default it is GPS only, and we want to use GLONASS too
@ -458,7 +457,6 @@ bool GPS::setup()
LOG_WARN("Unable to enable NMEA 4.10.\n"); LOG_WARN("Unable to enable NMEA 4.10.\n");
} }
} }
} else { } else {
if (strncmp(info.hwVersion, "00040007", 8) == 0) { // This PSM mode is only for Neo-6 if (strncmp(info.hwVersion, "00040007", 8) == 0) { // This PSM mode is only for Neo-6
msglen = makeUBXPacket(0x06, 0x11, 0x2, _message_CFG_RXM_ECO); msglen = makeUBXPacket(0x06, 0x11, 0x2, _message_CFG_RXM_ECO);
@ -642,12 +640,12 @@ void GPS::setGPSPower(bool on, bool standbyOnly, uint32_t sleepTime)
#endif #endif
#ifdef PIN_GPS_STANDBY // Specifically the standby pin for L76K and clones #ifdef PIN_GPS_STANDBY // Specifically the standby pin for L76K and clones
if (on) { if (on) {
LOG_INFO("Waking GPS"); LOG_INFO("Waking GPS\n");
pinMode(PIN_GPS_STANDBY, OUTPUT); pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, 1); digitalWrite(PIN_GPS_STANDBY, 1);
return; return;
} else { } else {
LOG_INFO("GPS entering sleep"); LOG_INFO("GPS entering sleep\n");
// notifyGPSSleep.notifyObservers(NULL); // notifyGPSSleep.notifyObservers(NULL);
pinMode(PIN_GPS_STANDBY, OUTPUT); pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, 0); digitalWrite(PIN_GPS_STANDBY, 0);

View File

@ -376,14 +376,17 @@ void GeoCoord::convertWGS84ToOSGB36(const double lat, const double lon, double &
} }
/// Ported from my old java code, returns distance in meters along the globe /// Ported from my old java code, returns distance in meters along the globe
/// surface (by magic?) /// surface (by Haversine formula)
float GeoCoord::latLongToMeter(double lat_a, double lng_a, double lat_b, double lng_b) float GeoCoord::latLongToMeter(double lat_a, double lng_a, double lat_b, double lng_b)
{ {
double pk = (180 / 3.14169); // Don't do math if the points are the same
double a1 = lat_a / pk; if (lat_a == lat_b && lng_a == lng_b)
double a2 = lng_a / pk; return 0.0;
double b1 = lat_b / pk;
double b2 = lng_b / pk; double a1 = lat_a / DEG_CONVERT;
double a2 = lng_a / DEG_CONVERT;
double b1 = lat_b / DEG_CONVERT;
double b2 = lng_b / DEG_CONVERT;
double cos_b1 = cos(b1); double cos_b1 = cos(b1);
double cos_a1 = cos(a1); double cos_a1 = cos(a1);
double t1 = cos_a1 * cos(a2) * cos_b1 * cos(b2); double t1 = cos_a1 * cos(a2) * cos_b1 * cos(b2);

View File

@ -11,6 +11,7 @@
#define PI 3.1415926535897932384626433832795 #define PI 3.1415926535897932384626433832795
#define OLC_CODE_LEN 11 #define OLC_CODE_LEN 11
#define DEG_CONVERT 180 / PI
// Helper functions // Helper functions
// Raises a number to an exponent, handling negative exponents. // Raises a number to an exponent, handling negative exponents.

View File

@ -372,7 +372,7 @@ struct SmartPosition PositionModule::getDistanceTraveledSinceLastSend(meshtastic
LOG_DEBUG("currentPosition.latitude_i=%i, currentPosition.longitude_i=%i\n", lastGpsLatitude, lastGpsLongitude); LOG_DEBUG("currentPosition.latitude_i=%i, currentPosition.longitude_i=%i\n", lastGpsLatitude, lastGpsLongitude);
LOG_DEBUG("--------SMART POSITION-----------------------------------\n"); LOG_DEBUG("--------SMART POSITION-----------------------------------\n");
LOG_DEBUG("hasTraveledOverThreshold=%i, distanceTraveled=%d, distanceThreshold=% u\n", LOG_DEBUG("hasTraveledOverThreshold=%i, distanceTraveled=%f, distanceThreshold=%f\n",
abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold, abs(distanceTraveledSinceLastSend), abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold, abs(distanceTraveledSinceLastSend),
distanceTravelThreshold); distanceTravelThreshold);