-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPS.ino
31 lines (28 loc) · 933 Bytes
/
GPS.ino
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
void readGPS(){
smartDelay(400);
if(gps.location.isValid()){
latit = gps.location.lat(); longit = gps.location.lng(); }
if(gps.altitude.isValid()){
alto = alt;
alt = gps.altitude.meters();
double currvel = (alt - alto);
vel[0] = vel[1]; vel[1] = vel[2]; vel[2] = vel[3]; vel[3] = vel[4]; vel[4] = currvel;
velDiff = (vel[0] + vel[1] + vel[2] + vel[3] + vel[4])/5;
}
if(gps.time.isValid()){ gpstime = gps.time.value(); }
if(gps.date.isValid()){ gpsdate = gps.date.value(); }
if(gps.satellites.isValid()){ numsats = gps.satellites.value(); }
if(gps.course.isValid()){ course = gps.course.deg(); }
if(gps.speed.isValid()){ speed = gps.speed.mph(); }
delay(10);
}
static void smartDelay(unsigned long ms){
unsigned long start = millis();
do
{
while (Serial2.available() && (!gps.altitude.isUpdated()) ) {
gps.encode(Serial2.read());
}
}
while (millis() - start < ms);
}