Rev 183 | Rev 187 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 183 | Rev 185 | ||
---|---|---|---|
Line 133... | Line 133... | ||
133 | //------------------------------------------------------------- |
133 | //------------------------------------------------------------- |
134 | // Update GPSParamter |
134 | // Update GPSParamter |
135 | void GPS_UpdateParameter(void) |
135 | void GPS_UpdateParameter(void) |
136 | { |
136 | { |
137 | #define SWITCH_DELAY 500 |
137 | #define SWITCH_DELAY 500 |
- | 138 | static u8 wpclear = FALSE; |
|
138 | static u32 SwitchDelay = 0; |
139 | static u32 SwitchDelay = 0; |
139 | static GPS_FlightMode_t FlightMode_Old = GPS_FLIGHT_MODE_UNDEF; |
140 | static GPS_FlightMode_t FlightMode_Old = GPS_FLIGHT_MODE_UNDEF; |
Line 140... | Line 141... | ||
140 | 141 | ||
141 | // in case of bad receiving conditions |
142 | // in case of bad receiving conditions |
Line 170... | Line 171... | ||
170 | { |
171 | { |
171 | if(FlightMode_Old == GPS_FLIGHT_MODE_FREE) SetDelay(SWITCH_DELAY); |
172 | if(FlightMode_Old == GPS_FLIGHT_MODE_FREE) SetDelay(SWITCH_DELAY); |
172 | if(CheckDelay(SwitchDelay)) |
173 | if(CheckDelay(SwitchDelay)) |
173 | { |
174 | { |
174 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
175 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
175 | NCFlags &= ~(NC_FLAG_PH | NC_FLAG_CH); |
- | |
176 | NCFlags |= NC_FLAG_FREE; |
- | |
177 | } |
176 | } |
178 | } |
177 | } |
179 | else if(Parameter.NaviGpsModeControl < 180) |
178 | else if(Parameter.NaviGpsModeControl < 180) |
180 | { |
179 | { |
181 | if(FlightMode_Old == GPS_FLIGHT_MODE_AID) SetDelay(SWITCH_DELAY); |
180 | if(FlightMode_Old == GPS_FLIGHT_MODE_AID) SetDelay(SWITCH_DELAY); |
182 | if(CheckDelay(SwitchDelay)) |
181 | if(CheckDelay(SwitchDelay)) |
183 | { |
182 | { |
184 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_AID; |
183 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_AID; |
185 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_CH); |
- | |
186 | NCFlags |= NC_FLAG_PH; |
- | |
187 | } |
184 | } |
188 | } |
185 | } |
189 | else |
186 | else |
190 | { |
187 | { |
191 | if(FlightMode_Old == GPS_FLIGHT_MODE_WAYPOINT) SetDelay(SWITCH_DELAY); |
188 | if(FlightMode_Old == GPS_FLIGHT_MODE_WAYPOINT) SetDelay(SWITCH_DELAY); |
192 | if(CheckDelay(SwitchDelay)) |
189 | if(CheckDelay(SwitchDelay)) |
193 | { |
190 | { |
194 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
191 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
195 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_PH); |
- | |
196 | NCFlags |= NC_FLAG_CH; |
- | |
197 | } |
192 | } |
198 | } |
193 | } |
199 | } |
194 | } |
200 | GPS_Parameter.Gain = (float)Parameter.NaviGpsGain; |
195 | GPS_Parameter.Gain = (float)Parameter.NaviGpsGain; |
201 | GPS_Parameter.P = (float)Parameter.NaviGpsP; |
196 | GPS_Parameter.P = (float)Parameter.NaviGpsP; |
Line 212... | Line 207... | ||
212 | GPS_Parameter.MinSat = (u8)Parameter.NaviGpsMinSat; |
207 | GPS_Parameter.MinSat = (u8)Parameter.NaviGpsMinSat; |
213 | GPS_Parameter.StickThreshold = (s8)Parameter.NaviStickThreshold; |
208 | GPS_Parameter.StickThreshold = (s8)Parameter.NaviStickThreshold; |
214 | GPS_Parameter.WindCorrection = (float)Parameter.NaviWindCorrection; |
209 | GPS_Parameter.WindCorrection = (float)Parameter.NaviWindCorrection; |
215 | GPS_Parameter.OperatingRadius = (s32)Parameter.NaviOperatingRadius * 100; // conversion of m to cm |
210 | GPS_Parameter.OperatingRadius = (s32)Parameter.NaviOperatingRadius * 100; // conversion of m to cm |
216 | } |
211 | } |
217 | // FlightMode changed? |
212 | // FlightMode transitions |
218 | if(GPS_Parameter.FlightMode != FlightMode_Old) |
213 | if(GPS_Parameter.FlightMode != FlightMode_Old) |
219 | { |
214 | { |
220 | BeepTime = 200; // beep to indicate that mode has been switched |
215 | BeepTime = 100; // beep to indicate that mode has been switched |
221 | NCFlags &= ~NC_FLAG_TARGET_REACHED; |
216 | NCFlags &= ~NC_FLAG_TARGET_REACHED; |
- | 217 | switch(GPS_Parameter.FlightMode) |
|
- | 218 | { |
|
- | 219 | case GPS_FLIGHT_MODE_FREE: |
|
- | 220 | NCFlags &= ~(NC_FLAG_PH | NC_FLAG_CH); |
|
- | 221 | NCFlags |= NC_FLAG_FREE; |
|
222 | // if the mode has changed to free (avoid clear of WP-List when StopNavigation is active) |
222 | if(!StopNavigation && wpclear) |
- | 223 | { |
|
223 | if((!StopNavigation) && (GPS_Parameter.FlightMode == GPS_FLIGHT_MODE_FREE)) WPList_Clear(); // clear WPList if mode has changed to Free |
224 | WPList_Clear(); // clear WPList if mode has changed to Free |
- | 225 | wpclear = FALSE; |
|
- | 226 | } |
|
- | 227 | break; |
|
- | 228 | ||
- | 229 | case GPS_FLIGHT_MODE_AID: |
|
- | 230 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_CH); |
|
- | 231 | NCFlags |= NC_FLAG_PH; |
|
- | 232 | break; |
|
- | 233 | ||
- | 234 | case GPS_FLIGHT_MODE_WAYPOINT: |
|
- | 235 | wpclear = TRUE; // clear WP's only if CH was once active |
|
- | 236 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_PH); |
|
- | 237 | NCFlags |= NC_FLAG_CH; |
|
- | 238 | break; |
|
- | 239 | ||
- | 240 | default: // should never happen |
|
- | 241 | NCFlags = 0; |
|
- | 242 | break; |
|
- | 243 | } |
|
- | 244 | FlightMode_Old = GPS_Parameter.FlightMode; |
|
224 | } |
245 | } |
225 | FlightMode_Old = GPS_Parameter.FlightMode; |
- | |
226 | } |
246 | } |
Line 227... | Line 247... | ||
227 | 247 | ||
228 | //------------------------------------------------------------- |
248 | //------------------------------------------------------------- |
229 | // This function defines a good GPS signal condition |
249 | // This function defines a good GPS signal condition |