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; ...@@ -50,12 +50,13 @@ static int firstrun, firstfix;
static int gpson, pgpson; static int gpson, pgpson;
static int track, ptrack; static int track, ptrack;
static void gps_set_time();
static void gps_track();
static void gpsbkgnd_task(void *params) static void gpsbkgnd_task(void *params)
{ {
(void) params; (void) params;
struct event e; struct event e;
struct tm time;
struct gps_utc gpstime;
/* Previous and current state of GPS ON setting */ /* Previous and current state of GPS ON setting */
pgpson = gpson; pgpson = gpson;
...@@ -74,26 +75,10 @@ static void gpsbkgnd_task(void *params) ...@@ -74,26 +75,10 @@ static void gpsbkgnd_task(void *params)
return; return;
} }
/* Set time from GPS at first fix or midday */ /* Set time and track according to setting */
if (setting_get(&setting_gps_sets_time) && gps_fixed()) { if (gps_fixed()) {
time = clock_get_time(); if (setting_get(&setting_gps_sets_time))
gps_set_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;
} }
if (firstrun) if (firstrun)
...@@ -114,3 +99,27 @@ void gpsbkgnd_init() ...@@ -114,3 +99,27 @@ void gpsbkgnd_init()
xTimerStart(timerGps, 0); 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