-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWiGPS.h
More file actions
132 lines (97 loc) · 3.6 KB
/
WiGPS.h
File metadata and controls
132 lines (97 loc) · 3.6 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
Copyright 2013 Daniele Faugiana
This file is part of "WiGPS Arduino Library".
"WiGPS Arduino Library" is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
"WiGPS Arduino Library" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "WiGPS Arduino Library". If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WIGPS_H
#define _WIGPS_H
#if defined(ARDUINO) && ARDUINO >= 100
#include <arduino.h>
#elif defined(SPARK)
#include "application.h" //needs to be placed in extra classes
#endif
#include "GPRMC.h"
/*****************
* Data constants
*****************/
#define KMKNOT 1.852
#define DEGREE_CHAR 0xDF
#define PROTOCOL "GPRMC"
#define BUFFER_LENGTH_2 75 //Had to change the name because made conflict with some other SparkCore define named BUFFER_LENGTH
/*******************
* GPS POWER STATES
*******************/
#define ON 1
#define OFF 0
/**************
* ERROR CODES
**************/
#if !defined TRUE
#define TRUE 1
#endif
#if !defined FALSE
#define FALSE 0
#endif
/*************
* TYPEDEFS
*************/
typedef unsigned int uint;
typedef unsigned char uchar;
class WiGPS {
private:
/***************
* PRIVATE VARS
***************/
//Port serialPort; // A pointer to the serial port the GPS communicates through
uint portType; // Port type, see upside to understand types
uint powerPort; // The pin Arduino uses to activate/deactivate the GPS
bool powerState; // Power state of the GPS
int hours; // Last UTC time data from the GPS
int minutes;
int seconds;
//int milliseconds;
int day; // Last UTC date data from the GPS
int month;
int year;
int latitudeDeg; // Last Latitude data from the GPS
int latitudeMin;
int latitudeSec;
char latitudeRef;
int longitudeDeg; // Last Longitude data from the GPS
int longitudeMin;
int longitudeSec;
char longitudeRef;
int Speed; // Last speed from the GPS (km/h)
int Course; // Last course over ground (degrees from the north)
int dataReady; // Data ready to be read
/******************
* PRIVATE METHODS
******************/
void parseGPRMC(GPRMC*); // Extract data from the GPRMC String
public:
/*****************
* PUBLIC METHODS
*****************/
WiGPS(int);
void init(int);
int on(void); // Powers on the GPS module
int off(void); // Turns off the GPS module and stop tracking data
bool update(void); // Starts fetching data from the GPS.
String time(void); // Returns an Arduino String object for the UTC time
String date(void); // Returns an Arduino String object for the UTC date
String latitude(void); // Returns an Arduino String object for the latitude
String longitude(void); // Returns an Arduino String object for the longitude
String speed(void); // Returns an Arduino String object for the speed
String course(void); // Returns an Arduino String object for the course
~WiGPS();
};
#endif