Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 433 → Rev 434

/FollowMe/trunk/gpx.c
60,10 → 60,7
#include "gpx.h"
#include "gpx_header.h"
#include "timer0.h"
//#include "spi_slave.h"
#include "main.h"
#include "uart1.h"
#include "ubx.h"
 
//________________________________________________________________________________________________________________________________________
// Function: GPX_DocumentInit(GPX_Document_t *)
95,6 → 92,9
{
 
uint8_t retvalue = 0;
uint16_t i;
int8_t c;
const prog_char *str;
 
if(doc == NULL) return(0);
GPX_DocumentInit(doc); // intialize the document with resetvalues
103,8 → 103,13
if(doc->file != NULL) // could the file be opened?
{
retvalue = 1; // the document could be created on the drive.
doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened.
fwrite_((void*)GPX_DOCUMENT_HEADER, sizeof(GPX_DOCUMENT_HEADER)-1,1,doc->file);// write the gpx-header to the document.
doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened.
str = GPX_DOCUMENT_HEADER; // write the gpx-header to the document..
for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
}
 
return(retvalue);
123,6 → 128,9
{
 
uint8_t retvalue = 1;
uint16_t i;
int8_t c;
const prog_char *str;
 
if(doc == NULL) return(0);
 
141,7 → 149,12
case GPX_DOC_OPENED: // close the file on the memorycard
if(doc->file != NULL)
{
fwrite_((void*)GPX_DOCUMENT_FOOTER, sizeof(GPX_DOCUMENT_FOOTER)-1,1,doc->file); // write the gpx-footer to the document.
str = GPX_DOCUMENT_FOOTER; // write the gpx-footer to the document.
for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
fclose_(doc->file);
retvalue = 1;
}
169,6 → 182,11
{
 
uint8_t retvalue = 0;
uint16_t i;
int8_t c;
const prog_char *str;
 
 
if(doc->state == GPX_DOC_OPENED)
{
if(doc->file != NULL)
175,7 → 193,12
{
doc->state = GPX_DOC_TRACK_OPENED;
retvalue = 1;
fwrite_((void*)GPX_TRACK_HEADER, sizeof(GPX_TRACK_HEADER)-1,1,doc->file);
str = GPX_TRACK_HEADER;
for(i= 0; i < sizeof(GPX_TRACK_HEADER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
}
}
return(retvalue);
194,6 → 217,9
{
 
uint8_t retvalue = 0;
uint16_t i;
int8_t c;
const prog_char *str;
 
if(doc->state == GPX_DOC_TRACK_OPENED)
{
200,8 → 226,12
if(doc->file != NULL)
{
doc->state = GPX_DOC_OPENED;
fwrite_((void*)GPX_TRACK_FOOTER, sizeof(GPX_TRACK_FOOTER)-1,1,doc->file);
retvalue = 1;
str = GPX_TRACK_FOOTER;
for(i= 0; i < sizeof(GPX_TRACK_FOOTER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
}
}
 
221,6 → 251,9
{
 
uint8_t retvalue = 0;
uint16_t i;
int8_t c;
const prog_char *str;
 
if(doc->state == GPX_DOC_TRACK_OPENED)
{
227,7 → 260,12
if(doc->file != NULL)
{
doc->state = GPX_DOC_TRACKSEGMENT_OPENED;
fwrite_((void*)GPX_TRACKSEGMENT_HEADER, sizeof(GPX_TRACKSEGMENT_HEADER)-1,1,doc->file);
str = GPX_TRACKSEGMENT_HEADER;
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
retvalue = 1;
}
}
247,12 → 285,22
{
 
uint8_t retvalue = 0;
uint16_t i;
int8_t c;
const prog_char *str;
 
 
if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED)
{
if(doc->file != NULL)
{
doc->state = GPX_DOC_TRACK_OPENED;
fwrite_((void*)GPX_TRACKSEGMENT_FOOTER, sizeof(GPX_TRACKSEGMENT_FOOTER)-1,1,doc->file);
str = GPX_TRACKSEGMENT_FOOTER;
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER); i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
}
retvalue = 1;
}
}