This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgps.h
65 lines (47 loc) · 1.57 KB
/
gps.h
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
#if !defined __DEF_NMEA_H__
#define __DEF_NMEA_H__
#include "defines.h"
/* Timestamp: Seconds since first day of month 00:00 */
typedef uint32_t timestamp_t;
typedef struct _Date {
uint16_t year;
uint8_t month;
uint8_t day;
} date_t;
/* Position report */
typedef struct _PosData {
float latitude;
float longitude;
float speed, altitude;
uint16_t course;
timestamp_t timestamp;
} posdata_t;
/* Access to current position. Note that current_time can be
* different from timestamp in current_pos since GPS is not always in fix
*/
extern posdata_t current_pos;
extern timestamp_t current_time;
extern date_t current_date;
#define TIME_STR(buf) time2str((buf), current_time)
#define DATE_STR(buf) date2str((buf), current_date)
#define TIME_HOUR(time) (uint8_t) (((time) / 3600) % 24)
/* API */
void gps_init(SerialDriver*, Stream*);
posdata_t* gps_get_pos(void);
timestamp_t gps_get_time(void);
date_t gps_get_date(void);
uint32_t gps_distance(posdata_t*, posdata_t*);
uint16_t gps_bearing(posdata_t *from, posdata_t *to);
void gps_mon_pos (void);
void gps_mon_raw (void);
void gps_mon_off (void);
bool gps_is_fixed (void);
bool gps_wait_fix (uint16_t);
char* pos2str_lat(char*, posdata_t*);
char* pos2str_long(char*, posdata_t*);
char* datetime2str(char*, date_t, timestamp_t);
char* time2str (char*, timestamp_t);
char* date2str (char*, date_t);
void gps_on(void);
void gps_off(void);
#endif