sforkowany z mirror/meshtastic-firmware
Use int based lat/long from now on in the device code
for https://github.com/meshtastic/Meshtastic-device/issues/1241.2-legacy
rodzic
29fd8dc7a5
commit
9b309fe0a0
|
@ -9,7 +9,7 @@ Minimum items needed to make sure hardware is good.
|
|||
- plug in correct variants for the real board
|
||||
- Use the PMU driver on real hardware
|
||||
- add a NEMA based GPS driver to test GPS
|
||||
- Use new radio driver on real hardware - possibly start with https://os.mbed.com/teams/Semtech/code/SX126xLib/
|
||||
- Use new radio driver on real hardware
|
||||
- Use UC1701 LCD driver on real hardware. Still need to create at startup and probe on SPI
|
||||
- test the LEDs
|
||||
- test the buttons
|
||||
|
|
2
proto
2
proto
|
@ -1 +1 @@
|
|||
Subproject commit bd002e5a144f209e42c97b64fea9a05a2e513b28
|
||||
Subproject commit cabbdf51ed365b72ab995ad24b075269627f58ad
|
|
@ -48,7 +48,7 @@ void GPS::setup()
|
|||
isConnected = ublox.begin(_serial_gps);
|
||||
|
||||
if (isConnected) {
|
||||
DEBUG_MSG("Connected to GPS successfully\n");
|
||||
DEBUG_MSG("Connected to UBLOX GPS successfully\n");
|
||||
|
||||
bool factoryReset = false;
|
||||
bool ok;
|
||||
|
@ -191,10 +191,10 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
|
|||
if ((fixtype >= 3 && fixtype <= 4) && ublox.getP()) // rd fixes only
|
||||
{
|
||||
// we only notify if position has changed
|
||||
latitude = ublox.getLatitude() * 1e-7;
|
||||
longitude = ublox.getLongitude() * 1e-7;
|
||||
latitude = ublox.getLatitude();
|
||||
longitude = ublox.getLongitude();
|
||||
altitude = ublox.getAltitude() / 1000; // in mm convert to meters
|
||||
DEBUG_MSG("new gps pos lat=%f, lon=%f, alt=%d\n", latitude, longitude, altitude);
|
||||
DEBUG_MSG("new gps pos lat=%f, lon=%f, alt=%d\n", latitude * 1e-7, longitude * 1e-7, altitude);
|
||||
|
||||
hasValidLocation = (latitude != 0) || (longitude != 0); // bogus lat lon is reported as 0,0
|
||||
if (hasValidLocation) {
|
||||
|
|
|
@ -15,7 +15,7 @@ class GPS : public PeriodicTask, public Observable<void *>
|
|||
SFE_UBLOX_GPS ublox;
|
||||
|
||||
public:
|
||||
double latitude, longitude;
|
||||
uint32_t latitude, longitude; // as an int mult by 1e-7 to get value as double
|
||||
uint32_t altitude;
|
||||
bool isConnected; // Do we have a GPS we are talking to
|
||||
|
||||
|
@ -29,7 +29,6 @@ class GPS : public PeriodicTask, public Observable<void *>
|
|||
|
||||
void setup();
|
||||
|
||||
|
||||
virtual void doTask();
|
||||
|
||||
/// If we haven't yet set our RTC this boot, set it from a GPS derived time
|
||||
|
|
|
@ -269,8 +269,7 @@ void MeshService::sendToMesh(MeshPacket *p)
|
|||
if (p->to == nodeDB.getNodeNum()) {
|
||||
DEBUG_MSG("Dropping locally processed message\n");
|
||||
releaseToPool(p);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Note: We might return !OK if our fifo was full, at that point the only option we have is to drop it
|
||||
if (router.send(p) != ERRNO_OK) {
|
||||
DEBUG_MSG("No radio was able to send packet, discarding...\n");
|
||||
|
@ -333,8 +332,8 @@ int MeshService::onGPSChanged(void *unused)
|
|||
if (gps.latitude != 0 || gps.longitude != 0) {
|
||||
if (gps.altitude != 0)
|
||||
pos.altitude = gps.altitude;
|
||||
pos.latitude = gps.latitude;
|
||||
pos.longitude = gps.longitude;
|
||||
pos.latitude_i = gps.latitude;
|
||||
pos.longitude_i = gps.longitude;
|
||||
pos.time = gps.getValidTime();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,3 @@ PB_BIND(ToRadio, ToRadio, 2)
|
|||
|
||||
|
||||
|
||||
#ifndef PB_CONVERT_DOUBLE_FLOAT
|
||||
/* On some platforms (such as AVR), double is really float.
|
||||
* To be able to encode/decode double on these platforms, you need.
|
||||
* to define PB_CONVERT_DOUBLE_FLOAT in pb.h or compiler command line.
|
||||
*/
|
||||
PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -66,11 +66,11 @@ typedef struct _MyNodeInfo {
|
|||
} MyNodeInfo;
|
||||
|
||||
typedef struct _Position {
|
||||
double latitude;
|
||||
double longitude;
|
||||
int32_t altitude;
|
||||
int32_t battery_level;
|
||||
uint32_t time;
|
||||
int32_t latitude_i;
|
||||
int32_t longitude_i;
|
||||
} Position;
|
||||
|
||||
typedef struct _RadioConfig_UserPreferences {
|
||||
|
@ -237,8 +237,8 @@ typedef struct _ToRadio {
|
|||
#define MyNodeInfo_error_code_tag 7
|
||||
#define MyNodeInfo_error_address_tag 8
|
||||
#define MyNodeInfo_error_count_tag 9
|
||||
#define Position_latitude_tag 1
|
||||
#define Position_longitude_tag 2
|
||||
#define Position_latitude_i_tag 7
|
||||
#define Position_longitude_i_tag 8
|
||||
#define Position_altitude_tag 3
|
||||
#define Position_battery_level_tag 4
|
||||
#define Position_time_tag 6
|
||||
|
@ -297,11 +297,11 @@ typedef struct _ToRadio {
|
|||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define Position_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, DOUBLE, latitude, 1) \
|
||||
X(a, STATIC, SINGULAR, DOUBLE, longitude, 2) \
|
||||
X(a, STATIC, SINGULAR, INT32, altitude, 3) \
|
||||
X(a, STATIC, SINGULAR, INT32, battery_level, 4) \
|
||||
X(a, STATIC, SINGULAR, UINT32, time, 6)
|
||||
X(a, STATIC, SINGULAR, UINT32, time, 6) \
|
||||
X(a, STATIC, SINGULAR, INT32, latitude_i, 7) \
|
||||
X(a, STATIC, SINGULAR, INT32, longitude_i, 8)
|
||||
#define Position_CALLBACK NULL
|
||||
#define Position_DEFAULT NULL
|
||||
|
||||
|
@ -486,21 +486,21 @@ extern const pb_msgdesc_t ToRadio_msg;
|
|||
#define ToRadio_fields &ToRadio_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define Position_size 46
|
||||
#define Position_size 50
|
||||
#define Data_size 256
|
||||
#define User_size 72
|
||||
/* RouteDiscovery_size depends on runtime parameters */
|
||||
#define SubPacket_size 383
|
||||
#define MeshPacket_size 425
|
||||
#define SubPacket_size 387
|
||||
#define MeshPacket_size 429
|
||||
#define ChannelSettings_size 44
|
||||
#define RadioConfig_size 120
|
||||
#define RadioConfig_UserPreferences_size 72
|
||||
#define NodeInfo_size 138
|
||||
#define NodeInfo_size 142
|
||||
#define MyNodeInfo_size 85
|
||||
#define DeviceState_size 18925
|
||||
#define DeviceState_size 19185
|
||||
#define DebugString_size 258
|
||||
#define FromRadio_size 434
|
||||
#define ToRadio_size 428
|
||||
#define FromRadio_size 438
|
||||
#define ToRadio_size 432
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
@ -280,7 +280,7 @@ static float estimatedHeading(double lat, double lon)
|
|||
/// valid lat/lon
|
||||
static bool hasPosition(NodeInfo *n)
|
||||
{
|
||||
return n->has_position && (n->position.latitude != 0 || n->position.longitude != 0);
|
||||
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
||||
}
|
||||
|
||||
/// We will skip one node - the one for us, so we just blindly loop over all
|
||||
|
@ -288,6 +288,9 @@ static bool hasPosition(NodeInfo *n)
|
|||
static size_t nodeIndex;
|
||||
static int8_t prevFrame = -1;
|
||||
|
||||
/// Convert an integer GPS coords to a floating point
|
||||
#define DegD(i) (i * 1e-7)
|
||||
|
||||
static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
// We only advance our nodeIndex if the frame # has changed - because
|
||||
|
@ -334,7 +337,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||
NodeInfo *ourNode = nodeDB.getNode(nodeDB.getNodeNum());
|
||||
if (ourNode && hasPosition(ourNode) && hasPosition(node)) {
|
||||
Position &op = ourNode->position, &p = node->position;
|
||||
float d = latLongToMeter(p.latitude, p.longitude, op.latitude, op.longitude);
|
||||
float d = latLongToMeter(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
||||
if (d < 2000)
|
||||
snprintf(distStr, sizeof(distStr), "%.0f m", d);
|
||||
else
|
||||
|
@ -342,8 +345,8 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||
|
||||
// FIXME, also keep the guess at the operators heading and add/substract
|
||||
// it. currently we don't do this and instead draw north up only.
|
||||
float bearingToOther = bearing(p.latitude, p.longitude, op.latitude, op.longitude);
|
||||
float myHeading = estimatedHeading(p.latitude, p.longitude);
|
||||
float bearingToOther = bearing(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
||||
float myHeading = estimatedHeading(DegD(p.latitude_i), DegD(p.longitude_i));
|
||||
headingRadian = bearingToOther - myHeading;
|
||||
} else {
|
||||
// Debug info for gps lock errors
|
||||
|
|
Ładowanie…
Reference in New Issue