2010-09-06 17:18:32 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
#include "GPS.h"
|
2010-10-17 01:07:46 -03:00
|
|
|
#include "WProgram.h"
|
2010-09-06 17:18:32 -03:00
|
|
|
|
2010-12-24 02:35:09 -04:00
|
|
|
void
|
|
|
|
GPS::update(void)
|
2010-10-17 17:13:53 -03:00
|
|
|
{
|
2010-12-24 02:35:09 -04:00
|
|
|
bool result;
|
|
|
|
|
|
|
|
// call the GPS driver to process incoming data
|
|
|
|
result = read();
|
|
|
|
|
|
|
|
// if we did not get a message, and the idle timer has expired, re-init
|
|
|
|
if (!result) {
|
|
|
|
if ((millis() - _idleTimer) > _idleTimeout) {
|
|
|
|
_status = NO_GPS;
|
|
|
|
init();
|
2011-04-04 19:00:06 -03:00
|
|
|
|
|
|
|
// reset the idle timer
|
|
|
|
_idleTimer = millis();
|
2010-12-24 02:35:09 -04:00
|
|
|
}
|
2010-10-17 01:07:46 -03:00
|
|
|
} else {
|
2010-12-24 02:35:09 -04:00
|
|
|
// we got a message, update our status correspondingly
|
|
|
|
_status = fix ? GPS_OK : NO_FIX;
|
|
|
|
|
|
|
|
valid_read = true;
|
|
|
|
new_data = true;
|
2010-10-17 01:07:46 -03:00
|
|
|
|
2011-04-04 19:00:06 -03:00
|
|
|
// reset the idle timer
|
|
|
|
_idleTimer = millis();
|
|
|
|
}
|
2010-10-17 17:13:53 -03:00
|
|
|
}
|
2010-12-19 09:24:29 -04:00
|
|
|
|
2011-02-19 14:33:42 -04:00
|
|
|
void
|
|
|
|
GPS::setHIL(long time, float latitude, float longitude, float altitude,
|
|
|
|
float ground_speed, float ground_course, float speed_3d, uint8_t num_sats)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-24 02:35:09 -04:00
|
|
|
// XXX this is probably the wrong way to do it, too
|
2010-12-19 09:24:29 -04:00
|
|
|
void
|
2010-12-24 02:35:09 -04:00
|
|
|
GPS::_error(const char *msg)
|
2010-12-19 09:24:29 -04:00
|
|
|
{
|
2010-12-24 02:35:09 -04:00
|
|
|
Serial.println(msg);
|
2010-12-19 09:24:29 -04:00
|
|
|
}
|