Commit 5f40efa3 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Work towards track file naming, no particular progress

parent 87a0e9ca
...@@ -51,8 +51,9 @@ static xTimerHandle timerGps; ...@@ -51,8 +51,9 @@ static xTimerHandle timerGps;
extern xSemaphoreHandle mutexSdCardAccess; extern xSemaphoreHandle mutexSdCardAccess;
static int firstrun, firstfix; static int firstrun, firstfix;
static int cgpson, pgpson; static int gpson, pgpson;
static int ctrack, ptrack; static int track, ptrack;
static int open = 0;
static FIL f; static FIL f;
static FATFS fatfs; static FATFS fatfs;
...@@ -72,14 +73,14 @@ static void gpsbkgnd_task(void *params) ...@@ -72,14 +73,14 @@ static void gpsbkgnd_task(void *params)
char buf[80]; char buf[80];
/* Previous and current state of settings */ /* Previous and current state of settings */
pgpson = cgpson; pgpson = gpson;
cgpson = setting_get(&setting_gps_on); gpson = setting_get(&setting_gps_on);
/* Pulse GPS ON_OFF pin if setting changed */ /* Pulse GPS ON_OFF pin if setting changed */
if ((pgpson != cgpson) && !firstrun) if ((pgpson != gpson) && !firstrun)
gps_on_off_pulse(); gps_on_off_pulse();
if (!cgpson) { if (!gpson) {
/* Turn off status bar icon if GPS turns off */ /* Turn off status bar icon if GPS turns off */
if (pgpson) { if (pgpson) {
e.type = GPS_OFF; e.type = GPS_OFF;
...@@ -111,34 +112,46 @@ static void gpsbkgnd_task(void *params) ...@@ -111,34 +112,46 @@ static void gpsbkgnd_task(void *params)
} }
/* Track GPS position if setting tells us to */ /* Track GPS position if setting tells us to */
ptrack = ctrack; ptrack = track;
ctrack = setting_get(&setting_tracking); track = setting_get(&setting_tracking);
if (ctrack) { if (track) {
/* Init stuff, open file & take semaphore so that only we write to SD */ /* Init stuff & take semaphore so that only we write to SD */
if (firstrun || !ptrack) { if (firstrun || !ptrack) {
xSemaphoreTake(mutexSdCardAccess, 0); xSemaphoreTake(mutexSdCardAccess, 0);
MICROSD_Init(); MICROSD_Init();
disk_initialize(0); disk_initialize(0);
f_mount(0, &fatfs); f_mount(0, &fatfs);
f_open(&f, "yellow", FA_CREATE_ALWAYS | FA_WRITE); f_open(&f, "blah", FA_CREATE_ALWAYS | FA_WRITE);
f_lseek(&f, 0); f_lseek(&f, 0);
open = 1;
} }
/* Write to file if gps is fixed */ /* Write to file if gps is fixed */
if (gps_fixed()) { if (gps_fixed()) {
// if (open) {
// open = 0;
// gps_get_utc(&gpstime);
// sprintf(buf, "track_%d-%d-%d_%dh%dm", 1900 + gpstime.yr,
// 1 + gpstime.mon, gpstime.day,
// gpstime.hr + setting_get(&setting_gmt_ofs_hr),
// gpstime.min + setting_get(&setting_gmt_ofs_min));
// f_open(&f, buf, FA_CREATE_ALWAYS | FA_WRITE);
// f_lseek(&f, 0);
// }
gps_get_coord(&gpscoord, 2); gps_get_coord(&gpscoord, 2);
sprintf(buf, "%3.7f,%3.7f\n", gpscoord.lat, gpscoord.lon); sprintf(buf, "%3.7f,%3.7f\n", gpscoord.lat, gpscoord.lon);
f_write(&f, buf, strlen(buf), NULL); f_write(&f, buf, strlen(buf), NULL);
} }
} else if (!ctrack && ptrack) { } else if (!track && ptrack) {
/* /*
* Turned off tracking setting => close file, deinit microsd driver and * Turned off tracking setting => close file, deinit microsd driver and
* give mutex so that other tasks can use the SD card * give mutex so that other tasks can use the SD card
*/ */
f_close(&f); f_close(&f);
MICROSD_Deinit(); MICROSD_Deinit();
open = 1;
xSemaphoreGive(mutexSdCardAccess); xSemaphoreGive(mutexSdCardAccess);
} }
......
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