Repository navigation
Expand file tree
/
Copy pathLGPS.h
More file actions
284 lines (228 loc) · 6.33 KB
/
Copy pathLGPS.h
File metadata and controls
284 lines (228 loc) · 6.33 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
Copyright (c) 2014 MediaTek Inc. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License..
This 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 Lesser General Public License for more details.
*/
#ifndef _LGPS_H
#define _LGPS_H
/*!
\def GPS_DEVICE_ADDR
The I2C address GPS
\def GPS_SCAN_ID
The id of scan data, the format is 0,0,0,Device address
\def GPS_SCAN_SIZE
The length of scan data
\def GPS_UTC_DATE_TIME_ID
The id of utc date and time, the format is YMDHMS
\def GPS_UTC_DATE_TIME_SIZE
The length of utc date and time data
\def GPS_STATUS_ID
The id of GPS status, the format is A/V
\def GPS_STATUS_SIZE
The length of GPS status data
\def GPS_LATITUDE_ID
The id of latitude, the format is dd.dddddd
\def GPS_LATITUDE_SIZE
The length of latitude data
\def GPS_NS_ID
The id of latitude direction, the format is N/S
\def GPS_NS_SIZE
The length of latitude direction data
\def GPS_LONGITUDE_ID
The id of longitude, the format is ddd.dddddd
\def GPS_LONGITUDE_SIZE
The length of longitude data
\def GPS_EW_ID
The id of longitude direction, the format is E/W
\def GPS_EW_SIZE
The length of longitude direction data
\def GPS_SPEED_ID
The id of speed, the format is 000.0~999.9 Knots
\def GPS_SPEED_SIZE
The length of speed data
\def GPS_COURSE_ID
The id of course, the format is 000.0~359.9
\def GPS_COURSE_SIZE
The length of course data
\def GPS_POSITION_FIX_ID
The id of position fix status, the format is 0,1,2,6
\def GPS_POSITION_FIX_SIZE
The length of position fix status data
\def GPS_SATE_USED_ID
The id of state used, the format is 00~12
\def GPS_SATE_USED_SIZE
The length of sate used data
\def GPS_ALTITUDE_ID
The id of altitude, the format is -9999.9~99999.9
\def GPS_ALTITUDE_SIZE
The length of altitude data
\def GPS_MODE_ID
The id of locate mode, the format is A/M
\def GPS_MODE_SIZE
The length of locate mode data
\def GPS_MODE2_ID
The id of current status, the format is 1,2,3
\def GPS_MODE2_SIZE
The length of current status data
\def GPS_SATE_IN_VIEW_ID
The id of sate in view
\def GPS_SATE_IN_VIEW_SIZE
The length of sate in view data
*/
/* Data format:
* ID(1 byte), Data length(1 byte), Data 1, Data 2, ... Data n (n bytes, n = data length)
* For example, get the scan data.
* First, Send GPS_SCAN_ID(1 byte) to device.
* Second, Receive scan data(ID + Data length + GPS_SCAN_SIZE = 6 bytes).
* Third, The scan data begin from the third data of received.
* End
*/
#define GPS_DEVICE_ADDR 0x05
#define GPS_SCAN_ID 0 // 4 bytes
#define GPS_SCAN_SIZE 4 // 0,0,0,Device address
#define GPS_UTC_DATE_TIME_ID 1 // YMDHMS
#define GPS_UTC_DATE_TIME_SIZE 6 // 6 bytes
#define GPS_STATUS_ID 2 // A/V
#define GPS_STATUS_SIZE 1 // 1 byte
#define GPS_LATITUDE_ID 3 // dd.dddddd
#define GPS_LATITUDE_SIZE 9 // 9 bytes
#define GPS_NS_ID 4 // N/S
#define GPS_NS_SIZE 1 // 1 byte
#define GPS_LONGITUDE_ID 5 // ddd.dddddd
#define GPS_LONGITUDE_SIZE 10 // 10 bytes
#define GPS_EW_ID 6 // E/W
#define GPS_EW_SIZE 1 // 1 byte
#define GPS_SPEED_ID 7 // 000.0~999.9 Knots
#define GPS_SPEED_SIZE 5 // 5 bytes
#define GPS_COURSE_ID 8 // 000.0~359.9
#define GPS_COURSE_SIZE 5 // 5 bytes
#define GPS_POSITION_FIX_ID 9 // 0,1,2,6
#define GPS_POSITION_FIX_SIZE 1 // 1 byte
#define GPS_SATE_USED_ID 10 // 00~12
#define GPS_SATE_USED_SIZE 2 // 2 bytes
#define GPS_ALTITUDE_ID 11 // -9999.9~99999.9
#define GPS_ALTITUDE_SIZE 7 // 7 bytes
#define GPS_MODE_ID 12 // A/M
#define GPS_MODE_SIZE 1 // 1 byte
#define GPS_MODE2_ID 13 // 1,2,3
#define GPS_MODE2_SIZE 1 // 1 byte
#define GPS_SATE_IN_VIEW_ID 14 // 0~12
#define GPS_SATE_IN_VIEW_SIZE 1 // 1 byte
class LGPSClass
{
public:
/**
* \brief Get the status of the device.
*
* \return Return TRUE or FALSE. TRUE is on line, FALSE is off line.
*
*/
unsigned char check_on_line(void);
/**
* \brief Get the utc date and time.
*
* \return Return the pointer of utc date sand time, the format is YMDHMS.
*
*/
unsigned char* get_utc_date_time(void);
/**
* \brief Get the status of GPS.
*
* \return Return A or V. A is orientation, V is navigation.
*
*/
unsigned char get_status(void);
/**
* \brief Get the altitude.
*
* \return Return altitude data. The format is dd.dddddd.
*
*/
float get_latitude(void);
/**
* \brief Get the altitude direction.
*
* \return Return altitude direction data. The format is N/S. N is north, S is south.
*
*/
unsigned char get_ns(void);
/**
* \brief Get the longitude.
*
* \return Return longitude data. The format is ddd.dddddd.
*
*/
float get_longitude(void);
/**
* \brief Get the longitude direction.
*
* \return Return longitude direction data. The format is E/W. E is east, W is west.
*
*/
unsigned char get_ew(void);
/**
* \brief Get the speed.
*
* \return Return speed data. The format is 000.0~999.9 Knots.
*
*/
float get_speed(void);
/**
* \brief Get the course.
*
* \return Return course data. The format is 000.0~359.9.
*
*/
float get_course(void);
/**
* \brief Get the status of position fix.
*
* \return Return course data. The format is 0,1,2,6.
*
*/
unsigned char get_position_fix(void);
/**
* \brief Get the number of state used。
*
* \return Return number of state used. The format is 0-12.
*
*/
unsigned char get_sate_used(void);
/**
* \brief Get the altitude。 the format is -9999.9~99999.9
*
* \return Return altitude data. The format is -9999.9~99999.9.
*
*/
float get_altitude(void);
/**
* \brief Get the mode of location.
*
* \return Return mode of location. The format is A/M. A:automatic, M:manual.
*
*/
unsigned char get_mode(void);
/**
* \brief Get the current status of GPS.
*
* \return Return current status. The format is 1,2,3. 1:null, 2:2D, 3:3D.
*
*/
unsigned char get_mode2(void);
/**
* \brief Get the number of sate in view.
*
* \return Return the number of sate in view.
*
*/
unsigned char get_sate_in_view(void);
private:
};
extern LGPSClass LGPS;
#endif