Rev 360 | Rev 491 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 360 | Rev 490 | ||
---|---|---|---|
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 | - | ||
- | 56 | #include <ctype.h> |
|
- | 57 | #include <stdio.h> |
|
- | 58 | #include <stdlib.h> |
|
57 | #include <string.h> |
59 | #include <string.h> |
58 | #include "91x_lib.h" |
60 | #include "91x_lib.h" |
59 | #include "waypoints.h" |
61 | #include "waypoints.h" |
60 | #include "uart1.h" |
62 | #include "uart1.h" |
- | 63 | #include "fat16.h" |
|
61 | 64 | ||
62 | // the waypoints list |
65 | // the waypoints list |
63 | #define MAX_LIST_LEN 101 |
66 | #define MAX_LIST_LEN 101 |
64 | 67 | ||
65 | Point_t PointList[MAX_LIST_LEN]; |
68 | Point_t PointList[MAX_LIST_LEN]; |
66 | u8 WPIndex = 0; // list index of GPS point representig the current WP, can be maximal WPCount |
69 | u8 WPIndex = 0; // list index of GPS point representig the current WP, can be maximal WPCount |
67 | u8 POIIndex = 0; // list index of GPS Point representing the current POI, can be maximal WPCount |
70 | u8 POIIndex = 0; // list index of GPS Point representing the current POI, can be maximal WPCount |
68 | u8 WPCount = 0; // number of waypoints |
71 | u8 WPCount = 0; // number of waypoints |
69 | u8 PointCount = 0; // number of wp in the list can be maximal equal to MAX_LIST_LEN |
72 | u8 PointCount = 0; // number of wp in the list can be maximal equal to MAX_LIST_LEN |
70 | u8 POICount = 0; |
73 | u8 POICount = 0; |
71 | 74 | ||
72 | u8 WPActive = FALSE; |
75 | u8 WPActive = FALSE; |
73 | 76 | ||
74 | u8 PointList_Init(void) |
77 | u8 PointList_Init(void) |
75 | { |
78 | { |
76 | return PointList_Clear(); |
79 | return PointList_Clear(); |
77 | } |
80 | } |
78 | 81 | ||
79 | u8 PointList_Clear(void) |
82 | u8 PointList_Clear(void) |
80 | { |
83 | { |
81 | u8 i; |
84 | u8 i; |
82 | WPIndex = 0; // real list position are 1 ,2, 3 ... |
85 | WPIndex = 0; // real list position are 1 ,2, 3 ... |
83 | POIIndex = 0; // real list position are 1 ,2, 3 ... |
86 | POIIndex = 0; // real list position are 1 ,2, 3 ... |
84 | WPCount = 0; // no waypoints |
87 | WPCount = 0; // no waypoints |
85 | POICount = 0; |
88 | POICount = 0; |
86 | PointCount = 0; // no contents |
89 | PointCount = 0; // no contents |
87 | WPActive = FALSE; |
90 | WPActive = FALSE; |
88 | NaviData.WaypointNumber = WPCount; |
91 | NaviData.WaypointNumber = WPCount; |
89 | NaviData.WaypointIndex = 0; |
92 | NaviData.WaypointIndex = 0; |
90 | 93 | ||
91 | for(i = 0; i < MAX_LIST_LEN; i++) |
94 | for(i = 0; i < MAX_LIST_LEN; i++) |
92 | { |
95 | { |
93 | PointList[i].Position.Status = INVALID; |
96 | PointList[i].Position.Status = INVALID; |
94 | PointList[i].Position.Latitude = 0; |
97 | PointList[i].Position.Latitude = 0; |
95 | PointList[i].Position.Longitude = 0; |
98 | PointList[i].Position.Longitude = 0; |
96 | PointList[i].Position.Altitude = 0; |
99 | PointList[i].Position.Altitude = 0; |
97 | PointList[i].Heading = 361; // invalid value |
100 | PointList[i].Heading = 361; // invalid value |
98 | PointList[i].ToleranceRadius = 0; // in meters, if the MK is within that range around the target, then the next target is triggered |
101 | PointList[i].ToleranceRadius = 0; // in meters, if the MK is within that range around the target, then the next target is triggered |
99 | PointList[i].HoldTime = 0; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
102 | PointList[i].HoldTime = 0; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
100 | PointList[i].Type = POINT_TYPE_INVALID; |
- | |
101 | PointList[i].Event_Flag = 0; // future implementation |
103 | PointList[i].Event_Flag = 0; // future implementation |
- | 104 | PointList[i].Index = 0; |
|
- | 105 | PointList[i].Type = POINT_TYPE_INVALID; |
|
- | 106 | PointList[i].WP_EventChannelValue = 0; |
|
102 | PointList[i].AltitudeRate = 0; // no change of setpoint |
107 | PointList[i].AltitudeRate = 0; // no change of setpoint |
- | 108 | PointList[i].Speed = 0; |
|
- | 109 | PointList[i].CamAngle = 0; |
|
- | 110 | PointList[i].Name[0] = 0; |
|
103 | } |
111 | } |
104 | return TRUE; |
112 | return TRUE; |
105 | } |
113 | } |
106 | 114 | ||
107 | u8 PointList_GetCount(void) |
115 | u8 PointList_GetCount(void) |
108 | { |
116 | { |
109 | return PointCount; // number of points in the list |
117 | return PointCount; // number of points in the list |
110 | } |
118 | } |
111 | 119 | ||
112 | Point_t* PointList_GetAt(u8 index) |
120 | Point_t* PointList_GetAt(u8 index) |
113 | { |
121 | { |
114 | if((index > 0) && (index <= PointCount)) return(&(PointList[index-1])); // return pointer to this waypoint |
122 | if((index > 0) && (index <= PointCount)) return(&(PointList[index-1])); // return pointer to this waypoint |
115 | else return(NULL); |
123 | else return(NULL); |
116 | } |
124 | } |
117 | 125 | ||
118 | u8 PointList_SetAt(Point_t* pPoint) |
126 | u8 PointList_SetAt(Point_t* pPoint) |
119 | { |
127 | { |
120 | // if index is in range |
128 | // if index is in range |
121 | if((pPoint->Index > 0) && (pPoint->Index <= MAX_LIST_LEN)) |
129 | if((pPoint->Index > 0) && (pPoint->Index <= MAX_LIST_LEN)) |
122 | { |
130 | { |
123 | // check list entry before update |
131 | // check list entry before update |
124 | switch(PointList[pPoint->Index-1].Type) |
132 | switch(PointList[pPoint->Index-1].Type) |
125 | { |
133 | { |
126 | case POINT_TYPE_INVALID: // was invalid |
134 | case POINT_TYPE_INVALID: // was invalid |
127 | switch(pPoint->Type) |
135 | switch(pPoint->Type) |
128 | { |
136 | { |
129 | default: |
137 | default: |
130 | case POINT_TYPE_INVALID: |
138 | case POINT_TYPE_INVALID: |
131 | // nothing to do |
139 | // nothing to do |
132 | break; |
140 | break; |
133 | 141 | ||
134 | case POINT_TYPE_WP: |
142 | case POINT_TYPE_WP: |
135 | WPCount++; |
143 | WPCount++; |
136 | PointCount++; |
144 | PointCount++; |
137 | break; |
145 | break; |
138 | 146 | ||
139 | case POINT_TYPE_POI: |
147 | case POINT_TYPE_POI: |
140 | POICount++; |
148 | POICount++; |
141 | PointCount++; |
149 | PointCount++; |
142 | break; |
150 | break; |
143 | } |
151 | } |
144 | break; |
152 | break; |
145 | 153 | ||
146 | case POINT_TYPE_WP: // was a waypoint |
154 | case POINT_TYPE_WP: // was a waypoint |
147 | switch(pPoint->Type) |
155 | switch(pPoint->Type) |
148 | { |
156 | { |
149 | case POINT_TYPE_INVALID: |
157 | case POINT_TYPE_INVALID: |
150 | WPCount--; |
158 | WPCount--; |
151 | PointCount--; |
159 | PointCount--; |
152 | break; |
160 | break; |
153 | 161 | ||
154 | default: |
162 | default: |
155 | case POINT_TYPE_WP: |
163 | case POINT_TYPE_WP: |
156 | //nothing to do |
164 | //nothing to do |
157 | break; |
165 | break; |
158 | 166 | ||
159 | case POINT_TYPE_POI: |
167 | case POINT_TYPE_POI: |
160 | POICount++; |
168 | POICount++; |
161 | WPCount--; |
169 | WPCount--; |
162 | break; |
170 | break; |
163 | } |
171 | } |
164 | break; |
172 | break; |
165 | 173 | ||
166 | case POINT_TYPE_POI: // was a poi |
174 | case POINT_TYPE_POI: // was a poi |
167 | switch(pPoint->Type) |
175 | switch(pPoint->Type) |
168 | { |
176 | { |
169 | case POINT_TYPE_INVALID: |
177 | case POINT_TYPE_INVALID: |
170 | POICount--; |
178 | POICount--; |
171 | PointCount--; |
179 | PointCount--; |
172 | break; |
180 | break; |
173 | 181 | ||
174 | case POINT_TYPE_WP: |
182 | case POINT_TYPE_WP: |
175 | WPCount++; |
183 | WPCount++; |
176 | POICount--; |
184 | POICount--; |
177 | break; |
185 | break; |
178 | 186 | ||
179 | case POINT_TYPE_POI: |
187 | case POINT_TYPE_POI: |
180 | default: |
188 | default: |
181 | // nothing to do |
189 | // nothing to do |
182 | break; |
190 | break; |
183 | } |
191 | } |
184 | break; |
192 | break; |
185 | } |
193 | } |
186 | memcpy(&PointList[pPoint->Index-1], pPoint, sizeof(Point_t)); // copy data to list entry |
194 | memcpy(&PointList[pPoint->Index-1], pPoint, sizeof(Point_t)); // copy data to list entry |
187 | NaviData.WaypointNumber = WPCount; |
195 | NaviData.WaypointNumber = WPCount; |
188 | return pPoint->Index; |
196 | return pPoint->Index; |
189 | } |
197 | } |
190 | else return(0); |
198 | else return(0); |
191 | } |
199 | } |
192 | 200 | ||
193 | // returns the pointer to the first waypoint within the list |
201 | // returns the pointer to the first waypoint within the list |
194 | Point_t* PointList_WPBegin(void) |
202 | Point_t* PointList_WPBegin(void) |
195 | { |
203 | { |
196 | u8 i; |
204 | u8 i; |
197 | WPIndex = 0; // set list position invalid |
205 | WPIndex = 0; // set list position invalid |
198 | 206 | ||
199 | if(WPActive == FALSE) return(NULL); |
207 | if(WPActive == FALSE) return(NULL); |
200 | 208 | ||
201 | POIIndex = 0; // set invalid POI |
209 | POIIndex = 0; // set invalid POI |
202 | if(PointCount > 0) |
210 | if(PointCount > 0) |
203 | { |
211 | { |
204 | // search for first wp in list |
212 | // search for first wp in list |
205 | for(i = 0; i <MAX_LIST_LEN; i++) |
213 | for(i = 0; i <MAX_LIST_LEN; i++) |
206 | { |
214 | { |
207 | if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) |
215 | if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) |
208 | { |
216 | { |
209 | WPIndex = i + 1; |
217 | WPIndex = i + 1; |
210 | break; |
218 | break; |
211 | } |
219 | } |
212 | } |
220 | } |
213 | if(WPIndex) // found a WP in the list |
221 | if(WPIndex) // found a WP in the list |
214 | { |
222 | { |
215 | NaviData.WaypointIndex = 1; |
223 | NaviData.WaypointIndex = 1; |
216 | // update index to POI |
224 | // update index to POI |
217 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
225 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
218 | else POIIndex = 0; |
226 | else POIIndex = 0; |
219 | } |
227 | } |
220 | else // some points in the list but no WP found |
228 | else // some points in the list but no WP found |
221 | { |
229 | { |
222 | NaviData.WaypointIndex = 0; |
230 | NaviData.WaypointIndex = 0; |
223 | //Check for an existing POI |
231 | //Check for an existing POI |
224 | for(i = 0; i < MAX_LIST_LEN; i++) |
232 | for(i = 0; i < MAX_LIST_LEN; i++) |
225 | { |
233 | { |
226 | if((PointList[i].Type == POINT_TYPE_POI) && (PointList[i].Position.Status != INVALID)) |
234 | if((PointList[i].Type == POINT_TYPE_POI) && (PointList[i].Position.Status != INVALID)) |
227 | { |
235 | { |
228 | POIIndex = i + 1; |
236 | POIIndex = i + 1; |
229 | break; |
237 | break; |
230 | } |
238 | } |
231 | } |
239 | } |
232 | } |
240 | } |
233 | } |
241 | } |
234 | else // no point in the list |
242 | else // no point in the list |
235 | { |
243 | { |
236 | POIIndex = 0; |
244 | POIIndex = 0; |
237 | NaviData.WaypointIndex = 0; |
245 | NaviData.WaypointIndex = 0; |
238 | } |
246 | } |
239 | 247 | ||
240 | if(WPIndex) return(&(PointList[WPIndex-1])); |
248 | if(WPIndex) return(&(PointList[WPIndex-1])); |
241 | else return(NULL); |
249 | else return(NULL); |
242 | } |
250 | } |
243 | 251 | ||
244 | // returns the last waypoint |
252 | // returns the last waypoint |
245 | Point_t* PointList_WPEnd(void) |
253 | Point_t* PointList_WPEnd(void) |
246 | { |
254 | { |
247 | 255 | ||
248 | u8 i; |
256 | u8 i; |
249 | WPIndex = 0; // set list position invalid |
257 | WPIndex = 0; // set list position invalid |
250 | POIIndex = 0; // set invalid |
258 | POIIndex = 0; // set invalid |
251 | 259 | ||
252 | if(WPActive == FALSE) return(NULL); |
260 | if(WPActive == FALSE) return(NULL); |
253 | 261 | ||
254 | if(PointCount > 0) |
262 | if(PointCount > 0) |
255 | { |
263 | { |
256 | // search backward! |
264 | // search backward! |
257 | for(i = 1; i <= MAX_LIST_LEN; i++) |
265 | for(i = 1; i <= MAX_LIST_LEN; i++) |
258 | { |
266 | { |
259 | if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_WP) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
267 | if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_WP) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
260 | { |
268 | { |
261 | WPIndex = MAX_LIST_LEN - i + 1; |
269 | WPIndex = MAX_LIST_LEN - i + 1; |
262 | break; |
270 | break; |
263 | } |
271 | } |
264 | } |
272 | } |
265 | if(WPIndex) // found a WP within the list |
273 | if(WPIndex) // found a WP within the list |
266 | { |
274 | { |
267 | NaviData.WaypointIndex = WPCount; |
275 | NaviData.WaypointIndex = WPCount; |
268 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
276 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
269 | else POIIndex = 0; |
277 | else POIIndex = 0; |
270 | } |
278 | } |
271 | else // list contains some points but no WP in the list |
279 | else // list contains some points but no WP in the list |
272 | { |
280 | { |
273 | // search backward for a POI! |
281 | // search backward for a POI! |
274 | for(i = 1; i <= MAX_LIST_LEN; i++) |
282 | for(i = 1; i <= MAX_LIST_LEN; i++) |
275 | { |
283 | { |
276 | if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_POI) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
284 | if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_POI) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
277 | { |
285 | { |
278 | POIIndex = MAX_LIST_LEN - i + 1; |
286 | POIIndex = MAX_LIST_LEN - i + 1; |
279 | break; |
287 | break; |
280 | } |
288 | } |
281 | } |
289 | } |
282 | NaviData.WaypointIndex = 0; |
290 | NaviData.WaypointIndex = 0; |
283 | } |
291 | } |
284 | } |
292 | } |
285 | else // no point in the list |
293 | else // no point in the list |
286 | { |
294 | { |
287 | POIIndex = 0; |
295 | POIIndex = 0; |
288 | NaviData.WaypointIndex = 0; |
296 | NaviData.WaypointIndex = 0; |
289 | } |
297 | } |
290 | if(WPIndex) return(&(PointList[WPIndex-1])); |
298 | if(WPIndex) return(&(PointList[WPIndex-1])); |
291 | else return(NULL); |
299 | else return(NULL); |
292 | } |
300 | } |
293 | 301 | ||
294 | // returns a pointer to the next waypoint or NULL if the end of the list has been reached |
302 | // returns a pointer to the next waypoint or NULL if the end of the list has been reached |
295 | Point_t* PointList_WPNext(void) |
303 | Point_t* PointList_WPNext(void) |
296 | { |
304 | { |
297 | u8 wp_found = 0; |
305 | u8 wp_found = 0; |
298 | if(WPActive == FALSE) return(NULL); |
306 | if(WPActive == FALSE) return(NULL); |
299 | 307 | ||
300 | if(WPIndex < MAX_LIST_LEN) // if there is a next entry in the list |
308 | if(WPIndex < MAX_LIST_LEN) // if there is a next entry in the list |
301 | { |
309 | { |
302 | u8 i; |
310 | u8 i; |
303 | for(i = WPIndex; i < MAX_LIST_LEN; i++) // start search for next at next list entry |
311 | for(i = WPIndex; i < MAX_LIST_LEN; i++) // start search for next at next list entry |
304 | { |
312 | { |
305 | if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) // jump over POIs |
313 | if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) // jump over POIs |
306 | { |
314 | { |
307 | wp_found = i+1; |
315 | wp_found = i+1; |
308 | break; |
316 | break; |
309 | } |
317 | } |
310 | } |
318 | } |
311 | } |
319 | } |
312 | if(wp_found) |
320 | if(wp_found) |
313 | { |
321 | { |
314 | WPIndex = wp_found; // update list position |
322 | WPIndex = wp_found; // update list position |
315 | NaviData.WaypointIndex++; |
323 | NaviData.WaypointIndex++; |
316 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
324 | if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
317 | else POIIndex = 0; |
325 | else POIIndex = 0; |
318 | return(&(PointList[WPIndex-1])); // return pointer to this waypoint |
326 | return(&(PointList[WPIndex-1])); // return pointer to this waypoint |
319 | } |
327 | } |
320 | else |
328 | else |
321 | { // no next wp found |
329 | { // no next wp found |
322 | NaviData.WaypointIndex = 0; |
330 | NaviData.WaypointIndex = 0; |
323 | POIIndex = 0; |
331 | POIIndex = 0; |
324 | return(NULL); |
332 | return(NULL); |
325 | } |
333 | } |
326 | } |
334 | } |
327 | 335 | ||
328 | void PointList_WPActive(u8 set) |
336 | void PointList_WPActive(u8 set) |
329 | { |
337 | { |
330 | if(set) |
338 | if(set) |
331 | { |
339 | { |
332 | WPActive = TRUE; |
340 | WPActive = TRUE; |
333 | PointList_WPBegin(); // uopdates POI index |
341 | PointList_WPBegin(); // uopdates POI index |
334 | } |
342 | } |
335 | else |
343 | else |
336 | { |
344 | { |
337 | WPActive = FALSE; |
345 | WPActive = FALSE; |
338 | POIIndex = 0; // disable POI also |
346 | POIIndex = 0; // disable POI also |
339 | } |
347 | } |
340 | } |
348 | } |
341 | 349 | ||
342 | Point_t* PointList_GetPOI(void) |
350 | Point_t* PointList_GetPOI(void) |
343 | { |
351 | { |
344 | return PointList_GetAt(POIIndex); |
352 | return PointList_GetAt(POIIndex); |
345 | } |
353 | } |
- | 354 | ||
- | 355 | #define LINE_MAX 70 |
|
- | 356 | #define WP_FILE_VERSION_COMPATIBLE 3 |
|
- | 357 | // save actual point list to SD card |
|
- | 358 | u8 PointList_SaveToFile(u8 place) |
|
- | 359 | { |
|
- | 360 | File_t *fp; |
|
- | 361 | s8 wpline[LINE_MAX], retval = 0; |
|
- | 362 | // user absolute path, i.e. leading / |
|
- | 363 | ||
- | 364 | sprintf(wpline, "/list_%03d.wpl", place); |
|
- | 365 | ||
- | 366 | UART1_PutString("\n\r Write "); |
|
- | 367 | UART1_PutString(wpline); |
|
- | 368 | UART1_PutString("..."); |
|
- | 369 | ||
- | 370 | UART1_PutString("\n\r Save WPL..."); |
|
- | 371 | ||
- | 372 | if(Fat16_IsValid()) |
|
- | 373 | { // check if wpl file is existing |
|
- | 374 | fp = fopen_(wpline, 'w'); // try to open the file |
|
- | 375 | if(fp == NULL) |
|
- | 376 | { |
|
- | 377 | UART1_PutString("ERROR: Creating waypoint file!\r\n"); |
|
- | 378 | return(retval); |
|
- | 379 | } |
|
- | 380 | // Create general section and key entries |
|
- | 381 | fputs_("[General]\r\n", fp); |
|
- | 382 | sprintf(wpline, "FileVersion=%d\r\n", WP_FILE_VERSION_COMPATIBLE); |
|
- | 383 | fputs_(wpline, fp); |
|
- | 384 | sprintf(wpline, "NumberOfWaypoints=%d\r\n", PointCount); |
|
- | 385 | fputs_(wpline, fp); |
|
- | 386 | // dump all points if existent |
|
- | 387 | if(PointCount) |
|
- | 388 | { |
|
- | 389 | u8 i, u8_1; |
|
- | 390 | s32 i32_1, i32_2; |
|
- | 391 | ||
- | 392 | for (i = 0; i < PointCount; i++) |
|
- | 393 | { |
|
- | 394 | sprintf(wpline, "[Point%d]\r\n",PointList[i].Index); |
|
- | 395 | fputs_(wpline, fp); |
|
- | 396 | // write latitude in deg |
|
- | 397 | if(PointList[i].Position.Latitude < 0) u8_1 = '-'; |
|
- | 398 | else u8_1 = '+'; |
|
- | 399 | i32_1 = abs(PointList[i].Position.Latitude)/10000000L; |
|
- | 400 | i32_2 = abs(PointList[i].Position.Latitude)%10000000L; |
|
- | 401 | sprintf(wpline, "Latitude=%c%ld.%07ld\r\n", u8_1, i32_1, i32_2); |
|
- | 402 | fputs_(wpline, fp); |
|
- | 403 | // write longitude in deg |
|
- | 404 | if(PointList[i].Position.Longitude < 0) u8_1 = '-'; |
|
- | 405 | else u8_1 = '+'; |
|
- | 406 | i32_1 = abs(PointList[i].Position.Longitude)/10000000L; |
|
- | 407 | i32_2 = abs(PointList[i].Position.Longitude)%10000000L; |
|
- | 408 | sprintf(wpline, "Longitude=%c%ld.%07ld\r\n", u8_1, i32_1, i32_2); |
|
- | 409 | fputs_(wpline, fp); |
|
- | 410 | // write tolerace radius in m |
|
- | 411 | sprintf(wpline, "Radius=%d\r\n", PointList[i].ToleranceRadius); |
|
- | 412 | fputs_(wpline, fp); |
|
- | 413 | // write altitude in m |
|
- | 414 | if(PointList[i].Position.Altitude < 0) u8_1 = '-'; |
|
- | 415 | else u8_1 = '+'; |
|
- | 416 | if(PointList[i].Type == POINT_TYPE_POI) |
|
- | 417 | { |
|
- | 418 | i32_1 = abs(PointList[i].Position.Altitude)/100L; // cm --> m |
|
- | 419 | i32_2 = abs(PointList[i].Position.Altitude)%100L; |
|
- | 420 | } |
|
- | 421 | else |
|
- | 422 | { |
|
- | 423 | i32_1 = abs(PointList[i].Position.Altitude)/10L; // dm --> m |
|
- | 424 | i32_2 = abs(PointList[i].Position.Altitude)%10L; |
|
- | 425 | } |
|
- | 426 | sprintf(wpline, "Altitude=%c%ld.%01ld\r\n", u8_1, i32_1, i32_2); |
|
- | 427 | fputs_(wpline, fp); |
|
- | 428 | // write climb rate in 0.1 m/s |
|
- | 429 | sprintf(wpline, "ClimbRate=%d\r\n", PointList[i].AltitudeRate); |
|
- | 430 | fputs_(wpline, fp); |
|
- | 431 | // write hold time in s |
|
- | 432 | sprintf(wpline, "DelayTime=%d\r\n", PointList[i].HoldTime); |
|
- | 433 | fputs_(wpline, fp); |
|
- | 434 | // write event channel value |
|
- | 435 | sprintf(wpline, "WP_Event_Channel_Value=%d\r\n", PointList[i].WP_EventChannelValue); |
|
- | 436 | fputs_(wpline, fp); |
|
- | 437 | // write heading in deg (0= nothing, neg. values index to poi) |
|
- | 438 | sprintf(wpline, "Heading=%d\r\n", PointList[i].Heading); |
|
- | 439 | fputs_(wpline, fp); |
|
- | 440 | // write speed in 0.1 m/s |
|
- | 441 | sprintf(wpline, "Speed=%d\r\n", PointList[i].Speed); |
|
- | 442 | fputs_(wpline, fp); |
|
- | 443 | // write cam angle in degree (255 -> POI-Automatic) |
|
- | 444 | sprintf(wpline, "CAM-Nick=%d\r\n", PointList[i].CamAngle); |
|
- | 445 | fputs_(wpline, fp); |
|
- | 446 | // write point type |
|
- | 447 | sprintf(wpline, "Type=%d\r\n", PointList[i].Type + 1); |
|
- | 448 | fputs_(wpline, fp); |
|
- | 449 | // write prefix |
|
- | 450 | //if(PointList[i].Type == POINT_TYPE_WP) u8_1 = 'P'; |
|
- | 451 | //else u8_1 = '0'; |
|
- | 452 | sprintf(wpline, "Prefix=%s\r\n", PointList[i].Name); |
|
- | 453 | fputs_(wpline, fp); |
|
- | 454 | } // EOF loop over all points |
|
- | 455 | } // EOF if(PointCount) |
|
- | 456 | if(EOF == fclose_(fp)) |
|
- | 457 | { |
|
- | 458 | UART1_PutString("failed!\r\n"); |
|
- | 459 | } |
|
- | 460 | else |
|
- | 461 | { |
|
- | 462 | UART1_PutString("ok\r\n"); |
|
- | 463 | retval = 1; |
|
- | 464 | } |
|
- | 465 | } // EOF if(Fat16_IsValid()) |
|
- | 466 | UART1_PutString("no file system found!\r\n"); |
|
- | 467 | return(retval); |
|
- | 468 | } |
|
- | 469 | ||
- | 470 | // load actual point list from SD card |
|
- | 471 | u8 PointList_ReadFromFile(u8 place) |
|
- | 472 | { |
|
- | 473 | File_t *fp; |
|
- | 474 | s8 wpline[LINE_MAX], retval = 0; |
|
- | 475 | ||
- | 476 | s8 *name, *value; |
|
- | 477 | u8 i; |
|
- | 478 | ||
- | 479 | u8 IsGeneralSection = 0; |
|
- | 480 | u8 IsPointSection = 0; |
|
- | 481 | u8 WPNumber = 0; |
|
- | 482 | ||
- | 483 | // user absolute path, i.e. leading / |
|
- | 484 | sprintf(wpline, "/list_%03d.wpl", place); |
|
- | 485 | ||
- | 486 | UART1_PutString("\n\r Read "); |
|
- | 487 | UART1_PutString(wpline); |
|
- | 488 | UART1_PutString("..."); |
|
- | 489 | ||
- | 490 | if(Fat16_IsValid()) |
|
- | 491 | { // check if wpl file is existing |
|
- | 492 | fp = fopen_(wpline, 'r'); // try to open the file |
|
- | 493 | if(fp == NULL) |
|
- | 494 | { |
|
- | 495 | UART1_PutString("ERROR: Reading waypoint file!\r\n"); |
|
- | 496 | return(0); |
|
- | 497 | } |
|
- | 498 | // clear point list first |
|
- | 499 | PointList_Clear(); |
|
- | 500 | // read all lines from file |
|
- | 501 | while(fgets_(wpline, LINE_MAX, fp) != 0) |
|
- | 502 | { |
|
- | 503 | if ( // ignorelines starting with \r,\n,' ',';','#' |
|
- | 504 | (wpline[0] != '\n') && |
|
- | 505 | (wpline[0] != '\r') && |
|
- | 506 | (wpline[0] != ' ' ) && |
|
- | 507 | (wpline[0] != ';' ) && |
|
- | 508 | (wpline[0] != '#' ) |
|
- | 509 | ) |
|
- | 510 | { |
|
- | 511 | // check for section line found |
|
- | 512 | if(wpline[0] == '[') |
|
- | 513 | { |
|
- | 514 | // next section found |
|
- | 515 | IsGeneralSection = 0; |
|
- | 516 | IsPointSection = 0; |
|
- | 517 | ||
- | 518 | name = strtok(&wpline[1], "]"); |
|
- | 519 | if(name != NULL) // if section name |
|
- | 520 | { |
|
- | 521 | // check section type |
|
- | 522 | for(i=0; name[i]; i++) name[i] = toupper(name[i]); // convert to upper case |
|
- | 523 | ||
- | 524 | if(strncmp(name, "POINT", 5) == 0) |
|
- | 525 | { |
|
- | 526 | IsPointSection = (u8)atoi(&name[5]); |
|
- | 527 | PointCount++; |
|
- | 528 | } |
|
- | 529 | else if(strcmp(name, "GENERAL") == 0) |
|
- | 530 | { |
|
- | 531 | IsGeneralSection = 1; |
|
- | 532 | } |
|
- | 533 | else |
|
- | 534 | { |
|
- | 535 | UART1_PutString("Unknown section: "); |
|
- | 536 | UART1_PutString(name); |
|
- | 537 | UART1_PutString("\r\n"); |
|
- | 538 | } |
|
- | 539 | } |
|
- | 540 | } // EOF section line |
|
- | 541 | else |
|
- | 542 | { // look for key entrys of each sections |
|
- | 543 | name = strtok(wpline, "="); // get name |
|
- | 544 | value = strtok(NULL, "="); // get value |
|
- | 545 | if ((name != NULL) && (value != NULL)) |
|
- | 546 | { |
|
- | 547 | for(i=0; name[i]; i++) name[i] = toupper(name[i]); // convert to upper case |
|
- | 548 | if(IsPointSection && (IsPointSection <= WPNumber)) |
|
- | 549 | { |
|
- | 550 | if(strcmp(name, "LATITUDE") == 0) |
|
- | 551 | { |
|
- | 552 | PointList[IsPointSection-1].Position.Latitude = (s32)(atof(value) * 1E7); |
|
- | 553 | } |
|
- | 554 | else if(strcmp(name, "LONGITUDE") == 0) |
|
- | 555 | { |
|
- | 556 | PointList[IsPointSection-1].Position.Longitude = (s32)(atof(value) * 1E7); |
|
- | 557 | } |
|
- | 558 | else if(strcmp(name, "RADIUS") == 0) |
|
- | 559 | { |
|
- | 560 | PointList[IsPointSection-1].ToleranceRadius = (u8)atoi(value); |
|
- | 561 | } |
|
- | 562 | else if(strcmp(name, "ALTITUDE") == 0) |
|
- | 563 | { |
|
- | 564 | PointList[IsPointSection-1].Position.Altitude = (s32)(atof(value) * 100.0); // in cm |
|
- | 565 | PointList[IsPointSection-1].Position.Status = NEWDATA; |
|
- | 566 | } |
|
- | 567 | else if(strcmp(name, "CLIMBRATE") == 0) |
|
- | 568 | { |
|
- | 569 | PointList[IsPointSection-1].AltitudeRate = (u8)atoi(value); |
|
- | 570 | } |
|
- | 571 | else if(strcmp(name, "DELAYTIME") == 0) |
|
- | 572 | { |
|
- | 573 | PointList[IsPointSection-1].HoldTime = (u8)atoi(value); |
|
- | 574 | } |
|
- | 575 | else if(strcmp(name, "WP_EVENT_CHANNEL_VALUE") == 0) |
|
- | 576 | { |
|
- | 577 | PointList[IsPointSection-1].WP_EventChannelValue = (u8)atoi(value); |
|
- | 578 | } |
|
- | 579 | else if(strcmp(name, "HEADING") == 0) |
|
- | 580 | { |
|
- | 581 | PointList[IsPointSection-1].Heading = (s16)atoi(value); |
|
- | 582 | } |
|
- | 583 | else if(strcmp(name, "SPEED") == 0) |
|
- | 584 | { |
|
- | 585 | PointList[IsPointSection-1].Speed = (u8)atoi(value); |
|
- | 586 | } |
|
- | 587 | else if(strcmp(name, "CAM-NICK") == 0) |
|
- | 588 | { |
|
- | 589 | PointList[IsPointSection-1].CamAngle = (u8)atoi(value); |
|
- | 590 | } |
|
- | 591 | else if(strcmp(name, "TYPE") == 0) |
|
- | 592 | { |
|
- | 593 | PointList[IsPointSection-1].Type = (u8)atoi(value); |
|
- | 594 | if(PointList[IsPointSection-1].Type > 0) PointList[IsPointSection-1].Type--; // index shift |
|
- | 595 | else PointList[IsPointSection-1].Type = POINT_TYPE_INVALID; |
|
- | 596 | ||
- | 597 | switch(PointList[IsPointSection-1].Type) |
|
- | 598 | { |
|
- | 599 | case POINT_TYPE_WP: |
|
- | 600 | // this works only if altitude key is set before point type key in WPL file !! |
|
- | 601 | PointList[IsPointSection-1].Position.Altitude /= 10; // dm only for WPs |
|
- | 602 | WPCount++; |
|
- | 603 | break; |
|
- | 604 | ||
- | 605 | case POINT_TYPE_POI: |
|
- | 606 | POICount++; |
|
- | 607 | break; |
|
- | 608 | } |
|
- | 609 | } |
|
- | 610 | else if(strcmp(name, "PREFIX") == 0) |
|
- | 611 | { |
|
- | 612 | strncpy(PointList[IsPointSection-1].Name, value, 4); |
|
- | 613 | PointList[IsPointSection-1].Name[3] = 0; // Terminate string |
|
- | 614 | } |
|
- | 615 | else |
|
- | 616 | { |
|
- | 617 | UART1_PutString("Unknown key: "); |
|
- | 618 | UART1_PutString(name); |
|
- | 619 | UART1_PutString("\r\n"); |
|
- | 620 | } |
|
- | 621 | } // EOF point section |
|
- | 622 | else if(IsGeneralSection) |
|
- | 623 | { |
|
- | 624 | if(strcmp(name, "NUMBEROFWAYPOINTS") == 0) |
|
- | 625 | { |
|
- | 626 | WPNumber = (u8)atoi(value); |
|
- | 627 | if(!WPNumber) // no waypoints in file |
|
- | 628 | { |
|
- | 629 | return(1); // we are done here |
|
- | 630 | } |
|
- | 631 | else if(WPNumber > MAX_LIST_LEN) // number o points larger than ram list |
|
- | 632 | { |
|
- | 633 | UART1_PutString("To much points!"); |
|
- | 634 | return(0); |
|
- | 635 | } |
|
- | 636 | } |
|
- | 637 | else if (strcmp(name, "FILEVERSION") == 0) |
|
- | 638 | { |
|
- | 639 | if((u8)atoi(value) != WP_FILE_VERSION_COMPATIBLE) |
|
- | 640 | { |
|
- | 641 | UART1_PutString("Bad file version!\r\n"); |
|
- | 642 | return(0); |
|
- | 643 | } |
|
- | 644 | } |
|
- | 645 | else |
|
- | 646 | { |
|
- | 647 | UART1_PutString("Unknown key: "); |
|
- | 648 | UART1_PutString(name); |
|
- | 649 | UART1_PutString("\r\n"); |
|
- | 650 | } |
|
- | 651 | } // EOF general section |
|
- | 652 | } // EOF valid key entry |
|
- | 653 | } // EOF key entry line |
|
- | 654 | } // valid line |
|
- | 655 | } // EOF loop over all lines |
|
- | 656 | fclose_(fp); |
|
- | 657 | NaviData.WaypointNumber = WPCount; |
|
- | 658 | UART1_PutString("ok\r\n"); |
|
- | 659 | retval = 1; |
|
- | 660 | } // EOF if(Fat16_IsValid()) |
|
- | 661 | else UART1_PutString("no file system found!\r\n"); |
|
- | 662 | return(retval); |
|
- | 663 | } |
|
346 | 664 | ||
347 | 665 |