-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGPS.cpp
86 lines (77 loc) · 1.78 KB
/
GPS.cpp
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
/**
* @file ?/GPS.cpp
* @version 0.6
*
* @section License
* Copyright (C) 2014-2015, jeditekunum
*
* 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, or (at your option) any later version.
*
* 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.
*
*/
#include "GPS.hh"
void
GPS::reset(void)
{
m_last_update = 0;
m_date = 0;
m_time = 0;
#ifndef GPS_TIME_ONLY
m_latitude = 0;
m_longitude = 0;
m_altitude = 0;
m_course = 0;
m_speed = 0;
m_satellites = 0;
m_hdop = 0;
#endif
}
clock_t
GPS::clock(void)
{
uint32_t tmp;
time_t t;
/* Extract time */
tmp = m_time / 1000; // Discard milliseconds
t.seconds = tmp % 100;
tmp /= 100;
t.minutes = tmp % 100;
tmp /= 100;
t.hours = tmp;
/* Extract date */
tmp = m_date;
t.year = tmp % 100;
tmp /= 100;
t.month = tmp % 100;
tmp /= 100;
t.date = tmp;
t.day = 0; // unknown
return (clock_t(t));
}
IOStream&
operator<<(IOStream& outs, GPS& gps)
{
outs
<< PSTR("GPS::V=") << (gps.valid() ? PSTR("t") : PSTR("f"))
<< PSTR(",U=") << gps.last_update()
<< PSTR(",D=") << gps.date()
<< PSTR(",T=") << gps.time()
#ifndef GPS_TIME_ONLY
<< PSTR(",LA=") << gps.f_latitude()
<< PSTR(",LO=") << gps.f_longitude()
<< PSTR(",A=") << gps.f_altitude()
<< PSTR(",C=") << gps.f_course()
<< PSTR(",SP=") << gps.f_speed()
<< PSTR(",SA=") << gps.satellites()
<< PSTR(",H=") << gps.f_hdop()
#endif
;
return (outs);
}