Rev 2191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + www.MikroKopter.com |
||
3 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
2050 | holgerb | 4 | // + Software Nutzungsbedingungen (english version: see below) |
5 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
||
6 | // + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
||
7 | // + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
||
8 | // + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
||
9 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
||
1 | ingob | 10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2050 | holgerb | 11 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
12 | // + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
||
13 | // + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
||
14 | // + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
||
15 | // + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
||
16 | // + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
||
17 | // + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
||
18 | // + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
||
19 | // + des Mitverschuldens offen. |
||
20 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
||
21 | // + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
||
22 | // + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
||
23 | // + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
||
24 | // + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
||
25 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
||
26 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
||
27 | // + 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. |
||
1 | ingob | 28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2050 | holgerb | 29 | // + Software LICENSING TERMS |
1 | ingob | 30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2050 | holgerb | 31 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
32 | // + 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 |
||
33 | // + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
||
34 | // + The Software may only be used with the Licensor's products. |
||
35 | // + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
||
36 | // + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
||
37 | // + agreement shall be the property of the Licensor. |
||
38 | // + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
||
39 | // + features that can be used to identify the program may not be altered or defaced by the customer. |
||
40 | // + The customer shall be responsible for taking reasonable precautions |
||
41 | // + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
||
42 | // + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
||
43 | // + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
||
44 | // + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
||
45 | // + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
||
46 | // + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
||
47 | // + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
||
48 | // + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
||
49 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
||
50 | // + #### END OF LICENSING TERMS #### |
||
51 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
||
1 | ingob | 52 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
53 | #include "main.h" |
||
1913 | holgerb | 54 | unsigned char DisableRcOffBeeping = 0; |
173 | holgerb | 55 | unsigned char PlatinenVersion = 10; |
1232 | hbuss | 56 | unsigned char BattLowVoltageWarning = 94; |
1298 | hbuss | 57 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
1512 | holgerb | 58 | unsigned int FlugSekunden = 0; |
1444 | ingob | 59 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
1702 | holgerb | 60 | unsigned char FoundMotors = 0; |
1834 | holgerb | 61 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
1444 | ingob | 62 | |
2030 | holgerb | 63 | void PrintLine(void) |
64 | { |
||
65 | printf("\n\r==================================="); |
||
66 | } |
||
67 | |||
68 | |||
819 | hbuss | 69 | void CalMk3Mag(void) |
70 | { |
||
71 | static unsigned char stick = 1; |
||
72 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
||
73 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
||
74 | { |
||
75 | stick = 1; |
||
76 | WinkelOut.CalcState++; |
||
1051 | killagreg | 77 | if(WinkelOut.CalcState > 4) |
78 | { |
||
819 | hbuss | 79 | // WinkelOut.CalcState = 0; // in Uart.c |
80 | beeptime = 1000; |
||
1051 | killagreg | 81 | } |
1232 | hbuss | 82 | else Piep(WinkelOut.CalcState,150); |
819 | hbuss | 83 | } |
84 | DebugOut.Analog[19] = WinkelOut.CalcState; |
||
85 | } |
||
86 | |||
1438 | ingob | 87 | |
1268 | hbuss | 88 | void LipoDetection(unsigned char print) |
89 | { |
||
1654 | killagreg | 90 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
91 | unsigned int timer, cells; |
||
92 | if(print) printf("\n\rBatt:"); |
||
93 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
||
94 | { |
||
95 | timer = SetDelay(500); |
||
96 | if(print) while (!CheckDelay(timer)); |
||
1657 | killagreg | 97 | // up to 6s LiPo, less than 2s is technical impossible |
98 | for(cells = 2; cells < 7; cells++) |
||
1654 | killagreg | 99 | { |
100 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
||
1420 | killagreg | 101 | } |
1654 | killagreg | 102 | |
103 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
||
104 | if(print) |
||
105 | { |
||
106 | Piep(cells, 200); |
||
107 | printf(" %d Cells ", cells); |
||
1420 | killagreg | 108 | } |
1654 | killagreg | 109 | } |
110 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
||
2034 | holgerb | 111 | if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
1268 | hbuss | 112 | } |
113 | |||
1 | ingob | 114 | //############################################################################ |
115 | //Hauptprogramm |
||
116 | int main (void) |
||
117 | //############################################################################ |
||
118 | { |
||
1424 | ingob | 119 | unsigned int timer,i,timer2 = 0, timerPolling; |
1479 | killagreg | 120 | |
1051 | killagreg | 121 | DDRB = 0x00; |
122 | PORTB = 0x00; |
||
188 | holgerb | 123 | for(timer = 0; timer < 1000; timer++); // verzögern |
1660 | holgerb | 124 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
2183 | holgerb | 125 | |
126 | if(PINB & 0x02) PlatinenVersion = 21; |
||
127 | else |
||
128 | { |
||
129 | PlatinenVersion = 22; |
||
2191 | holgerb | 130 | // ACC_AMPLIFY = 7; // der ACC-Sensor hat etwa 16% weniger Ausschlag |
2183 | holgerb | 131 | } |
132 | |||
1660 | holgerb | 133 | #else |
134 | if(PINB & 0x01) |
||
918 | hbuss | 135 | { |
1051 | killagreg | 136 | if(PINB & 0x02) PlatinenVersion = 13; |
137 | else PlatinenVersion = 11; |
||
918 | hbuss | 138 | } |
1051 | killagreg | 139 | else |
1021 | hbuss | 140 | { |
1051 | killagreg | 141 | if(PINB & 0x02) PlatinenVersion = 20; |
142 | else PlatinenVersion = 10; |
||
1021 | hbuss | 143 | } |
1660 | holgerb | 144 | #endif |
173 | holgerb | 145 | DDRC = 0x81; // SCL |
1036 | hbuss | 146 | DDRC |=0x40; // HEF4017 Reset |
1 | ingob | 147 | PORTC = 0xff; // Pullup SDA |
148 | DDRB = 0x1B; // LEDs und Druckoffset |
||
149 | PORTB = 0x01; // LED_Rot |
||
150 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
1153 | hbuss | 151 | PORTD = 0x47; // LED |
2146 | holgerb | 152 | HEF4017Reset_ON; |
1 | ingob | 153 | MCUSR &=~(1<<WDRF); |
154 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
155 | WDTCSR = 0; |
||
156 | |||
1652 | holgerb | 157 | beeptime = 2500; |
1660 | holgerb | 158 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
159 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
1 | ingob | 160 | ROT_OFF; |
2193 | holgerb | 161 | GRN_ON; |
1479 | killagreg | 162 | |
1 | ingob | 163 | Timer_Init(); |
1156 | hbuss | 164 | TIMER2_Init(); |
1 | ingob | 165 | UART_Init(); |
166 | rc_sum_init(); |
||
167 | ADC_Init(); |
||
1743 | holgerb | 168 | I2C_Init(1); |
597 | ingob | 169 | SPI_MasterInit(); |
1486 | killagreg | 170 | Capacity_Init(); |
1435 | killagreg | 171 | LIBFC_Init(); |
1431 | ingob | 172 | GRN_ON; |
173 | sei(); |
||
1622 | killagreg | 174 | ParamSet_Init(); |
1344 | hbuss | 175 | |
1435 | killagreg | 176 | |
1211 | hbuss | 177 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
178 | // + Check connected BL-Ctrls |
||
179 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1648 | killagreg | 180 | // Check connected BL-Ctrls |
181 | BLFlags |= BLFLAG_READ_VERSION; |
||
1662 | killagreg | 182 | motor_read = 0; // read the first I2C-Data |
1648 | killagreg | 183 | SendMotorData(); |
1683 | killagreg | 184 | timer = SetDelay(500); |
185 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
1654 | killagreg | 186 | |
1648 | killagreg | 187 | printf("\n\rFound BL-Ctrl: "); |
1591 | holgerb | 188 | timer = SetDelay(4000); |
1211 | hbuss | 189 | for(i=0; i < MAX_MOTORS; i++) |
1622 | killagreg | 190 | { |
191 | SendMotorData(); |
||
1683 | killagreg | 192 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1622 | killagreg | 193 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
194 | { |
||
1648 | killagreg | 195 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
196 | { |
||
197 | SendMotorData(); |
||
1683 | killagreg | 198 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1648 | killagreg | 199 | } |
1232 | hbuss | 200 | } |
1648 | killagreg | 201 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
202 | { |
||
203 | printf("%d",i+1); |
||
1702 | holgerb | 204 | FoundMotors++; |
1652 | holgerb | 205 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
1648 | killagreg | 206 | } |
1622 | killagreg | 207 | } |
1211 | hbuss | 208 | for(i=0; i < MAX_MOTORS; i++) |
1051 | killagreg | 209 | { |
1622 | killagreg | 210 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
211 | { |
||
212 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
||
1701 | holgerb | 213 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
1111 | hbuss | 214 | } |
1622 | killagreg | 215 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
1 | ingob | 216 | } |
2030 | holgerb | 217 | PrintLine();// ("\n\r==================================="); |
1648 | killagreg | 218 | |
2030 | holgerb | 219 | |
1765 | killagreg | 220 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
1702 | holgerb | 221 | |
1529 | killagreg | 222 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
1622 | killagreg | 223 | { |
224 | printf("\n\rCalibrating pressure sensor.."); |
||
225 | timer = SetDelay(1000); |
||
226 | SucheLuftruckOffset(); |
||
227 | while (!CheckDelay(timer)); |
||
228 | printf("OK\n\r"); |
||
1 | ingob | 229 | } |
1051 | killagreg | 230 | |
1622 | killagreg | 231 | SetNeutral(0); |
1 | ingob | 232 | |
233 | ROT_OFF; |
||
1051 | killagreg | 234 | |
1 | ingob | 235 | beeptime = 2000; |
1051 | killagreg | 236 | ExternControl.Digital[0] = 0x55; |
1 | ingob | 237 | |
1051 | killagreg | 238 | |
1652 | holgerb | 239 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
240 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
1622 | killagreg | 241 | |
1702 | holgerb | 242 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
1622 | killagreg | 243 | { |
244 | FlugMinuten = 0; |
||
245 | FlugMinutenGesamt = 0; |
||
246 | } |
||
2034 | holgerb | 247 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
1622 | killagreg | 248 | |
1 | ingob | 249 | LcdClear(); |
173 | holgerb | 250 | I2CTimeout = 5000; |
819 | hbuss | 251 | WinkelOut.Orientation = 1; |
1268 | hbuss | 252 | LipoDetection(1); |
1626 | killagreg | 253 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
2030 | holgerb | 254 | PrintLine();// ("\n\r==================================="); |
1622 | killagreg | 255 | //SpektrumBinding(); |
1350 | hbuss | 256 | timer = SetDelay(2000); |
1424 | ingob | 257 | timerPolling = SetDelay(250); |
1648 | killagreg | 258 | |
1636 | ingob | 259 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
1702 | holgerb | 260 | DebugOut.Status[0] = 0x01 | 0x02; |
1834 | holgerb | 261 | JetiBeep = 0; |
1913 | holgerb | 262 | if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING) DisableRcOffBeeping = 1; |
1 | ingob | 263 | while (1) |
264 | { |
||
1945 | holgerb | 265 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
1907 | ingob | 266 | |
1930 | holgerb | 267 | //GRN_ON; |
1419 | ingob | 268 | if(UpdateMotor && AdReady) // ReglerIntervall |
1051 | killagreg | 269 | { |
1930 | holgerb | 270 | //GRN_OFF; |
1907 | ingob | 271 | UpdateMotor=0; |
819 | hbuss | 272 | if(WinkelOut.CalcState) CalMk3Mag(); |
1644 | holgerb | 273 | else MotorRegler(); |
274 | SendMotorData(); |
||
1 | ingob | 275 | ROT_OFF; |
1937 | holgerb | 276 | if(SenderOkay) { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ } |
1603 | killagreg | 277 | else |
278 | { |
||
279 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
280 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
1765 | killagreg | 281 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
1603 | killagreg | 282 | } |
1420 | killagreg | 283 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | holgerb | 284 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
285 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
1309 | hbuss | 286 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1210 | hbuss | 287 | if(!--I2CTimeout || MissingMotor) |
173 | holgerb | 288 | { |
1254 | killagreg | 289 | if(!I2CTimeout) |
1210 | hbuss | 290 | { |
1662 | killagreg | 291 | I2C_Reset(); |
1210 | hbuss | 292 | I2CTimeout = 5; |
1322 | hbuss | 293 | DebugOut.Analog[28]++; // I2C-Error |
1765 | killagreg | 294 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
1702 | holgerb | 295 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1322 | hbuss | 296 | } |
1051 | killagreg | 297 | if((BeepMuster == 0xffff) && MotorenEin) |
298 | { |
||
1936 | holgerb | 299 | beeptime = 25000; |
173 | holgerb | 300 | BeepMuster = 0x0080; |
1051 | killagreg | 301 | } |
1 | ingob | 302 | } |
1051 | killagreg | 303 | else |
1 | ingob | 304 | { |
1051 | killagreg | 305 | ROT_OFF; |
1944 | holgerb | 306 | } |
1916 | holgerb | 307 | LIBFC_Polling(); |
308 | |||
1639 | holgerb | 309 | if(!UpdateMotor) |
2012 | holgerb | 310 | { |
311 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
||
312 | if(NewSBusData) ProcessSBus(); |
||
313 | else |
||
314 | #endif |
||
1639 | holgerb | 315 | { |
1760 | holgerb | 316 | if(CalculateServoSignals) CalculateServo(); |
317 | DatenUebertragung(); |
||
318 | BearbeiteRxDaten(); |
||
1254 | killagreg | 319 | if(CheckDelay(timer)) |
320 | { |
||
1512 | holgerb | 321 | static unsigned char second; |
1420 | killagreg | 322 | timer += 20; // 20 ms interval |
2191 | holgerb | 323 | CalcNickServoValue(); |
1925 | holgerb | 324 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
1917 | holgerb | 325 | if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu(); |
1925 | holgerb | 326 | #endif |
1702 | holgerb | 327 | if(MissingMotor) |
328 | { |
||
1765 | killagreg | 329 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
1702 | holgerb | 330 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1765 | killagreg | 331 | } |
332 | else |
||
1702 | holgerb | 333 | { |
1936 | holgerb | 334 | if(!beeptime) |
335 | { |
||
336 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
||
337 | } |
||
1765 | killagreg | 338 | } |
2029 | holgerb | 339 | if(DisableRcOffBeeping) if(SenderOkay > 150) { DisableRcOffBeeping = 0; beeptime = 5000;}; |
1420 | killagreg | 340 | if(PcZugriff) PcZugriff--; |
341 | else |
||
342 | { |
||
343 | ExternControl.Config = 0; |
||
344 | ExternStickNick = 0; |
||
345 | ExternStickRoll = 0; |
||
346 | ExternStickGier = 0; |
||
1913 | holgerb | 347 | if(!SenderOkay) |
1420 | killagreg | 348 | { |
1914 | holgerb | 349 | if(BeepMuster == 0xffff && DisableRcOffBeeping != 2) |
1913 | holgerb | 350 | { |
351 | beeptime = 15000; |
||
352 | BeepMuster = 0x0c00; |
||
1914 | holgerb | 353 | if(DisableRcOffBeeping) DisableRcOffBeeping = 2; |
1913 | holgerb | 354 | } |
1914 | holgerb | 355 | } |
1420 | killagreg | 356 | } |
1682 | holgerb | 357 | if(NaviDataOkay > 200) |
1420 | killagreg | 358 | { |
359 | NaviDataOkay--; |
||
1765 | killagreg | 360 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
1420 | killagreg | 361 | } |
362 | else |
||
363 | { |
||
1702 | holgerb | 364 | if(NC_Version.Compatible) |
365 | { |
||
1930 | holgerb | 366 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
367 | NC_ErrorCode = 9; // "ERR: no NC communication" |
||
1702 | holgerb | 368 | if(BeepMuster == 0xffff && MotorenEin) |
369 | { |
||
370 | beeptime = 15000; |
||
371 | BeepMuster = 0xA800; |
||
372 | } |
||
1765 | killagreg | 373 | } |
1420 | killagreg | 374 | GPS_Nick = 0; |
375 | GPS_Roll = 0; |
||
1945 | holgerb | 376 | GPS_Aid_StickMultiplikator = 0; |
1916 | holgerb | 377 | GPSInfo.Flags = 0; |
1936 | holgerb | 378 | FromNaviCtrl.AccErrorN = 0; |
379 | FromNaviCtrl.AccErrorR = 0; |
||
1691 | holgerb | 380 | FromNaviCtrl.CompassValue = -1; |
1703 | holgerb | 381 | NaviDataOkay = 0; |
1420 | killagreg | 382 | } |
1309 | hbuss | 383 | if(UBat < BattLowVoltageWarning) |
1254 | killagreg | 384 | { |
1765 | killagreg | 385 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
1254 | killagreg | 386 | if(BeepMuster == 0xffff) |
387 | { |
||
388 | beeptime = 6000; |
||
389 | BeepMuster = 0x0300; |
||
390 | } |
||
391 | } |
||
1765 | killagreg | 392 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
1420 | killagreg | 393 | |
1254 | killagreg | 394 | SPI_StartTransmitPacket(); |
395 | SendSPI = 4; |
||
2009 | holgerb | 396 | // +++++++++++++++++++++++++++++++++ |
397 | // Sekundentakt |
||
1512 | holgerb | 398 | if(++second == 49) |
399 | { |
||
400 | second = 0; |
||
2009 | holgerb | 401 | if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++; |
402 | else |
||
403 | { |
||
404 | timer2 = 1450; // 0,5 Minuten aufrunden |
||
405 | if(StartLuftdruck < Luftdruck) StartLuftdruck++; |
||
406 | else |
||
407 | if(StartLuftdruck > Luftdruck) StartLuftdruck--; |
||
408 | } |
||
1512 | holgerb | 409 | } |
2009 | holgerb | 410 | // +++++++++++++++++++++++++++++++++ |
1320 | hbuss | 411 | if(++timer2 == 2930) // eine Minute |
1298 | hbuss | 412 | { |
413 | timer2 = 0; |
||
414 | FlugMinuten++; |
||
415 | FlugMinutenGesamt++; |
||
1652 | holgerb | 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); |
||
1344 | hbuss | 420 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
1298 | hbuss | 421 | } |
1254 | killagreg | 422 | } |
921 | hbuss | 423 | LED_Update(); |
1486 | killagreg | 424 | Capacity_Update(); |
1936 | holgerb | 425 | } //else DebugOut.Analog[26]++; |
604 | hbuss | 426 | } |
2012 | holgerb | 427 | } |
428 | if(!SendSPI) { SPI_TransmitByte(); } |
||
1 | ingob | 429 | } |
430 | return (1); |
||
431 | } |
||
1944 | holgerb | 432 | //DebugOut.Analog[16] |
1 | ingob | 433 |