Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2003 | - | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
||
3 | // + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
||
4 | // + www.MikroKopter.com |
||
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
6 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
||
7 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten und nicht-kommerziellen Gebrauch zulässig ist. |
||
8 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
||
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
||
11 | // + Verkauf von Luftbildaufnahmen, usw. |
||
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
13 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
||
14 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
||
15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
16 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
17 | // + auf anderen Webseiten oder Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
18 | // + eindeutig als Ursprung verlinkt und genannt werden |
||
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
20 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
21 | // + Benutzung auf eigene Gefahr |
||
22 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
24 | // + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
25 | // + mit unserer Zustimmung zulässig |
||
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
||
30 | // + this list of conditions and the following disclaimer. |
||
31 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
32 | // + from this software without specific prior written permission. |
||
33 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
||
34 | // + for non-commercial use (directly or indirectly) |
||
35 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
||
36 | // + with our written permission |
||
37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
||
38 | // + clearly linked as origin |
||
39 | // + * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
||
40 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
41 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
42 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
43 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
44 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
45 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
46 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
47 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
48 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
49 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
50 | // + POSSIBILITY OF SUCH DAMAGE. |
||
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
52 | #include "main.h" |
||
53 | unsigned char DisableRcOffBeeping = 0; |
||
54 | unsigned char PlatinenVersion = 10; |
||
55 | unsigned char SendVersionToNavi = 1; |
||
56 | unsigned char BattLowVoltageWarning = 94; |
||
57 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
||
58 | unsigned int FlugSekunden = 0; |
||
59 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
||
60 | unsigned char FoundMotors = 0; |
||
61 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
||
62 | |||
63 | static char panodelay = 0; ///martinw |
||
64 | //static char panoleddelay = 0; ///martinw |
||
65 | |||
66 | void CalMk3Mag(void) |
||
67 | { |
||
68 | static unsigned char stick = 1; |
||
69 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
||
70 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
||
71 | { |
||
72 | stick = 1; |
||
73 | WinkelOut.CalcState++; |
||
74 | if(WinkelOut.CalcState > 4) |
||
75 | { |
||
76 | // WinkelOut.CalcState = 0; // in Uart.c |
||
77 | beeptime = 1000; |
||
78 | } |
||
79 | else Piep(WinkelOut.CalcState,150); |
||
80 | } |
||
81 | DebugOut.Analog[19] = WinkelOut.CalcState; |
||
82 | } |
||
83 | |||
84 | |||
85 | void LipoDetection(unsigned char print) |
||
86 | { |
||
87 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
||
88 | unsigned int timer, cells; |
||
89 | if(print) printf("\n\rBatt:"); |
||
90 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
||
91 | { |
||
92 | timer = SetDelay(500); |
||
93 | if(print) while (!CheckDelay(timer)); |
||
94 | // up to 6s LiPo, less than 2s is technical impossible |
||
95 | for(cells = 2; cells < 7; cells++) |
||
96 | { |
||
97 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
||
98 | } |
||
99 | |||
100 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
||
101 | if(print) |
||
102 | { |
||
103 | Piep(cells, 200); |
||
104 | printf(" %d Cells ", cells); |
||
105 | } |
||
106 | } |
||
107 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
||
108 | //if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
||
109 | if(print) printf("Low Batt level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); /// Martinw; removed memorysaving |
||
110 | |||
111 | } |
||
112 | |||
113 | //############################################################################ |
||
114 | //Hauptprogramm |
||
115 | int main (void) |
||
116 | //############################################################################ |
||
117 | { |
||
118 | unsigned int timer,i,timer2 = 0, timerPolling; |
||
119 | |||
120 | DDRB = 0x00; |
||
121 | PORTB = 0x00; |
||
122 | for(timer = 0; timer < 1000; timer++); // verzögern |
||
123 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
||
124 | PlatinenVersion = 21; |
||
125 | #else |
||
126 | if(PINB & 0x01) |
||
127 | { |
||
128 | if(PINB & 0x02) PlatinenVersion = 13; |
||
129 | else PlatinenVersion = 11; |
||
130 | } |
||
131 | else |
||
132 | { |
||
133 | if(PINB & 0x02) PlatinenVersion = 20; |
||
134 | else PlatinenVersion = 10; |
||
135 | } |
||
136 | #endif |
||
137 | DDRC = 0x81; // SCL |
||
138 | DDRC |=0x40; // HEF4017 Reset |
||
139 | PORTC = 0xff; // Pullup SDA |
||
140 | DDRB = 0x1B; // LEDs und Druckoffset |
||
141 | PORTB = 0x01; // LED_Rot |
||
142 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
143 | PORTD = 0x47; // LED |
||
144 | HEF4017R_ON; |
||
145 | MCUSR &=~(1<<WDRF); |
||
146 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
147 | WDTCSR = 0; |
||
148 | |||
149 | beeptime = 2500; |
||
150 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
||
151 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
152 | ROT_OFF; |
||
153 | |||
154 | Timer_Init(); |
||
155 | TIMER2_Init(); |
||
156 | UART_Init(); |
||
157 | rc_sum_init(); |
||
158 | ADC_Init(); |
||
159 | I2C_Init(1); |
||
160 | SPI_MasterInit(); |
||
161 | LIBFC_Init(); |
||
162 | GRN_ON; |
||
163 | sei(); |
||
164 | ParamSet_Init(); |
||
165 | Capacity_Init(); //Moved by metro |
||
166 | |||
167 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
168 | // + Check connected BL-Ctrls |
||
169 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
170 | // Check connected BL-Ctrls |
||
171 | BLFlags |= BLFLAG_READ_VERSION; |
||
172 | motor_read = 0; // read the first I2C-Data |
||
173 | SendMotorData(); |
||
174 | timer = SetDelay(500); |
||
175 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
176 | |||
177 | printf("\n\rFound BL-Ctrl: "); |
||
178 | timer = SetDelay(4000); |
||
179 | for(i=0; i < MAX_MOTORS; i++) |
||
180 | { |
||
181 | SendMotorData(); |
||
182 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
183 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
||
184 | { |
||
185 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
||
186 | { |
||
187 | SendMotorData(); |
||
188 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
189 | } |
||
190 | } |
||
191 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
||
192 | { |
||
193 | printf("%d",i+1); |
||
194 | FoundMotors++; |
||
195 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
||
196 | } |
||
197 | } |
||
198 | for(i=0; i < MAX_MOTORS; i++) |
||
199 | { |
||
200 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
||
201 | { |
||
202 | //printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
||
203 | printf("\n\r\n\r!!MISSING BL-CTRL: %d!!",i+1);/// Martinw; removed memorysaving |
||
204 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
||
205 | } |
||
206 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
||
207 | } |
||
208 | //printf("\n\r===================================");/// Martinw; removed memorysaving |
||
209 | printf("\n\r=");/// Martinw; removed memorysaving |
||
210 | |||
211 | |||
212 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
||
213 | |||
214 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
||
215 | { |
||
216 | //printf("\n\rCalibrating pressure sensor.."); |
||
217 | printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving |
||
218 | timer = SetDelay(1000); |
||
219 | SucheLuftruckOffset(); |
||
220 | while (!CheckDelay(timer)); |
||
221 | printf("OK\n\r"); |
||
222 | } |
||
223 | |||
224 | SetNeutral(0); |
||
225 | |||
226 | ROT_OFF; |
||
227 | |||
228 | beeptime = 2000; |
||
229 | ExternControl.Digital[0] = 0x55; |
||
230 | |||
231 | |||
232 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
||
233 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
234 | |||
235 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
||
236 | { |
||
237 | FlugMinuten = 0; |
||
238 | FlugMinutenGesamt = 0; |
||
239 | } |
||
240 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
||
241 | |||
242 | printf("\n\rControl: "); |
||
243 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
||
244 | else printf("Normal (ACC-Mode)"); |
||
245 | |||
246 | #ifdef WITH_MKTOOL_Display // MartinW; for no MKT Display main.h |
||
247 | #warning : "### with MKTool Display ###" |
||
248 | LcdClear(); |
||
249 | #endif |
||
250 | |||
251 | I2CTimeout = 5000; |
||
252 | WinkelOut.Orientation = 1; |
||
253 | LipoDetection(1); |
||
254 | |||
255 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
||
256 | |||
257 | //printf("\n\r===================================\n\r"); |
||
258 | printf("\n\r=\n\r"); /// Martinw; removed memorysaving |
||
259 | //SpektrumBinding(); |
||
260 | timer = SetDelay(2000); |
||
261 | timerPolling = SetDelay(250); |
||
262 | |||
263 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
||
264 | DebugOut.Status[0] = 0x01 | 0x02; |
||
265 | JetiBeep = 0; |
||
266 | if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING) DisableRcOffBeeping = 1; |
||
267 | |||
268 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) ///MartinW; only for 1284er |
||
269 | //#warning : "### with Sponsored Message ###" |
||
270 | printf("\n\rJETI+ Version sponsored by Flyinghigh.ch, progammed by MartinW\n\r"); |
||
271 | #else |
||
272 | #endif |
||
273 | |||
274 | |||
275 | while (1) |
||
276 | { |
||
277 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
||
278 | |||
279 | |||
280 | //} |
||
281 | if(UpdateMotor && AdReady) // ReglerIntervall |
||
282 | { |
||
283 | //GRN_OFF; |
||
284 | UpdateMotor=0; |
||
285 | if(WinkelOut.CalcState) CalMk3Mag(); |
||
286 | else MotorRegler(); |
||
287 | SendMotorData(); |
||
288 | ROT_OFF; |
||
289 | if(SenderOkay) { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ } |
||
290 | else |
||
291 | { |
||
292 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
293 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
294 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
||
295 | } |
||
296 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
297 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
||
298 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
299 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
300 | if(!--I2CTimeout || MissingMotor) |
||
301 | { |
||
302 | if(!I2CTimeout) |
||
303 | { |
||
304 | I2C_Reset(); |
||
305 | I2CTimeout = 5; |
||
306 | DebugOut.Analog[28]++; // I2C-Error |
||
307 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
||
308 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
||
309 | } |
||
310 | if((BeepMuster == 0xffff) && MotorenEin) |
||
311 | { |
||
312 | beeptime = 25000; |
||
313 | BeepMuster = 0x0080; |
||
314 | } |
||
315 | } |
||
316 | else |
||
317 | { |
||
318 | ROT_OFF; |
||
319 | } |
||
320 | LIBFC_Polling(); |
||
321 | |||
322 | if(!UpdateMotor) |
||
323 | { |
||
324 | if(CalculateServoSignals) CalculateServo(); |
||
325 | DatenUebertragung(); |
||
326 | BearbeiteRxDaten(); |
||
327 | if(CheckDelay(timer)) |
||
328 | { |
||
329 | static unsigned char second; |
||
330 | timer += 20; // 20 ms interval |
||
331 | #if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU)) |
||
332 | #warning : "### with Hottmenu ###" |
||
333 | if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu(); |
||
334 | #endif |
||
335 | if(MissingMotor) |
||
336 | { |
||
337 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
||
338 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
||
339 | } |
||
340 | else |
||
341 | { |
||
342 | if(!beeptime) |
||
343 | { |
||
344 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
||
345 | } |
||
346 | } |
||
347 | if(SenderOkay && DisableRcOffBeeping) { DisableRcOffBeeping = 0; beeptime = 5000;}; |
||
348 | if(PcZugriff) PcZugriff--; |
||
349 | else |
||
350 | { |
||
351 | ExternControl.Config = 0; |
||
352 | ExternStickNick = 0; |
||
353 | ExternStickRoll = 0; |
||
354 | ExternStickGier = 0; |
||
355 | if(!SenderOkay) |
||
356 | { |
||
357 | if(BeepMuster == 0xffff && DisableRcOffBeeping != 2) |
||
358 | { |
||
359 | beeptime = 15000; |
||
360 | BeepMuster = 0x0c00; |
||
361 | if(DisableRcOffBeeping) DisableRcOffBeeping = 2; |
||
362 | } |
||
363 | } |
||
364 | } |
||
365 | if(NaviDataOkay > 200) |
||
366 | { |
||
367 | NaviDataOkay--; |
||
368 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
||
369 | } |
||
370 | else |
||
371 | { |
||
372 | if(NC_Version.Compatible) |
||
373 | { |
||
374 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
||
375 | NC_ErrorCode = 9; // "ERR: no NC communication" |
||
376 | if(BeepMuster == 0xffff && MotorenEin) |
||
377 | { |
||
378 | beeptime = 15000; |
||
379 | BeepMuster = 0xA800; |
||
380 | } |
||
381 | } |
||
382 | GPS_Nick = 0; |
||
383 | GPS_Roll = 0; |
||
384 | GPS_Aid_StickMultiplikator = 0; |
||
385 | GPSInfo.Flags = 0; |
||
386 | FromNaviCtrl.AccErrorN = 0; |
||
387 | FromNaviCtrl.AccErrorR = 0; |
||
388 | FromNaviCtrl.CompassValue = -1; |
||
389 | NaviDataOkay = 0; |
||
390 | } |
||
391 | if(UBat < BattLowVoltageWarning) |
||
392 | { |
||
393 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
||
394 | if(BeepMuster == 0xffff) |
||
395 | { |
||
396 | beeptime = 6000; |
||
397 | BeepMuster = 0x0300; |
||
398 | } |
||
399 | } |
||
400 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
||
401 | |||
402 | SPI_StartTransmitPacket(); |
||
403 | SendSPI = 4; |
||
404 | if(!(FC_StatusFlags & FC_STATUS_FLY)) timer2 = 1450; // 0,5 Minuten aufrunden |
||
405 | else |
||
406 | if(++second == 49) |
||
407 | { |
||
408 | second = 0; |
||
409 | FlugSekunden++; |
||
410 | } |
||
411 | if(++timer2 == 2930) // eine Minute |
||
412 | { |
||
413 | timer2 = 0; |
||
414 | FlugMinuten++; |
||
415 | FlugMinutenGesamt++; |
||
416 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
||
417 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
||
418 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
||
419 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
||
420 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
||
421 | } |
||
422 | } |
||
423 | |||
424 | #ifdef WITH_PANOTRIGGER /// MartinW main.h means no memsave |
||
425 | #warning : "### with Panorama Trigger Function ###" |
||
426 | //// Pano Trigger |
||
427 | if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function |
||
428 | { |
||
429 | if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; } |
||
430 | degreedivold = degreediv; |
||
431 | degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division |
||
432 | |||
433 | if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1) |
||
434 | { |
||
435 | |||
436 | if(panodelay == 0) |
||
437 | { |
||
438 | panotrigger= 1; // muss wieder geleert werden |
||
439 | ROT_ON; |
||
440 | J16_ON; |
||
441 | panodelay = Parameter_UserParam5; |
||
442 | } |
||
443 | } |
||
444 | |||
445 | else |
||
446 | { |
||
447 | if(panodelay <= Parameter_UserParam6) //ms Intervall |
||
448 | { |
||
449 | //panoleddelay = Parameter_UserParam6; |
||
450 | J16_OFF; |
||
451 | ROT_OFF; |
||
452 | } |
||
453 | if(panodelay > 0) |
||
454 | { |
||
455 | panodelay--; |
||
456 | } |
||
457 | |||
458 | } |
||
459 | }// END if(Parameter_UserParam4 >= 1) |
||
460 | //// Pano Trigger |
||
461 | |||
462 | #else |
||
463 | #warning : "### without Panorama Trigger Function ###" |
||
464 | |||
465 | #endif |
||
466 | |||
467 | |||
468 | |||
469 | LED_Update(); |
||
470 | Capacity_Update(); |
||
471 | } //else DebugOut.Analog[26]++; |
||
472 | } |
||
473 | if(!SendSPI) { SPI_TransmitByte(); } |
||
474 | } |
||
475 | return (1); |
||
476 | } |
||
477 | |||
478 |