Rev 360 | Rev 378 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 360 | Rev 362 | ||
---|---|---|---|
1 | /*#######################################################################################*/ |
1 | /*#######################################################################################*/ |
2 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
2 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
3 | /*#######################################################################################*/ |
3 | /*#######################################################################################*/ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 | // + www.MikroKopter.com |
5 | // + www.MikroKopter.com |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // + Software Nutzungsbedingungen (english version: see below) |
7 | // + Software Nutzungsbedingungen (english version: see below) |
8 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
8 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
9 | // + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
9 | // + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
10 | // + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
10 | // + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
11 | // + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
11 | // + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
12 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
12 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
14 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
15 | // + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
15 | // + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
16 | // + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
16 | // + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
17 | // + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
17 | // + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
18 | // + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
18 | // + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
19 | // + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
19 | // + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
20 | // + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
20 | // + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
21 | // + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
21 | // + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
22 | // + des Mitverschuldens offen. |
22 | // + des Mitverschuldens offen. |
23 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
23 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
24 | // + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
24 | // + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
25 | // + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
25 | // + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
26 | // + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
26 | // + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
27 | // + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
27 | // + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
28 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
28 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
29 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
29 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
30 | // + Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar. |
30 | // + Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar. |
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
32 | // + Software LICENSING TERMS |
32 | // + Software LICENSING TERMS |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
34 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
34 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
35 | // + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware |
35 | // + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware |
36 | // + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
36 | // + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
37 | // + The Software may only be used with the Licensor's products. |
37 | // + The Software may only be used with the Licensor's products. |
38 | // + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
38 | // + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
39 | // + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
39 | // + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
40 | // + agreement shall be the property of the Licensor. |
40 | // + agreement shall be the property of the Licensor. |
41 | // + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
41 | // + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
42 | // + features that can be used to identify the program may not be altered or defaced by the customer. |
42 | // + features that can be used to identify the program may not be altered or defaced by the customer. |
43 | // + The customer shall be responsible for taking reasonable precautions |
43 | // + The customer shall be responsible for taking reasonable precautions |
44 | // + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
44 | // + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
45 | // + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
45 | // + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
46 | // + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
46 | // + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
47 | // + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
47 | // + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
48 | // + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
48 | // + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
49 | // + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
49 | // + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
50 | // + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
50 | // + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
51 | // + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
51 | // + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
52 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
52 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
53 | // + #### END OF LICENSING TERMS #### |
53 | // + #### END OF LICENSING TERMS #### |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | #include <stdlib.h> |
56 | #include <stdlib.h> |
57 | #include <stdio.h> |
57 | #include <stdio.h> |
58 | #include "91x_lib.h" |
58 | #include "91x_lib.h" |
59 | #include "gpx.h" |
59 | #include "gpx.h" |
60 | #include "gpx_header.h" |
60 | #include "gpx_header.h" |
61 | #include "timer1.h" |
61 | #include "timer1.h" |
62 | #include "spi_slave.h" |
62 | #include "spi_slave.h" |
63 | #include "main.h" |
63 | #include "main.h" |
64 | #include "uart1.h" |
64 | #include "uart1.h" |
65 | #include "compass.h" |
65 | #include "compass.h" |
66 | #include "analog.h" |
66 | #include "analog.h" |
67 | #include "main.h" |
67 | #include "main.h" |
68 | #include "led.h" |
68 | #include "led.h" |
69 | #include "timer2.h" |
69 | #include "timer2.h" |
70 | 70 | ||
71 | //________________________________________________________________________________________________________________________________________ |
71 | //________________________________________________________________________________________________________________________________________ |
72 | // Function: GPX_DocumentInit(GPX_Document_t *) |
72 | // Function: GPX_DocumentInit(GPX_Document_t *) |
73 | // |
73 | // |
74 | // Description: This function initializes the gpx-document for further use. |
74 | // Description: This function initializes the gpx-document for further use. |
75 | // |
75 | // |
76 | // |
76 | // |
77 | // Returnvalue: '1' if document was initialized |
77 | // Returnvalue: '1' if document was initialized |
78 | //________________________________________________________________________________________________________________________________________ |
78 | //________________________________________________________________________________________________________________________________________ |
79 | 79 | ||
80 | u8 GPX_DocumentInit(GPX_Document_t *doc) |
80 | u8 GPX_DocumentInit(GPX_Document_t *doc) |
81 | { |
81 | { |
82 | if(doc->state != GPX_DOC_CLOSED) GPX_DocumentClose(doc); // close file if it was opened before |
82 | if(doc->state != GPX_DOC_CLOSED) GPX_DocumentClose(doc); // close file if it was opened before |
83 | doc->state = GPX_DOC_CLOSED; // init state of the gpx-document |
83 | doc->state = GPX_DOC_CLOSED; // init state of the gpx-document |
84 | doc->file = NULL; |
84 | doc->file = NULL; |
85 | return(1); |
85 | return(1); |
86 | } |
86 | } |
87 | 87 | ||
88 | //________________________________________________________________________________________________________________________________________ |
88 | //________________________________________________________________________________________________________________________________________ |
89 | // Function: GPX_Document_Open(s8 *name, GPX_Document_t *doc); |
89 | // Function: GPX_Document_Open(s8 *name, GPX_Document_t *doc); |
90 | // |
90 | // |
91 | // Description: This function opens a new gpx-document with the specified name and creates the document header within the file. |
91 | // Description: This function opens a new gpx-document with the specified name and creates the document header within the file. |
92 | // |
92 | // |
93 | // |
93 | // |
94 | // Returnvalue: '1' if the gpx-file could be created. |
94 | // Returnvalue: '1' if the gpx-file could be created. |
95 | //________________________________________________________________________________________________________________________________________ |
95 | //________________________________________________________________________________________________________________________________________ |
96 | 96 | ||
97 | 97 | ||
98 | u8 GPX_DocumentOpen(s8 *name, GPX_Document_t *doc) |
98 | u8 GPX_DocumentOpen(s8 *name, GPX_Document_t *doc) |
99 | { |
99 | { |
100 | s8 string[60]; |
100 | s8 string[60]; |
101 | u8 retvalue = 0; |
101 | u8 retvalue = 0; |
102 | 102 | ||
103 | if(doc == NULL) return(0); |
103 | if(doc == NULL) return(0); |
104 | GPX_DocumentInit(doc); // intialize the document with resetvalues |
104 | GPX_DocumentInit(doc); // intialize the document with resetvalues |
105 | doc->file = fopen_(name,'a'); // open a new file with the specified filename on the memorycard. |
105 | doc->file = fopen_(name,'a'); // open a new file with the specified filename on the memorycard. |
106 | 106 | ||
107 | if(doc->file != NULL) // could the file be opened? |
107 | if(doc->file != NULL) // could the file be opened? |
108 | { |
108 | { |
109 | retvalue = 1; // the document could be created on the drive. |
109 | retvalue = 1; // the document could be created on the drive. |
110 | doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
110 | doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
111 | fwrite_((void*)GPX_DOCUMENT_HEADER1, sizeof(GPX_DOCUMENT_HEADER1)-1,1,doc->file);// write the gpx-header to the document. |
111 | fwrite_((void*)GPX_DOCUMENT_HEADER1, sizeof(GPX_DOCUMENT_HEADER1)-1,1,doc->file);// write the gpx-header to the document. |
112 | sprintf(string, "<desc>FC HW:%d.%d SW:%d.%d%c + NC HW:%d.%d SW:%d.%d%c</desc>\r\n", FC_Version.Hardware/10,FC_Version.Hardware%10, FC_Version.Major, FC_Version.Minor, 'a'+FC_Version.Patch, Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
112 | sprintf(string, "<desc>FC HW:%d.%d SW:%d.%d%c + NC HW:%d.%d SW:%d.%d%c</desc>\r\n", FC_Version.Hardware/10,FC_Version.Hardware%10, FC_Version.Major, FC_Version.Minor, 'a'+FC_Version.Patch, Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
113 | fputs_(string, doc->file); |
113 | fputs_(string, doc->file); |
114 | fwrite_((void*)GPX_DOCUMENT_HEADER2, sizeof(GPX_DOCUMENT_HEADER2)-1,1,doc->file);// write the gpx-header to the document. |
114 | fwrite_((void*)GPX_DOCUMENT_HEADER2, sizeof(GPX_DOCUMENT_HEADER2)-1,1,doc->file);// write the gpx-header to the document. |
115 | } |
115 | } |
116 | Logging_FCStatusFlags1 = 0; |
116 | Logging_FCStatusFlags1 = 0; |
117 | Logging_FCStatusFlags2 = 0; |
117 | Logging_FCStatusFlags2 = 0; |
118 | return(retvalue); |
118 | return(retvalue); |
119 | } |
119 | } |
120 | 120 | ||
121 | //________________________________________________________________________________________________________________________________________ |
121 | //________________________________________________________________________________________________________________________________________ |
122 | // Function: DocumentClose(GPX_Document_t *doc); |
122 | // Function: DocumentClose(GPX_Document_t *doc); |
123 | // |
123 | // |
124 | // Description: This function closes the document specified by doc. |
124 | // Description: This function closes the document specified by doc. |
125 | // |
125 | // |
126 | // |
126 | // |
127 | // Returnvalue: '1' if the gpx-file could be closed. |
127 | // Returnvalue: '1' if the gpx-file could be closed. |
128 | //________________________________________________________________________________________________________________________________________ |
128 | //________________________________________________________________________________________________________________________________________ |
129 | 129 | ||
130 | u8 GPX_DocumentClose(GPX_Document_t *doc) |
130 | u8 GPX_DocumentClose(GPX_Document_t *doc) |
131 | { |
131 | { |
132 | 132 | ||
133 | u8 retvalue = 1; |
133 | u8 retvalue = 1; |
134 | 134 | ||
135 | if(doc == NULL) return(0); |
135 | if(doc == NULL) return(0); |
136 | 136 | ||
137 | while(doc->state != GPX_DOC_CLOSED) // close linestring, placemark and document before closing the file on the memorycard |
137 | while(doc->state != GPX_DOC_CLOSED && (SD_WatchDog)) // close linestring, placemark and document before closing the file on the memorycard |
138 | { |
138 | { |
139 | switch(doc->state) |
139 | switch(doc->state) |
140 | { |
140 | { |
141 | case GPX_DOC_TRACKSEGMENT_OPENED: |
141 | case GPX_DOC_TRACKSEGMENT_OPENED: |
142 | GPX_TrackSegmentEnd(doc); // write terminating tag to end tracksegment. |
142 | GPX_TrackSegmentEnd(doc); // write terminating tag to end tracksegment. |
143 | break; |
143 | break; |
144 | 144 | ||
145 | case GPX_DOC_TRACK_OPENED: // write terminating tag to close track. |
145 | case GPX_DOC_TRACK_OPENED: // write terminating tag to close track. |
146 | GPX_TrackEnd(doc); |
146 | GPX_TrackEnd(doc); |
147 | break; |
147 | break; |
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 | fwrite_((void*)GPX_DOCUMENT_FOOTER, sizeof(GPX_DOCUMENT_FOOTER)-1,1,doc->file); // write the gpx-footer to the document. |
152 | fwrite_((void*)GPX_DOCUMENT_FOOTER, sizeof(GPX_DOCUMENT_FOOTER)-1,1,doc->file); // write the gpx-footer to the document. |
153 | fclose_(doc->file); |
153 | fclose_(doc->file); |
154 | retvalue = 1; |
154 | retvalue = 1; |
155 | } |
155 | } |
156 | doc->state = GPX_DOC_CLOSED; |
156 | doc->state = GPX_DOC_CLOSED; |
157 | break; |
157 | break; |
158 | 158 | ||
159 | default: |
159 | default: |
160 | doc->state = GPX_DOC_CLOSED; |
160 | doc->state = GPX_DOC_CLOSED; |
161 | break; |
161 | break; |
162 | } |
162 | } |
163 | } |
163 | } |
164 | return(retvalue); |
164 | return(retvalue); |
165 | } |
165 | } |
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | //________________________________________________________________________________________________________________________________________ |
169 | //________________________________________________________________________________________________________________________________________ |
170 | // Function: u8 GPX_TrackBegin(GPX_Document_t); |
170 | // Function: u8 GPX_TrackBegin(GPX_Document_t); |
171 | // |
171 | // |
172 | // Description: This function adds a track to the document. |
172 | // Description: This function adds a track to the document. |
173 | // |
173 | // |
174 | // |
174 | // |
175 | // Returnvalue: '1' if the track could be opened |
175 | // Returnvalue: '1' if the track could be opened |
176 | //________________________________________________________________________________________________________________________________________ |
176 | //________________________________________________________________________________________________________________________________________ |
177 | 177 | ||
178 | u8 GPX_TrackBegin(GPX_Document_t *doc) |
178 | u8 GPX_TrackBegin(GPX_Document_t *doc) |
179 | { |
179 | { |
180 | 180 | ||
181 | u8 retvalue = 0; |
181 | u8 retvalue = 0; |
182 | if(doc->state == GPX_DOC_OPENED) |
182 | if(doc->state == GPX_DOC_OPENED) |
183 | { |
183 | { |
184 | if(doc->file != NULL) |
184 | if(doc->file != NULL) |
185 | { |
185 | { |
186 | doc->state = GPX_DOC_TRACK_OPENED; |
186 | doc->state = GPX_DOC_TRACK_OPENED; |
187 | retvalue = 1; |
187 | retvalue = 1; |
188 | fwrite_((void*)GPX_TRACK_HEADER, sizeof(GPX_TRACK_HEADER)-1,1,doc->file); |
188 | fwrite_((void*)GPX_TRACK_HEADER, sizeof(GPX_TRACK_HEADER)-1,1,doc->file); |
189 | } |
189 | } |
190 | } |
190 | } |
191 | return(retvalue); |
191 | return(retvalue); |
192 | } |
192 | } |
193 | 193 | ||
194 | 194 | ||
195 | //________________________________________________________________________________________________________________________________________ |
195 | //________________________________________________________________________________________________________________________________________ |
196 | // Function: u8 GPX_TrackEnd(KML_Document_t *doc) |
196 | // Function: u8 GPX_TrackEnd(KML_Document_t *doc) |
197 | // |
197 | // |
198 | // Description: This function ends the track opened before. |
198 | // Description: This function ends the track opened before. |
199 | // |
199 | // |
200 | // |
200 | // |
201 | // Returnvalue: 1' if the track could be closed |
201 | // Returnvalue: 1' if the track could be closed |
202 | //________________________________________________________________________________________________________________________________________ |
202 | //________________________________________________________________________________________________________________________________________ |
203 | 203 | ||
204 | u8 GPX_TrackEnd(GPX_Document_t *doc) |
204 | u8 GPX_TrackEnd(GPX_Document_t *doc) |
205 | { |
205 | { |
206 | 206 | ||
207 | u8 retvalue = 0; |
207 | u8 retvalue = 0; |
208 | 208 | ||
209 | if(doc->state == GPX_DOC_TRACK_OPENED) |
209 | if(doc->state == GPX_DOC_TRACK_OPENED) |
210 | { |
210 | { |
211 | if(doc->file != NULL) |
211 | if(doc->file != NULL) |
212 | { |
212 | { |
213 | doc->state = GPX_DOC_OPENED; |
213 | doc->state = GPX_DOC_OPENED; |
214 | fwrite_((void*)GPX_TRACK_FOOTER, sizeof(GPX_TRACK_FOOTER)-1,1,doc->file); |
214 | fwrite_((void*)GPX_TRACK_FOOTER, sizeof(GPX_TRACK_FOOTER)-1,1,doc->file); |
215 | retvalue = 1; |
215 | retvalue = 1; |
216 | } |
216 | } |
217 | } |
217 | } |
218 | 218 | ||
219 | return(retvalue); |
219 | return(retvalue); |
220 | } |
220 | } |
221 | 221 | ||
222 | //________________________________________________________________________________________________________________________________________ |
222 | //________________________________________________________________________________________________________________________________________ |
223 | // Function: u8 GPX_TrackSegmentBegin(GPX_Document_t *doc); |
223 | // Function: u8 GPX_TrackSegmentBegin(GPX_Document_t *doc); |
224 | // |
224 | // |
225 | // Description: This function starts a track segment. |
225 | // Description: This function starts a track segment. |
226 | // |
226 | // |
227 | // |
227 | // |
228 | // Returnvalue: '1' if the track segement could be started |
228 | // Returnvalue: '1' if the track segement could be started |
229 | //________________________________________________________________________________________________________________________________________ |
229 | //________________________________________________________________________________________________________________________________________ |
230 | 230 | ||
231 | u8 GPX_TrackSegmentBegin(GPX_Document_t *doc) |
231 | u8 GPX_TrackSegmentBegin(GPX_Document_t *doc) |
232 | { |
232 | { |
233 | 233 | ||
234 | u8 retvalue = 0; |
234 | u8 retvalue = 0; |
235 | 235 | ||
236 | if(doc->state == GPX_DOC_TRACK_OPENED) |
236 | if(doc->state == GPX_DOC_TRACK_OPENED) |
237 | { |
237 | { |
238 | if(doc->file != NULL) |
238 | if(doc->file != NULL) |
239 | { |
239 | { |
240 | doc->state = GPX_DOC_TRACKSEGMENT_OPENED; |
240 | doc->state = GPX_DOC_TRACKSEGMENT_OPENED; |
241 | fwrite_((void*)GPX_TRACKSEGMENT_HEADER, sizeof(GPX_TRACKSEGMENT_HEADER)-1,1,doc->file); |
241 | fwrite_((void*)GPX_TRACKSEGMENT_HEADER, sizeof(GPX_TRACKSEGMENT_HEADER)-1,1,doc->file); |
242 | retvalue = 1; |
242 | retvalue = 1; |
243 | } |
243 | } |
244 | } |
244 | } |
245 | return(retvalue); |
245 | return(retvalue); |
246 | } |
246 | } |
247 | 247 | ||
248 | //________________________________________________________________________________________________________________________________________ |
248 | //________________________________________________________________________________________________________________________________________ |
249 | // Function: u8 GPX_TrackSegmentEnd(GPX_Document_t *doc); |
249 | // Function: u8 GPX_TrackSegmentEnd(GPX_Document_t *doc); |
250 | // |
250 | // |
251 | // Description: This function ends the tracksegment opened before. |
251 | // Description: This function ends the tracksegment opened before. |
252 | // |
252 | // |
253 | // |
253 | // |
254 | // Returnvalue: '1' if the track segment could be terminated |
254 | // Returnvalue: '1' if the track segment could be terminated |
255 | //________________________________________________________________________________________________________________________________________ |
255 | //________________________________________________________________________________________________________________________________________ |
256 | 256 | ||
257 | u8 GPX_TrackSegmentEnd(GPX_Document_t *doc) |
257 | u8 GPX_TrackSegmentEnd(GPX_Document_t *doc) |
258 | { |
258 | { |
259 | 259 | ||
260 | u8 retvalue = 0; |
260 | u8 retvalue = 0; |
261 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) |
261 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) |
262 | { |
262 | { |
263 | if(doc->file != NULL) |
263 | if(doc->file != NULL) |
264 | { |
264 | { |
265 | doc->state = GPX_DOC_TRACK_OPENED; |
265 | doc->state = GPX_DOC_TRACK_OPENED; |
266 | fwrite_((void*)GPX_TRACKSEGMENT_FOOTER, sizeof(GPX_TRACKSEGMENT_FOOTER)-1,1,doc->file); |
266 | fwrite_((void*)GPX_TRACKSEGMENT_FOOTER, sizeof(GPX_TRACKSEGMENT_FOOTER)-1,1,doc->file); |
267 | retvalue = 1; |
267 | retvalue = 1; |
268 | } |
268 | } |
269 | } |
269 | } |
270 | return(retvalue); |
270 | return(retvalue); |
271 | } |
271 | } |
272 | 272 | ||
273 | //________________________________________________________________________________________________________________________________________ |
273 | //________________________________________________________________________________________________________________________________________ |
274 | // Function: u8 GPX_TrackSegementAddPoint(GPS_Pos_t * pGPS_Position ,GPX_Document_t *doc); |
274 | // Function: u8 GPX_TrackSegementAddPoint(GPS_Pos_t * pGPS_Position ,GPX_Document_t *doc); |
275 | // |
275 | // |
276 | // Description: This function adds a pointof a track segement to the specified document. |
276 | // Description: This function adds a pointof a track segement to the specified document. |
277 | // |
277 | // |
278 | // |
278 | // |
279 | // Returnvalue: '1' if a point was added |
279 | // Returnvalue: '1' if a point was added |
280 | //________________________________________________________________________________________________________________________________________ |
280 | //________________________________________________________________________________________________________________________________________ |
281 | 281 | ||
282 | u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc,unsigned char part) |
282 | u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc,unsigned char part) |
283 | { |
283 | { |
284 | 284 | ||
285 | u8 retvalue = 0; |
285 | u8 retvalue = 0; |
286 | s8 string[100]; |
286 | s8 string[100]; |
287 | 287 | ||
288 | if(doc == NULL) return(0); |
288 | if(doc == NULL) return(0); |
289 | 289 | ||
290 | if((GPSData.Position.Status != INVALID) && (NaviData.HomePosition.Status != INVALID)) |
290 | if((GPSData.Position.Status != INVALID) && (NaviData.HomePosition.Status != INVALID)) |
291 | { |
291 | { |
292 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) |
292 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) |
293 | { |
293 | { |
294 | if(doc->file != NULL) |
294 | if(doc->file != NULL) |
295 | { |
295 | { |
296 | s32 i32_1, i32_2; |
296 | s32 i32_1, i32_2; |
297 | s16 i16_1; |
297 | s16 i16_1; |
298 | u8 u8_1, u8_2; |
298 | u8 u8_1, u8_2; |
299 | // write <trkpt> tag |
299 | // write <trkpt> tag |
300 | switch(part) |
300 | switch(part) |
301 | { |
301 | { |
302 | case 0: |
302 | case 0: |
303 | if(GPSData.Position.Latitude < 0) u8_1 = '-'; |
303 | if(GPSData.Position.Latitude < 0) u8_1 = '-'; |
304 | else u8_1 = '+'; |
304 | else u8_1 = '+'; |
305 | i32_1 = abs(GPSData.Position.Latitude)/10000000L; |
305 | i32_1 = abs(GPSData.Position.Latitude)/10000000L; |
306 | i32_2 = abs(GPSData.Position.Latitude)%10000000L; |
306 | i32_2 = abs(GPSData.Position.Latitude)%10000000L; |
307 | sprintf(string, "<trkpt lat=\"%c%ld.%07ld\" ",u8_1, i32_1, i32_2); |
307 | sprintf(string, "<trkpt lat=\"%c%ld.%07ld\" ",u8_1, i32_1, i32_2); |
308 | fputs_(string, doc->file); |
308 | fputs_(string, doc->file); |
309 | if(GPSData.Position.Longitude < 0) u8_1 = '-'; |
309 | if(GPSData.Position.Longitude < 0) u8_1 = '-'; |
310 | else u8_1 = '+'; |
310 | else u8_1 = '+'; |
311 | i32_1 = abs(GPSData.Position.Longitude)/10000000L; |
311 | i32_1 = abs(GPSData.Position.Longitude)/10000000L; |
312 | i32_2 = abs(GPSData.Position.Longitude)%10000000L; |
312 | i32_2 = abs(GPSData.Position.Longitude)%10000000L; |
313 | sprintf(string, "lon=\"%c%ld.%07ld\">\r\n",u8_1, i32_1, i32_2); |
313 | sprintf(string, "lon=\"%c%ld.%07ld\">\r\n",u8_1, i32_1, i32_2); |
314 | fputs_(string, doc->file); |
314 | fputs_(string, doc->file); |
315 | break; |
315 | break; |
316 | case 1: |
316 | case 1: |
317 | // write <ele> taga |
317 | // write <ele> taga |
318 | i32_2 = GPSData.Position.Altitude - NaviData.HomePosition.Altitude; |
318 | i32_2 = GPSData.Position.Altitude - NaviData.HomePosition.Altitude; |
319 | if(i32_2 < 0) i32_2 = 0; // avoid negative altitudes in log |
319 | if(i32_2 < 0) i32_2 = 0; // avoid negative altitudes in log |
320 | i32_1 = i32_2/1000L; |
320 | i32_1 = i32_2/1000L; |
321 | i32_2 = i32_2%1000L; |
321 | i32_2 = i32_2%1000L; |
322 | sprintf(string,"<ele>%ld.%03ld</ele>\r\n",i32_1, i32_2); |
322 | sprintf(string,"<ele>%ld.%03ld</ele>\r\n",i32_1, i32_2); |
323 | fputs_(string, doc->file); |
323 | fputs_(string, doc->file); |
324 | // write <time> tag only at a resolution of one second |
324 | // write <time> tag only at a resolution of one second |
325 | sprintf(string, "<time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\r\n",SystemTime.Year, SystemTime.Month, SystemTime.Day, SystemTime.Hour, SystemTime.Min, SystemTime.Sec); |
325 | sprintf(string, "<time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\r\n",SystemTime.Year, SystemTime.Month, SystemTime.Day, SystemTime.Hour, SystemTime.Min, SystemTime.Sec); |
326 | fputs_(string, doc->file); |
326 | fputs_(string, doc->file); |
327 | // write <sat> tag |
327 | // write <sat> tag |
328 | sprintf(string, "<sat>%d</sat>\r\n", NaviData.SatsInUse); |
328 | sprintf(string, "<sat>%d</sat>\r\n", NaviData.SatsInUse); |
329 | fputs_(string, doc->file); |
329 | fputs_(string, doc->file); |
330 | // todo: add <extensions> tag with additional data to be logged |
330 | // todo: add <extensions> tag with additional data to be logged |
331 | sprintf(string, "<extensions>\r\n"); |
331 | sprintf(string, "<extensions>\r\n"); |
332 | fputs_(string, doc->file); |
332 | fputs_(string, doc->file); |
333 | break; |
333 | break; |
334 | case 2: |
334 | case 2: |
335 | // Altimeter according to air pressure |
335 | // Altimeter according to air pressure |
336 | sprintf(string, "<Altimeter>%d,'%c'</Altimeter>\r\n", NaviData.Altimeter,FromFC_VarioCharacter); |
336 | sprintf(string, "<Altimeter>%d,'%c'</Altimeter>\r\n", NaviData.Altimeter,FromFC_VarioCharacter); |
337 | fputs_(string, doc->file); |
337 | fputs_(string, doc->file); |
338 | // Variometer according to air pressure |
338 | // Variometer according to air pressure |
339 | sprintf(string, "<Variometer>%d</Variometer>\r\n", NaviData.Variometer); |
339 | sprintf(string, "<Variometer>%d</Variometer>\r\n", NaviData.Variometer); |
340 | fputs_(string, doc->file); |
340 | fputs_(string, doc->file); |
341 | // Course in deg |
341 | // Course in deg |
342 | i16_1 = GPSData.Heading/100000L; |
342 | i16_1 = GPSData.Heading/100000L; |
343 | sprintf(string, "<Course>%03d</Course>\r\n", i16_1); |
343 | sprintf(string, "<Course>%03d</Course>\r\n", i16_1); |
344 | fputs_(string, doc->file); |
344 | fputs_(string, doc->file); |
345 | // Ground Speed in cm/s |
345 | // Ground Speed in cm/s |
346 | sprintf(string, "<GroundSpeed>%d</GroundSpeed>\r\n", NaviData.GroundSpeed); |
346 | sprintf(string, "<GroundSpeed>%d</GroundSpeed>\r\n", NaviData.GroundSpeed); |
347 | fputs_(string, doc->file); |
347 | fputs_(string, doc->file); |
348 | // Vertical Speed in cm/s |
348 | // Vertical Speed in cm/s |
349 | sprintf(string, "<VerticalSpeed>%d</VerticalSpeed>\r\n", NaviData.TopSpeed); |
349 | sprintf(string, "<VerticalSpeed>%d</VerticalSpeed>\r\n", NaviData.TopSpeed); |
350 | fputs_(string, doc->file); |
350 | fputs_(string, doc->file); |
351 | // Flight duration |
351 | // Flight duration |
352 | sprintf(string, "<FlightTime>%d</FlightTime>\r\n", NaviData.FlyingTime); |
352 | sprintf(string, "<FlightTime>%d</FlightTime>\r\n", NaviData.FlyingTime); |
353 | fputs_(string, doc->file); |
353 | fputs_(string, doc->file); |
354 | break; |
354 | break; |
355 | case 3: |
355 | case 3: |
356 | // Ubat |
356 | // Ubat |
357 | u8_1 = NaviData.UBat / 10; |
357 | u8_1 = NaviData.UBat / 10; |
358 | u8_2 = NaviData.UBat % 10; |
358 | u8_2 = NaviData.UBat % 10; |
359 | sprintf(string, "<Voltage>%d.%01d</Voltage>\r\n", u8_1, u8_2); |
359 | sprintf(string, "<Voltage>%d.%01d</Voltage>\r\n", u8_1, u8_2); |
360 | fputs_(string, doc->file); |
360 | fputs_(string, doc->file); |
361 | // Current |
361 | // Current |
362 | u8_1 = NaviData.Current / 10; |
362 | u8_1 = NaviData.Current / 10; |
363 | u8_2 = NaviData.Current % 10; |
363 | u8_2 = NaviData.Current % 10; |
364 | sprintf(string, "<Current>%d.%01d</Current>\r\n", u8_1, u8_2); |
364 | sprintf(string, "<Current>%d.%01d</Current>\r\n", u8_1, u8_2); |
365 | fputs_(string, doc->file); |
365 | fputs_(string, doc->file); |
366 | // Capacity |
366 | // Capacity |
367 | sprintf(string, "<Capacity>%d</Capacity>\r\n", NaviData.UsedCapacity); |
367 | sprintf(string, "<Capacity>%d</Capacity>\r\n", NaviData.UsedCapacity); |
368 | fputs_(string, doc->file); |
368 | fputs_(string, doc->file); |
369 | // RC Quality |
369 | // RC Quality |
370 | sprintf(string, "<RCQuality>%d</RCQuality>\r\n", FC.RC_Quality); |
370 | sprintf(string, "<RCQuality>%d</RCQuality>\r\n", FC.RC_Quality); |
371 | fputs_(string, doc->file); |
371 | fputs_(string, doc->file); |
372 | // RC Received Signal Strength Indication |
372 | // RC Received Signal Strength Indication |
373 | break; |
373 | break; |
374 | case 4: |
374 | case 4: |
375 | sprintf(string, "<RCRSSI>%d</RCRSSI>\r\n", FC.RC_RSSI); |
375 | sprintf(string, "<RCRSSI>%d</RCRSSI>\r\n", FC.RC_RSSI); |
376 | fputs_(string, doc->file); |
376 | fputs_(string, doc->file); |
377 | // Compassind deg |
377 | // Compassind deg |
378 | i16_1 = FromFlightCtrl.GyroHeading / 10; |
378 | i16_1 = FromFlightCtrl.GyroHeading / 10; |
379 | sprintf(string, "<Compass>%03d,%03d</Compass>\r\n", i16_1,ToFlightCtrl.CompassHeading); |
379 | sprintf(string, "<Compass>%03d,%03d</Compass>\r\n", i16_1,ToFlightCtrl.CompassHeading); |
380 | fputs_(string, doc->file); |
380 | fputs_(string, doc->file); |
381 | // Nick Angle ind deg |
381 | // Nick Angle ind deg |
382 | sprintf(string, "<NickAngle>%03d</NickAngle>\r\n", NaviData.AngleNick); |
382 | sprintf(string, "<NickAngle>%03d</NickAngle>\r\n", NaviData.AngleNick); |
383 | fputs_(string, doc->file); |
383 | fputs_(string, doc->file); |
384 | // Roll Angle in deg |
384 | // Roll Angle in deg |
385 | sprintf(string, "<RollAngle>%03d</RollAngle>\r\n", NaviData.AngleRoll); |
385 | sprintf(string, "<RollAngle>%03d</RollAngle>\r\n", NaviData.AngleRoll); |
386 | fputs_(string, doc->file); |
386 | fputs_(string, doc->file); |
387 | break; |
387 | break; |
388 | case 5: |
388 | case 5: |
389 | // magnetic field |
389 | // magnetic field |
390 | sprintf(string, "<MagnetField>%03d</MagnetField>\r\n",(u16) (EarthMagneticFieldFiltered/5)); |
390 | sprintf(string, "<MagnetField>%03d</MagnetField>\r\n",(u16) (EarthMagneticFieldFiltered/5)); |
391 | fputs_(string, doc->file); |
391 | fputs_(string, doc->file); |
392 | // magnetic inclination & error |
392 | // magnetic inclination & error |
393 | sprintf(string, "<MagnetInclination>%02d,%02d</MagnetInclination>\r\n",(s16)EarthMagneticInclinationFiltered/10,(s16)(EarthMagneticInclinationFiltered/10 - EarthMagneticInclinationTheoretic)); |
393 | sprintf(string, "<MagnetInclination>%02d,%02d</MagnetInclination>\r\n",(s16)EarthMagneticInclinationFiltered/10,(s16)(EarthMagneticInclinationFiltered/10 - EarthMagneticInclinationTheoretic)); |
394 | fputs_(string, doc->file); |
394 | fputs_(string, doc->file); |
395 | // BL Information |
395 | // BL Information |
396 | sprintf(string, "<MotorCurrent>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</MotorCurrent>\r\n",Motor[0].Current,Motor[1].Current,Motor[2].Current,Motor[3].Current,Motor[4].Current,Motor[5].Current,Motor[6].Current,Motor[7].Current,Motor[8].Current,Motor[9].Current,Motor[10].Current,Motor[11].Current); |
396 | sprintf(string, "<MotorCurrent>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</MotorCurrent>\r\n",Motor[0].Current,Motor[1].Current,Motor[2].Current,Motor[3].Current,Motor[4].Current,Motor[5].Current,Motor[6].Current,Motor[7].Current,Motor[8].Current,Motor[9].Current,Motor[10].Current,Motor[11].Current); |
397 | fputs_(string, doc->file); |
397 | fputs_(string, doc->file); |
398 | sprintf(string, "<BL_Temperature>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_Temperature>\r\n",Motor[0].Temperature,Motor[1].Temperature,Motor[2].Temperature,Motor[3].Temperature,Motor[4].Temperature,Motor[5].Temperature,Motor[6].Temperature,Motor[7].Temperature,Motor[8].Temperature,Motor[9].Temperature,Motor[10].Temperature,Motor[11].Temperature); |
398 | sprintf(string, "<BL_Temperature>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_Temperature>\r\n",Motor[0].Temperature,Motor[1].Temperature,Motor[2].Temperature,Motor[3].Temperature,Motor[4].Temperature,Motor[5].Temperature,Motor[6].Temperature,Motor[7].Temperature,Motor[8].Temperature,Motor[9].Temperature,Motor[10].Temperature,Motor[11].Temperature); |
399 | fputs_(string, doc->file); |
399 | fputs_(string, doc->file); |
400 | break; |
400 | break; |
401 | case 6: |
401 | case 6: |
402 | /* sprintf(string, "<BL_State>0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x</BL_State>\r\n",Motor.State[0],Motor.State[1],Motor.State[2],Motor.State[3],Motor.State[4],Motor.State[5],Motor.State[6],Motor.State[7],Motor.State[8],Motor.State[9],Motor.State[10],Motor.State[11]); |
402 | /* sprintf(string, "<BL_State>0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x</BL_State>\r\n",Motor.State[0],Motor.State[1],Motor.State[2],Motor.State[3],Motor.State[4],Motor.State[5],Motor.State[6],Motor.State[7],Motor.State[8],Motor.State[9],Motor.State[10],Motor.State[11]); |
403 | fputs_(string, doc->file); |
403 | fputs_(string, doc->file); |
404 | sprintf(string, "<BL_MaxPWM>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_MaxPWM>\r\n",Motor.MaxPWM[0],Motor.MaxPWM[1],Motor.MaxPWM[2],Motor.MaxPWM[3],Motor.MaxPWM[4],Motor.MaxPWM[5],Motor.MaxPWM[6],Motor.MaxPWM[7],Motor.MaxPWM[8],Motor.MaxPWM[9],Motor.MaxPWM[10],Motor.MaxPWM[11]); |
404 | sprintf(string, "<BL_MaxPWM>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_MaxPWM>\r\n",Motor.MaxPWM[0],Motor.MaxPWM[1],Motor.MaxPWM[2],Motor.MaxPWM[3],Motor.MaxPWM[4],Motor.MaxPWM[5],Motor.MaxPWM[6],Motor.MaxPWM[7],Motor.MaxPWM[8],Motor.MaxPWM[9],Motor.MaxPWM[10],Motor.MaxPWM[11]); |
405 | fputs_(string, doc->file); |
405 | fputs_(string, doc->file); |
406 | */ sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM); |
406 | */ sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM); |
407 | fputs_(string, doc->file); |
407 | fputs_(string, doc->file); |
408 | sprintf(string, "<FC_I2C_ErrorCounter>%03d</FC_I2C_ErrorCounter>\r\n",(s16)FC_I2C_ErrorConter); |
408 | sprintf(string, "<FC_I2C_ErrorCounter>%03d</FC_I2C_ErrorCounter>\r\n",(s16)FC_I2C_ErrorConter); |
409 | fputs_(string, doc->file); |
409 | fputs_(string, doc->file); |
410 | // Analog inputs of the NC |
410 | // Analog inputs of the NC |
411 | sprintf(string, "<AnalogInputs>%d,%d,%d,%d</AnalogInputs>\r\n",AnalogData.Ch4,AnalogData.Ch5,AnalogData.Ch6,AnalogData.Ch7); |
411 | sprintf(string, "<AnalogInputs>%d,%d,%d,%d</AnalogInputs>\r\n",AnalogData.Ch4,AnalogData.Ch5,AnalogData.Ch6,AnalogData.Ch7); |
412 | fputs_(string, doc->file); |
412 | fputs_(string, doc->file); |
413 | // NC Mode (contains the status) |
413 | // NC Mode (contains the status) |
414 | sprintf(string, "<NCFlag>0x%02X</NCFlag>\r\n", NCFlags); |
414 | sprintf(string, "<NCFlag>0x%02X</NCFlag>\r\n", NCFlags); |
415 | fputs_(string, doc->file); |
415 | fputs_(string, doc->file); |
416 | sprintf(string, "<Servo>%d,%d,%d</Servo>\r\n", ServoParams.NickControl,ServoParams.RollControl,POI_KameraNick/10); // Raw Poti-Values of the Servo control and the POI_Nick in 1° |
416 | sprintf(string, "<Servo>%d,%d,%d</Servo>\r\n", ServoParams.NickControl,ServoParams.RollControl,POI_KameraNick/10); // Raw Poti-Values of the Servo control and the POI_Nick in 1° |
417 | fputs_(string, doc->file); |
417 | fputs_(string, doc->file); |
418 | sprintf(string, "<WP>%d,%d,%d</WP>\r\n",NaviData.WaypointIndex,NaviData.WaypointNumber,FC_WP_EventChannel); // x of y Waypoints and the actual value of the Event Channel |
418 | sprintf(string, "<WP>%d,%d,%d</WP>\r\n",NaviData.WaypointIndex,NaviData.WaypointNumber,FC_WP_EventChannel); // x of y Waypoints and the actual value of the Event Channel |
419 | fputs_(string, doc->file); |
419 | fputs_(string, doc->file); |
420 | break; |
420 | break; |
421 | case 7: |
421 | case 7: |
422 | // Flags |
422 | // Flags |
423 | sprintf(string, "<FCFlags2>0x%02x,0x%02x</FCFlags2>\r\n",Logging_FCStatusFlags1,Logging_FCStatusFlags2); |
423 | sprintf(string, "<FCFlags2>0x%02x,0x%02x</FCFlags2>\r\n",Logging_FCStatusFlags1,Logging_FCStatusFlags2); |
424 | fputs_(string, doc->file); |
424 | fputs_(string, doc->file); |
425 | Logging_FCStatusFlags1 = 0; |
425 | Logging_FCStatusFlags1 = 0; |
426 | Logging_FCStatusFlags2 = 0; |
426 | Logging_FCStatusFlags2 = 0; |
427 | // Status of the complete MikroKopter |
427 | // Status of the complete MikroKopter |
428 | sprintf(string, "<ErrorCode>%03d</ErrorCode>\r\n",ErrorCode); |
428 | sprintf(string, "<ErrorCode>%03d</ErrorCode>\r\n",ErrorCode); |
429 | fputs_(string, doc->file); |
429 | fputs_(string, doc->file); |
430 | // Target Bearing in deg |
430 | // Target Bearing in deg |
431 | sprintf(string, "<TargetBearing>%03d</TargetBearing>\r\n", NaviData.TargetPositionDeviation.Bearing); |
431 | sprintf(string, "<TargetBearing>%03d</TargetBearing>\r\n", NaviData.TargetPositionDeviation.Bearing); |
432 | fputs_(string, doc->file); |
432 | fputs_(string, doc->file); |
433 | // Target Distance in dm |
433 | // Target Distance in dm |
434 | sprintf(string, "<TargetDistance>%d</TargetDistance>\r\n", NaviData.TargetPositionDeviation.Distance); |
434 | sprintf(string, "<TargetDistance>%d</TargetDistance>\r\n", NaviData.TargetPositionDeviation.Distance); |
435 | fputs_(string, doc->file); |
435 | fputs_(string, doc->file); |
436 | break; |
436 | break; |
437 | case 8: |
437 | case 8: |
438 | // RC Sticks as Nick/Roll/Yaw |
438 | // RC Sticks as Nick/Roll/Yaw |
439 | sprintf(string, "<RCSticks>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</RCSticks>\r\n", FC.StickNick,FC.StickRoll, FC.StickYaw, FC.StickGas,FC.Poti[0],FC.Poti[1],FC.Poti[2],FC.Poti[3],FC.Poti[4],FC.Poti[5],FC.Poti[6],FC.Poti[7]); |
439 | sprintf(string, "<RCSticks>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</RCSticks>\r\n", FC.StickNick,FC.StickRoll, FC.StickYaw, FC.StickGas,FC.Poti[0],FC.Poti[1],FC.Poti[2],FC.Poti[3],FC.Poti[4],FC.Poti[5],FC.Poti[6],FC.Poti[7]); |
440 | fputs_(string, doc->file); |
440 | fputs_(string, doc->file); |
441 | // GPS Sticks as Nick/Roll/Yaw |
441 | // GPS Sticks as Nick/Roll/Yaw |
442 | sprintf(string, "<GPSSticks>%d,%d,%d,'%c'</GPSSticks>\r\n", ToFlightCtrl.GPSStick.Nick, ToFlightCtrl.GPSStick.Roll, ToFlightCtrl.GPSStick.Yaw,NC_GPS_ModeCharacter); |
442 | sprintf(string, "<GPSSticks>%d,%d,%d,'%c'</GPSSticks>\r\n", ToFlightCtrl.GPSStick.Nick, ToFlightCtrl.GPSStick.Roll, ToFlightCtrl.GPSStick.Yaw,NC_GPS_ModeCharacter); |
443 | fputs_(string, doc->file); |
443 | fputs_(string, doc->file); |
444 | // eof extensions |
444 | // eof extensions |
445 | sprintf(string, "</extensions>\r\n"); |
445 | sprintf(string, "</extensions>\r\n"); |
446 | fputs_(string, doc->file); |
446 | fputs_(string, doc->file); |
447 | sprintf(string, "</trkpt>\r\n"); |
447 | sprintf(string, "</trkpt>\r\n"); |
448 | fputs_(string, doc->file); |
448 | fputs_(string, doc->file); |
449 | break; |
449 | break; |
450 | } |
450 | } |
451 | retvalue = 1; |
451 | retvalue = 1; |
452 | } |
452 | } |
453 | } |
453 | } |
454 | } |
454 | } |
455 | return(retvalue); |
455 | return(retvalue); |
456 | } |
456 | } |
457 | 457 | ||
458 | //________________________________________________________________________________________________________________________________________ |
458 | //________________________________________________________________________________________________________________________________________ |
459 | // Function: u8 KML_LoggGPSCoordinates(gps_data_t *, KML_Document_t *) |
459 | // Function: u8 KML_LoggGPSCoordinates(gps_data_t *, KML_Document_t *) |
460 | // |
460 | // |
461 | // Description: This function opens and adds gpscoordinates to an GPX-Document. The document will be opened, if not already done |
461 | // Description: This function opens and adds gpscoordinates to an GPX-Document. The document will be opened, if not already done |
462 | // |
462 | // |
463 | // |
463 | // |
464 | // Returnvalue: '1' if an gps coordinate was logged |
464 | // Returnvalue: '1' if an gps coordinate was logged |
465 | //________________________________________________________________________________________________________________________________________ |
465 | //________________________________________________________________________________________________________________________________________ |
466 | 466 | ||
467 | u8 GPX_LoggGPSCoordinates(GPX_Document_t *doc,unsigned char part) |
467 | u8 GPX_LoggGPSCoordinates(GPX_Document_t *doc,unsigned char part) |
468 | { |
468 | { |
469 | u8 retval = 0; |
469 | u8 retval = 0; |
470 | while(doc->state != GPX_DOC_TRACKSEGMENT_OPENED) // automatic create document with default filename on the card. |
470 | while(doc->state != GPX_DOC_TRACKSEGMENT_OPENED && (SD_WatchDog)) // automatic create document with default filename on the card. |
471 | { |
471 | { |
472 | switch(doc->state) |
472 | switch(doc->state) |
473 | { |
473 | { |
474 | case GPX_DOC_CLOSED: // document hasn't been opened yet therefore it will be initialized automatically |
474 | case GPX_DOC_CLOSED: // document hasn't been opened yet therefore it will be initialized automatically |
475 | retval = GPX_DocumentOpen("default.gpx",doc); // open the gpx-document with a standardname. |
475 | retval = GPX_DocumentOpen("default.gpx",doc); // open the gpx-document with a standardname. |
476 | break; |
476 | break; |
477 | 477 | ||
478 | case GPX_DOC_OPENED: // if a document has been opened before but no track exists: |
478 | case GPX_DOC_OPENED: // if a document has been opened before but no track exists: |
479 | retval = GPX_TrackBegin(doc); |
479 | retval = GPX_TrackBegin(doc); |
480 | break; |
480 | break; |
481 | 481 | ||
482 | case GPX_DOC_TRACK_OPENED: // add tracksegement to the track |
482 | case GPX_DOC_TRACK_OPENED: // add tracksegement to the track |
483 | retval = GPX_TrackSegmentBegin(doc); |
483 | retval = GPX_TrackSegmentBegin(doc); |
484 | break; |
484 | break; |
485 | 485 | ||
486 | default: |
486 | default: |
487 | retval = 0; |
487 | retval = 0; |
488 | break; |
488 | break; |
489 | 489 | ||
490 | } |
490 | } |
491 | if(retval != 1) return(retval); // stop on error |
491 | if(retval != 1) return(retval); // stop on error |
492 | } |
492 | } |
493 | 493 | ||
494 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) // if the document was opened add coordinates to the document. |
494 | if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) // if the document was opened add coordinates to the document. |
495 | { |
495 | { |
496 | retval = GPX_TrackSegementAddPoint(doc,part); // add a track segment point |
496 | retval = GPX_TrackSegementAddPoint(doc,part); // add a track segment point |
497 | } |
497 | } |
498 | return(retval); |
498 | return(retval); |
499 | } |
499 | } |
500 | 500 | ||
501 | 501 |