mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
route debug output back to the CDC-ACM device instead of JLINK
This commit is contained in:
parent
db33200468
commit
266ba03bb7
192
src/GPSStatus.h
192
src/GPSStatus.h
@ -1,126 +1,98 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
|
||||||
#include "Status.h"
|
#include "Status.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
namespace meshtastic {
|
namespace meshtastic
|
||||||
|
{
|
||||||
|
|
||||||
/// Describes the state of the GPS system.
|
/// Describes the state of the GPS system.
|
||||||
class GPSStatus : public Status
|
class GPSStatus : public Status
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
CallbackObserver<GPSStatus, const GPSStatus *> statusObserver =
|
||||||
|
CallbackObserver<GPSStatus, const GPSStatus *>(this, &GPSStatus::updateStatus);
|
||||||
|
|
||||||
|
bool hasLock = false; // default to false, until we complete our first read
|
||||||
|
bool isConnected = false; // Do we have a GPS we are talking to
|
||||||
|
int32_t latitude = 0, longitude = 0; // as an int mult by 1e-7 to get value as double
|
||||||
|
int32_t altitude = 0;
|
||||||
|
uint32_t dop = 0; // Diminution of position; PDOP where possible (UBlox), HDOP otherwise (TinyGPS) in 10^2 units (needs
|
||||||
|
// scaling before use)
|
||||||
|
uint32_t heading = 0;
|
||||||
|
uint32_t numSatellites = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GPSStatus() { statusType = STATUS_TYPE_GPS; }
|
||||||
|
GPSStatus(bool hasLock, bool isConnected, int32_t latitude, int32_t longitude, int32_t altitude, uint32_t dop,
|
||||||
|
uint32_t heading, uint32_t numSatellites)
|
||||||
|
: Status()
|
||||||
{
|
{
|
||||||
|
this->hasLock = hasLock;
|
||||||
|
this->isConnected = isConnected;
|
||||||
|
this->latitude = latitude;
|
||||||
|
this->longitude = longitude;
|
||||||
|
this->altitude = altitude;
|
||||||
|
this->dop = dop;
|
||||||
|
this->heading = heading;
|
||||||
|
this->numSatellites = numSatellites;
|
||||||
|
}
|
||||||
|
GPSStatus(const GPSStatus &);
|
||||||
|
GPSStatus &operator=(const GPSStatus &);
|
||||||
|
|
||||||
private:
|
void observe(Observable<const GPSStatus *> *source) { statusObserver.observe(source); }
|
||||||
CallbackObserver<GPSStatus, const GPSStatus *> statusObserver = CallbackObserver<GPSStatus, const GPSStatus *>(this, &GPSStatus::updateStatus);
|
|
||||||
|
|
||||||
bool hasLock = false; // default to false, until we complete our first read
|
bool getHasLock() const { return hasLock; }
|
||||||
bool isConnected = false; // Do we have a GPS we are talking to
|
|
||||||
int32_t latitude = 0, longitude = 0; // as an int mult by 1e-7 to get value as double
|
|
||||||
int32_t altitude = 0;
|
|
||||||
uint32_t dop = 0; // Diminution of position; PDOP where possible (UBlox), HDOP otherwise (TinyGPS) in 10^2 units (needs scaling before use)
|
|
||||||
uint32_t heading = 0;
|
|
||||||
uint32_t numSatellites = 0;
|
|
||||||
|
|
||||||
public:
|
bool getIsConnected() const { return isConnected; }
|
||||||
|
|
||||||
GPSStatus() {
|
int32_t getLatitude() const { return latitude; }
|
||||||
statusType = STATUS_TYPE_GPS;
|
|
||||||
}
|
int32_t getLongitude() const { return longitude; }
|
||||||
GPSStatus( bool hasLock, bool isConnected, int32_t latitude, int32_t longitude, int32_t altitude, uint32_t dop, uint32_t heading, uint32_t numSatellites ) : Status()
|
|
||||||
|
int32_t getAltitude() const { return altitude; }
|
||||||
|
|
||||||
|
uint32_t getDOP() const { return dop; }
|
||||||
|
|
||||||
|
uint32_t getHeading() const { return heading; }
|
||||||
|
|
||||||
|
uint32_t getNumSatellites() const { return numSatellites; }
|
||||||
|
|
||||||
|
bool matches(const GPSStatus *newStatus) const
|
||||||
|
{
|
||||||
|
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected || newStatus->latitude != latitude ||
|
||||||
|
newStatus->longitude != longitude || newStatus->altitude != altitude || newStatus->dop != dop ||
|
||||||
|
newStatus->heading != heading || newStatus->numSatellites != numSatellites);
|
||||||
|
}
|
||||||
|
int updateStatus(const GPSStatus *newStatus)
|
||||||
|
{
|
||||||
|
// Only update the status if values have actually changed
|
||||||
|
bool isDirty;
|
||||||
{
|
{
|
||||||
this->hasLock = hasLock;
|
isDirty = matches(newStatus);
|
||||||
this->isConnected = isConnected;
|
initialized = true;
|
||||||
this->latitude = latitude;
|
hasLock = newStatus->hasLock;
|
||||||
this->longitude = longitude;
|
isConnected = newStatus->isConnected;
|
||||||
this->altitude = altitude;
|
latitude = newStatus->latitude;
|
||||||
this->dop = dop;
|
longitude = newStatus->longitude;
|
||||||
this->heading = heading;
|
altitude = newStatus->altitude;
|
||||||
this->numSatellites = numSatellites;
|
dop = newStatus->dop;
|
||||||
|
heading = newStatus->heading;
|
||||||
|
numSatellites = newStatus->numSatellites;
|
||||||
}
|
}
|
||||||
GPSStatus(const GPSStatus &);
|
if (isDirty) {
|
||||||
GPSStatus &operator=(const GPSStatus &);
|
if (hasLock)
|
||||||
|
DEBUG_MSG("New GPS pos lat=%f, lon=%f, alt=%d, pdop=%f, heading=%f, sats=%d\n", latitude * 1e-7, longitude * 1e-7,
|
||||||
void observe(Observable<const GPSStatus *> *source)
|
altitude, dop * 1e-2, heading * 1e-5, numSatellites);
|
||||||
{
|
else
|
||||||
statusObserver.observe(source);
|
DEBUG_MSG("No GPS lock\n");
|
||||||
|
onNewStatus.notifyObservers(this);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool getHasLock() const
|
} // namespace meshtastic
|
||||||
{
|
|
||||||
return hasLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getIsConnected() const
|
|
||||||
{
|
|
||||||
return isConnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getLatitude() const
|
|
||||||
{
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getLongitude() const
|
|
||||||
{
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getAltitude() const
|
|
||||||
{
|
|
||||||
return altitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getDOP() const
|
|
||||||
{
|
|
||||||
return dop;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getHeading() const
|
|
||||||
{
|
|
||||||
return heading;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getNumSatellites() const
|
|
||||||
{
|
|
||||||
return numSatellites;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matches(const GPSStatus *newStatus) const
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
newStatus->hasLock != hasLock ||
|
|
||||||
newStatus->isConnected != isConnected ||
|
|
||||||
newStatus->latitude != latitude ||
|
|
||||||
newStatus->longitude != longitude ||
|
|
||||||
newStatus->altitude != altitude ||
|
|
||||||
newStatus->dop != dop ||
|
|
||||||
newStatus->heading != heading ||
|
|
||||||
newStatus->numSatellites != numSatellites
|
|
||||||
);
|
|
||||||
}
|
|
||||||
int updateStatus(const GPSStatus *newStatus) {
|
|
||||||
// Only update the status if values have actually changed
|
|
||||||
bool isDirty;
|
|
||||||
{
|
|
||||||
isDirty = matches(newStatus);
|
|
||||||
initialized = true;
|
|
||||||
hasLock = newStatus->hasLock;
|
|
||||||
isConnected = newStatus->isConnected;
|
|
||||||
latitude = newStatus->latitude;
|
|
||||||
longitude = newStatus->longitude;
|
|
||||||
altitude = newStatus->altitude;
|
|
||||||
dop = newStatus->dop;
|
|
||||||
heading = newStatus->heading;
|
|
||||||
numSatellites = newStatus->numSatellites;
|
|
||||||
}
|
|
||||||
if(isDirty) {
|
|
||||||
DEBUG_MSG("New GPS pos lat=%f, lon=%f, alt=%d, pdop=%f, heading=%f, sats=%d\n", latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2, heading * 1e-5, numSatellites);
|
|
||||||
onNewStatus.notifyObservers(this);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern meshtastic::GPSStatus *gpsStatus;
|
extern meshtastic::GPSStatus *gpsStatus;
|
@ -81,7 +81,7 @@ void NMEAGPS::loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expect gps pos lat=37.520825, lon=-122.309162, alt=158
|
// expect gps pos lat=37.520825, lon=-122.309162, alt=158
|
||||||
DEBUG_MSG("new NMEA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7,
|
DEBUG_MSG("new NMEA GPS pos lat=%f, lon=%f, alt=%d, hdop=%g, heading=%f\n", latitude * 1e-7, longitude * 1e-7,
|
||||||
altitude, dop * 1e-2, heading * 1e-5);
|
altitude, dop * 1e-2, heading * 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
fix bootloader to use two buttons - remove bootloader hacks
|
fix bootloader to use two buttons - remove bootloader hacks
|
||||||
fix battery voltage sensing
|
fix battery voltage sensing
|
||||||
|
fix floating point SEGGER printf on nrf52 - see "new NMEA GPS pos"
|
||||||
get second button working in app load
|
get second button working in app load
|
||||||
if battery falls too low deassert PWR_ON (to force board to shutdown)
|
if battery falls too low deassert PWR_ON (to force board to shutdown)
|
||||||
fix display width and height
|
fix display width and height
|
||||||
@ -201,7 +202,7 @@ FIXME define/FIX flash access
|
|||||||
#define PIN_SPI_SCK (0 + 19)
|
#define PIN_SPI_SCK (0 + 19)
|
||||||
|
|
||||||
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
||||||
#define USE_SEGGER
|
// #define USE_SEGGER
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user