Rev 434 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 434 | Rev 436 | ||
---|---|---|---|
Line 103... | Line 103... | ||
103 | if(doc->file != NULL) // could the file be opened? |
103 | if(doc->file != NULL) // could the file be opened? |
104 | { |
104 | { |
105 | retvalue = 1; // the document could be created on the drive. |
105 | retvalue = 1; // the document could be created on the drive. |
106 | doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
106 | doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
107 | str = GPX_DOCUMENT_HEADER; // write the gpx-header to the document.. |
107 | str = GPX_DOCUMENT_HEADER; // write the gpx-header to the document.. |
108 | for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER); i++) |
108 | for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER)-1; i++) |
109 | { |
109 | { |
110 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
110 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
111 | fputc_(c, doc->file); // and write that to sd-card |
111 | fputc_(c, doc->file); // and write that to sd-card |
112 | } |
112 | } |
113 | } |
113 | } |
Line 148... | Line 148... | ||
148 | 148 | ||
149 | case GPX_DOC_OPENED: // close the file on the memorycard |
149 | case GPX_DOC_OPENED: // close the file on the memorycard |
150 | if(doc->file != NULL) |
150 | if(doc->file != NULL) |
151 | { |
151 | { |
152 | str = GPX_DOCUMENT_FOOTER; // write the gpx-footer to the document. |
152 | str = GPX_DOCUMENT_FOOTER; // write the gpx-footer to the document. |
153 | for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER); i++) |
153 | for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER)-1; i++) |
154 | { |
154 | { |
155 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
155 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
156 | fputc_(c, doc->file); // and write that to sd-card |
156 | fputc_(c, doc->file); // and write that to sd-card |
157 | } |
157 | } |
Line 192... | Line 192... | ||
192 | if(doc->file != NULL) |
192 | if(doc->file != NULL) |
193 | { |
193 | { |
194 | doc->state = GPX_DOC_TRACK_OPENED; |
194 | doc->state = GPX_DOC_TRACK_OPENED; |
195 | retvalue = 1; |
195 | retvalue = 1; |
196 | str = GPX_TRACK_HEADER; |
196 | str = GPX_TRACK_HEADER; |
197 | for(i= 0; i < sizeof(GPX_TRACK_HEADER); i++) |
197 | for(i= 0; i < sizeof(GPX_TRACK_HEADER)-1; i++) |
198 | { |
198 | { |
199 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
199 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
200 | fputc_(c, doc->file); // and write that to sd-card |
200 | fputc_(c, doc->file); // and write that to sd-card |
201 | } |
201 | } |
202 | } |
202 | } |
Line 225... | Line 225... | ||
225 | { |
225 | { |
226 | if(doc->file != NULL) |
226 | if(doc->file != NULL) |
227 | { |
227 | { |
228 | doc->state = GPX_DOC_OPENED; |
228 | doc->state = GPX_DOC_OPENED; |
229 | str = GPX_TRACK_FOOTER; |
229 | str = GPX_TRACK_FOOTER; |
230 | for(i= 0; i < sizeof(GPX_TRACK_FOOTER); i++) |
230 | for(i= 0; i < sizeof(GPX_TRACK_FOOTER)-1; i++) |
231 | { |
231 | { |
232 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
232 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
233 | fputc_(c, doc->file); // and write that to sd-card |
233 | fputc_(c, doc->file); // and write that to sd-card |
234 | } |
234 | } |
235 | } |
235 | } |
Line 259... | Line 259... | ||
259 | { |
259 | { |
260 | if(doc->file != NULL) |
260 | if(doc->file != NULL) |
261 | { |
261 | { |
262 | doc->state = GPX_DOC_TRACKSEGMENT_OPENED; |
262 | doc->state = GPX_DOC_TRACKSEGMENT_OPENED; |
263 | str = GPX_TRACKSEGMENT_HEADER; |
263 | str = GPX_TRACKSEGMENT_HEADER; |
264 | for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER); i++) |
264 | for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER)-1; i++) |
265 | { |
265 | { |
266 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
266 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
267 | fputc_(c, doc->file); // and write that to sd-card |
267 | fputc_(c, doc->file); // and write that to sd-card |
268 | } |
268 | } |
269 | retvalue = 1; |
269 | retvalue = 1; |
Line 294... | Line 294... | ||
294 | { |
294 | { |
295 | if(doc->file != NULL) |
295 | if(doc->file != NULL) |
296 | { |
296 | { |
297 | doc->state = GPX_DOC_TRACK_OPENED; |
297 | doc->state = GPX_DOC_TRACK_OPENED; |
298 | str = GPX_TRACKSEGMENT_FOOTER; |
298 | str = GPX_TRACKSEGMENT_FOOTER; |
299 | for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER); i++) |
299 | for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER)-1; i++) |
300 | { |
300 | { |
301 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
301 | c = (int8_t)pgm_read_byte(str++); // get byte from flash |
302 | fputc_(c, doc->file); // and write that to sd-card |
302 | fputc_(c, doc->file); // and write that to sd-card |
303 | } |
303 | } |
304 | retvalue = 1; |
304 | retvalue = 1; |
Line 344... | Line 344... | ||
344 | if(GPSData.Position.Longitude < 0) u8_1 = '-'; |
344 | if(GPSData.Position.Longitude < 0) u8_1 = '-'; |
345 | else u8_1 = '+'; |
345 | else u8_1 = '+'; |
346 | i16_1 = abs((int16_t)(GPSData.Position.Longitude/10000000L)); |
346 | i16_1 = abs((int16_t)(GPSData.Position.Longitude/10000000L)); |
347 | i16_2 = abs((int16_t)((GPSData.Position.Longitude%10000000L)/10000L)); |
347 | i16_2 = abs((int16_t)((GPSData.Position.Longitude%10000000L)/10000L)); |
348 | i16_3 = abs((int16_t)(((GPSData.Position.Longitude%10000000L)%10000L)/10L)); |
348 | i16_3 = abs((int16_t)(((GPSData.Position.Longitude%10000000L)%10000L)/10L)); |
349 | sprintf(string, "<lon=\"%c%d.%.3d%.3d\" ",u8_1, i16_1, i16_2, i16_3); |
349 | sprintf(string, "lon=\"%c%d.%.3d%.3d\" >\r\n",u8_1, i16_1, i16_2, i16_3); |
350 | fputs_(string, doc->file); |
350 | fputs_(string, doc->file); |
Line 351... | Line 351... | ||
351 | 351 | ||
352 | // write <time> tag only at a resolution of one second |
352 | // write <time> tag only at a resolution of one second |
353 | sprintf(string, "<time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\r\n",SystemTime.Year, SystemTime.Month, SystemTime.Day, SystemTime.Hour, SystemTime.Min, SystemTime.Sec); |
353 | sprintf(string, "<time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\r\n",SystemTime.Year, SystemTime.Month, SystemTime.Day, SystemTime.Hour, SystemTime.Min, SystemTime.Sec); |