-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGps.h
More file actions
87 lines (81 loc) · 2.37 KB
/
Gps.h
File metadata and controls
87 lines (81 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef Gps_h
#define Gps_h
/*
* gps
*
* Library to manage a gps device with tinyGPS++
*
* Greg Cope <greg.cope@gmail.com>
*
*/
#include <Arduino.h>
// https://github.com/mikalhart/TinyGPSPlus/releases
#include <TinyGPS++.h>
#include "Sleep.h"
// Notes
// converting rawLat deg / billionths into longs
// https://www.disk91.com/2016/technology/internet-of-things-technology/simple-lora-gps-tracker-based-on-rn2483-and-l80/
// payload testing
// https://ukhas.org.uk/guides:common_coding_errors_payload_testing
// simple GPS lib
// http://www.technoblogy.com/show?10WT
// distance using lat/lon * 1000000
// https://forum.arduino.cc/index.php?topic=393511.msg3232854#msg3232854
// we have billionths
// e.g. 0.449678333*1000000000 = 449678333
// debug functions
#define DEBUG(input) {Serial.print(input); Serial.flush();}
#define DEBUGln(input) {Serial.println(input); Serial.flush();}
//#define ACCEPTABLE_GPS_HDOP_FOR_FIX 200 // was 160
//#define GOOD_GPS_HDOP_FOR_FIX 145
#define ACCEPTABLE_GPS_HDOP_FOR_FIX 400 // was 160
#define GOOD_GPS_HDOP_FOR_FIX 200
class Gps
{
public:
Gps(byte pin);
boolean on(void);
void off(void);
boolean isOn(void);
boolean updateFix(unsigned long, int);
unsigned long getInitialFix(unsigned long);
boolean getUpdatedFix(unsigned long, int);
boolean drainNmea(void);
char* getdateTime(void);
//void getdateTime(char*);
void init(void);
void getLocation(double&, double&);
void getLocationBillionths(long&, long&);
void getRawLocation(char &charLat, char &charLon);
//double distanceMoved(double, double);
void distanceMoved(double&, double&, double&);
double haversine(double, double, double, double);
private:
int _powerPin;
boolean _powerState;
boolean nmeaOutput;
int nmeaUpdates;
unsigned long nmeaTimeoutMs;
boolean serial1Output;
unsigned long gpsFixTimeoutMs;
unsigned long now;
unsigned long gpsTimerStart;
unsigned long gpsTimeToFixMs;
boolean gpsFixTimeoutReached;
void setupGPS(void);
void printGPSData(void);
int initialHDOP;
int finalHDOP;
int hdop;
TinyGPSPlus nmea;
TinyGPSCustom antenna;
TinyGPSCustom fixqual;
Sleep sleep;
char _dateTime[17];
//int nmeaUpdated;
double _distance;
long billion = 1000000000L;
long latBillionths;
long lonBillionths;
};
#endif