Commit 7fe7780c authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Restarting work on GPS tracking

parent 2fdff57b
......@@ -50,12 +50,13 @@ static int firstrun, firstfix;
static int gpson, pgpson;
static int track, ptrack;
static void gps_set_time();
static void gps_track();
static void gpsbkgnd_task(void *params)
{
(void) params;
struct event e;
struct tm time;
struct gps_utc gpstime;
/* Previous and current state of GPS ON setting */
pgpson = gpson;
......@@ -74,26 +75,10 @@ static void gpsbkgnd_task(void *params)
return;
}
/* Set time from GPS at first fix or midday */
if (setting_get(&setting_gps_sets_time) && gps_fixed()) {
time = clock_get_time();
if (firstfix ||
((time.tm_hour == 12) && (time.tm_min == 0))) {
gps_get_utc(&gpstime);
time.tm_year = gpstime.yr;
time.tm_mon = gpstime.mon;
time.tm_mday = gpstime.day;
time.tm_hour = gpstime.hr + setting_get(&setting_gmt_ofs_hr);
time.tm_min = gpstime.min + setting_get(&setting_gmt_ofs_min);
time.tm_sec = gpstime.sec;
time.tm_isdst = 0;
clock_set_time(&time);
}
if (firstfix) firstfix = 0;
/* Set time and track according to setting */
if (gps_fixed()) {
if (setting_get(&setting_gps_sets_time))
gps_set_time();
}
if (firstrun)
......@@ -114,3 +99,27 @@ void gpsbkgnd_init()
xTimerStart(timerGps, 0);
}
static void gps_set_time()
{
struct tm time;
struct gps_utc gpstime;
time = clock_get_time();
if (firstfix ||
((time.tm_hour == 12) && (time.tm_min == 0))) {
gps_get_utc(&gpstime);
time.tm_year = gpstime.yr;
time.tm_mon = gpstime.mon;
time.tm_mday = gpstime.day;
time.tm_hour = gpstime.hr + setting_get(&setting_gmt_ofs_hr);
time.tm_min = gpstime.min + setting_get(&setting_gmt_ofs_min);
time.tm_sec = gpstime.sec;
time.tm_isdst = 0;
clock_set_time(&time);
}
if (firstfix) firstfix = 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment