Rev 2011 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1338 | ingob | 2 | // + Copyright (c) Holger Buss, Ingo Busker |
3 | // + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
||
1 | ingob | 4 | // + www.MikroKopter.com |
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 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. |
||
1 | ingob | 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 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 13 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
1 | ingob | 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 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1338 | ingob | 24 | // + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
1 | ingob | 25 | // + mit unserer Zustimmung zulässig |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
1 | ingob | 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. |
||
1051 | killagreg | 33 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
1 | ingob | 34 | // + for non-commercial use (directly or indirectly) |
1051 | killagreg | 35 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
1 | ingob | 36 | // + with our written permission |
1051 | killagreg | 37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
38 | // + clearly linked as origin |
||
1338 | ingob | 39 | // + * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
1 | ingob | 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 |
||
1051 | killagreg | 50 | // + POSSIBILITY OF SUCH DAMAGE. |
1 | ingob | 51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
52 | #include "main.h" |
||
1913 | holgerb | 53 | unsigned char DisableRcOffBeeping = 0; |
173 | holgerb | 54 | unsigned char PlatinenVersion = 10; |
1232 | hbuss | 55 | unsigned char BattLowVoltageWarning = 94; |
1298 | hbuss | 56 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
1512 | holgerb | 57 | unsigned int FlugSekunden = 0; |
1444 | ingob | 58 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
1702 | holgerb | 59 | unsigned char FoundMotors = 0; |
1834 | holgerb | 60 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
1444 | ingob | 61 | |
819 | hbuss | 62 | void CalMk3Mag(void) |
63 | { |
||
64 | static unsigned char stick = 1; |
||
65 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
||
66 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
||
67 | { |
||
68 | stick = 1; |
||
69 | WinkelOut.CalcState++; |
||
1051 | killagreg | 70 | if(WinkelOut.CalcState > 4) |
71 | { |
||
819 | hbuss | 72 | // WinkelOut.CalcState = 0; // in Uart.c |
73 | beeptime = 1000; |
||
1051 | killagreg | 74 | } |
1232 | hbuss | 75 | else Piep(WinkelOut.CalcState,150); |
819 | hbuss | 76 | } |
77 | DebugOut.Analog[19] = WinkelOut.CalcState; |
||
78 | } |
||
79 | |||
1438 | ingob | 80 | |
1268 | hbuss | 81 | void LipoDetection(unsigned char print) |
82 | { |
||
1654 | killagreg | 83 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
84 | unsigned int timer, cells; |
||
85 | if(print) printf("\n\rBatt:"); |
||
86 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
||
87 | { |
||
88 | timer = SetDelay(500); |
||
89 | if(print) while (!CheckDelay(timer)); |
||
1657 | killagreg | 90 | // up to 6s LiPo, less than 2s is technical impossible |
91 | for(cells = 2; cells < 7; cells++) |
||
1654 | killagreg | 92 | { |
93 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
||
1420 | killagreg | 94 | } |
1654 | killagreg | 95 | |
96 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
||
97 | if(print) |
||
98 | { |
||
99 | Piep(cells, 200); |
||
100 | printf(" %d Cells ", cells); |
||
1420 | killagreg | 101 | } |
1654 | killagreg | 102 | } |
103 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
||
104 | if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
||
1268 | hbuss | 105 | } |
106 | |||
1 | ingob | 107 | //############################################################################ |
108 | //Hauptprogramm |
||
109 | int main (void) |
||
110 | //############################################################################ |
||
111 | { |
||
1424 | ingob | 112 | unsigned int timer,i,timer2 = 0, timerPolling; |
1479 | killagreg | 113 | |
1051 | killagreg | 114 | DDRB = 0x00; |
115 | PORTB = 0x00; |
||
188 | holgerb | 116 | for(timer = 0; timer < 1000; timer++); // verzögern |
1660 | holgerb | 117 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
118 | PlatinenVersion = 21; |
||
119 | #else |
||
120 | if(PINB & 0x01) |
||
918 | hbuss | 121 | { |
1051 | killagreg | 122 | if(PINB & 0x02) PlatinenVersion = 13; |
123 | else PlatinenVersion = 11; |
||
918 | hbuss | 124 | } |
1051 | killagreg | 125 | else |
1021 | hbuss | 126 | { |
1051 | killagreg | 127 | if(PINB & 0x02) PlatinenVersion = 20; |
128 | else PlatinenVersion = 10; |
||
1021 | hbuss | 129 | } |
1660 | holgerb | 130 | #endif |
173 | holgerb | 131 | DDRC = 0x81; // SCL |
1036 | hbuss | 132 | DDRC |=0x40; // HEF4017 Reset |
1 | ingob | 133 | PORTC = 0xff; // Pullup SDA |
134 | DDRB = 0x1B; // LEDs und Druckoffset |
||
135 | PORTB = 0x01; // LED_Rot |
||
136 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
1153 | hbuss | 137 | PORTD = 0x47; // LED |
1171 | hbuss | 138 | HEF4017R_ON; |
1 | ingob | 139 | MCUSR &=~(1<<WDRF); |
140 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
141 | WDTCSR = 0; |
||
142 | |||
1652 | holgerb | 143 | beeptime = 2500; |
1660 | holgerb | 144 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
145 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
1 | ingob | 146 | ROT_OFF; |
1479 | killagreg | 147 | |
1 | ingob | 148 | Timer_Init(); |
1156 | hbuss | 149 | TIMER2_Init(); |
1 | ingob | 150 | UART_Init(); |
151 | rc_sum_init(); |
||
152 | ADC_Init(); |
||
1743 | holgerb | 153 | I2C_Init(1); |
597 | ingob | 154 | SPI_MasterInit(); |
1486 | killagreg | 155 | Capacity_Init(); |
1435 | killagreg | 156 | LIBFC_Init(); |
1431 | ingob | 157 | GRN_ON; |
158 | sei(); |
||
1622 | killagreg | 159 | ParamSet_Init(); |
1344 | hbuss | 160 | |
1435 | killagreg | 161 | |
1211 | hbuss | 162 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
163 | // + Check connected BL-Ctrls |
||
164 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1648 | killagreg | 165 | // Check connected BL-Ctrls |
166 | BLFlags |= BLFLAG_READ_VERSION; |
||
1662 | killagreg | 167 | motor_read = 0; // read the first I2C-Data |
1648 | killagreg | 168 | SendMotorData(); |
1683 | killagreg | 169 | timer = SetDelay(500); |
170 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
1654 | killagreg | 171 | |
1648 | killagreg | 172 | printf("\n\rFound BL-Ctrl: "); |
1591 | holgerb | 173 | timer = SetDelay(4000); |
1211 | hbuss | 174 | for(i=0; i < MAX_MOTORS; i++) |
1622 | killagreg | 175 | { |
176 | SendMotorData(); |
||
1683 | killagreg | 177 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1622 | killagreg | 178 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
179 | { |
||
1648 | killagreg | 180 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
181 | { |
||
182 | SendMotorData(); |
||
1683 | killagreg | 183 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1648 | killagreg | 184 | } |
1232 | hbuss | 185 | } |
1648 | killagreg | 186 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
187 | { |
||
188 | printf("%d",i+1); |
||
1702 | holgerb | 189 | FoundMotors++; |
1652 | holgerb | 190 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
1648 | killagreg | 191 | } |
1622 | killagreg | 192 | } |
1211 | hbuss | 193 | for(i=0; i < MAX_MOTORS; i++) |
1051 | killagreg | 194 | { |
1622 | killagreg | 195 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
196 | { |
||
197 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
||
1701 | holgerb | 198 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
1111 | hbuss | 199 | } |
1622 | killagreg | 200 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
1 | ingob | 201 | } |
1622 | killagreg | 202 | printf("\n\r==================================="); |
1648 | killagreg | 203 | |
1765 | killagreg | 204 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
1702 | holgerb | 205 | |
1529 | killagreg | 206 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
1622 | killagreg | 207 | { |
208 | printf("\n\rCalibrating pressure sensor.."); |
||
209 | timer = SetDelay(1000); |
||
210 | SucheLuftruckOffset(); |
||
211 | while (!CheckDelay(timer)); |
||
212 | printf("OK\n\r"); |
||
1 | ingob | 213 | } |
1051 | killagreg | 214 | |
1622 | killagreg | 215 | SetNeutral(0); |
1 | ingob | 216 | |
217 | ROT_OFF; |
||
1051 | killagreg | 218 | |
1 | ingob | 219 | beeptime = 2000; |
1051 | killagreg | 220 | ExternControl.Digital[0] = 0x55; |
1 | ingob | 221 | |
1051 | killagreg | 222 | |
1652 | holgerb | 223 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
224 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
1622 | killagreg | 225 | |
1702 | holgerb | 226 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
1622 | killagreg | 227 | { |
228 | FlugMinuten = 0; |
||
229 | FlugMinutenGesamt = 0; |
||
230 | } |
||
231 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
||
232 | |||
1211 | hbuss | 233 | printf("\n\rControl: "); |
1 | ingob | 234 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
1211 | hbuss | 235 | else printf("Normal (ACC-Mode)"); |
1051 | killagreg | 236 | |
1 | ingob | 237 | LcdClear(); |
173 | holgerb | 238 | I2CTimeout = 5000; |
819 | hbuss | 239 | WinkelOut.Orientation = 1; |
1268 | hbuss | 240 | LipoDetection(1); |
1435 | killagreg | 241 | |
1626 | killagreg | 242 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
1444 | ingob | 243 | |
1232 | hbuss | 244 | printf("\n\r===================================\n\r"); |
1622 | killagreg | 245 | //SpektrumBinding(); |
1350 | hbuss | 246 | timer = SetDelay(2000); |
1424 | ingob | 247 | timerPolling = SetDelay(250); |
1648 | killagreg | 248 | |
1636 | ingob | 249 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
1702 | holgerb | 250 | DebugOut.Status[0] = 0x01 | 0x02; |
1834 | holgerb | 251 | JetiBeep = 0; |
1913 | holgerb | 252 | if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING) DisableRcOffBeeping = 1; |
1 | ingob | 253 | while (1) |
254 | { |
||
1945 | holgerb | 255 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
1907 | ingob | 256 | |
1930 | holgerb | 257 | //GRN_ON; |
1419 | ingob | 258 | if(UpdateMotor && AdReady) // ReglerIntervall |
1051 | killagreg | 259 | { |
1930 | holgerb | 260 | //GRN_OFF; |
1907 | ingob | 261 | UpdateMotor=0; |
819 | hbuss | 262 | if(WinkelOut.CalcState) CalMk3Mag(); |
1644 | holgerb | 263 | else MotorRegler(); |
264 | SendMotorData(); |
||
1 | ingob | 265 | ROT_OFF; |
1937 | holgerb | 266 | if(SenderOkay) { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ } |
1603 | killagreg | 267 | else |
268 | { |
||
269 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
270 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
1765 | killagreg | 271 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
1603 | killagreg | 272 | } |
1420 | killagreg | 273 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | holgerb | 274 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
275 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
1309 | hbuss | 276 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1210 | hbuss | 277 | if(!--I2CTimeout || MissingMotor) |
173 | holgerb | 278 | { |
1254 | killagreg | 279 | if(!I2CTimeout) |
1210 | hbuss | 280 | { |
1662 | killagreg | 281 | I2C_Reset(); |
1210 | hbuss | 282 | I2CTimeout = 5; |
1322 | hbuss | 283 | DebugOut.Analog[28]++; // I2C-Error |
1765 | killagreg | 284 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
1702 | holgerb | 285 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1322 | hbuss | 286 | } |
1051 | killagreg | 287 | if((BeepMuster == 0xffff) && MotorenEin) |
288 | { |
||
1936 | holgerb | 289 | beeptime = 25000; |
173 | holgerb | 290 | BeepMuster = 0x0080; |
1051 | killagreg | 291 | } |
1 | ingob | 292 | } |
1051 | killagreg | 293 | else |
1 | ingob | 294 | { |
1051 | killagreg | 295 | ROT_OFF; |
1944 | holgerb | 296 | } |
1916 | holgerb | 297 | LIBFC_Polling(); |
298 | |||
1639 | holgerb | 299 | if(!UpdateMotor) |
2012 | holgerb | 300 | { |
301 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
||
302 | if(NewSBusData) ProcessSBus(); |
||
303 | else |
||
304 | #endif |
||
1639 | holgerb | 305 | { |
1760 | holgerb | 306 | if(CalculateServoSignals) CalculateServo(); |
307 | DatenUebertragung(); |
||
308 | BearbeiteRxDaten(); |
||
1254 | killagreg | 309 | if(CheckDelay(timer)) |
310 | { |
||
1512 | holgerb | 311 | static unsigned char second; |
1420 | killagreg | 312 | timer += 20; // 20 ms interval |
1925 | holgerb | 313 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
1917 | holgerb | 314 | if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu(); |
1925 | holgerb | 315 | #endif |
1702 | holgerb | 316 | if(MissingMotor) |
317 | { |
||
1765 | killagreg | 318 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
1702 | holgerb | 319 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1765 | killagreg | 320 | } |
321 | else |
||
1702 | holgerb | 322 | { |
1936 | holgerb | 323 | if(!beeptime) |
324 | { |
||
325 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
||
326 | } |
||
1765 | killagreg | 327 | } |
1915 | holgerb | 328 | if(SenderOkay && DisableRcOffBeeping) { DisableRcOffBeeping = 0; beeptime = 5000;}; |
1420 | killagreg | 329 | if(PcZugriff) PcZugriff--; |
330 | else |
||
331 | { |
||
332 | ExternControl.Config = 0; |
||
333 | ExternStickNick = 0; |
||
334 | ExternStickRoll = 0; |
||
335 | ExternStickGier = 0; |
||
1913 | holgerb | 336 | if(!SenderOkay) |
1420 | killagreg | 337 | { |
1914 | holgerb | 338 | if(BeepMuster == 0xffff && DisableRcOffBeeping != 2) |
1913 | holgerb | 339 | { |
340 | beeptime = 15000; |
||
341 | BeepMuster = 0x0c00; |
||
1914 | holgerb | 342 | if(DisableRcOffBeeping) DisableRcOffBeeping = 2; |
1913 | holgerb | 343 | } |
1914 | holgerb | 344 | } |
1420 | killagreg | 345 | } |
1682 | holgerb | 346 | if(NaviDataOkay > 200) |
1420 | killagreg | 347 | { |
348 | NaviDataOkay--; |
||
1765 | killagreg | 349 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
1420 | killagreg | 350 | } |
351 | else |
||
352 | { |
||
1702 | holgerb | 353 | if(NC_Version.Compatible) |
354 | { |
||
1930 | holgerb | 355 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
356 | NC_ErrorCode = 9; // "ERR: no NC communication" |
||
1702 | holgerb | 357 | if(BeepMuster == 0xffff && MotorenEin) |
358 | { |
||
359 | beeptime = 15000; |
||
360 | BeepMuster = 0xA800; |
||
361 | } |
||
1765 | killagreg | 362 | } |
1420 | killagreg | 363 | GPS_Nick = 0; |
364 | GPS_Roll = 0; |
||
1945 | holgerb | 365 | GPS_Aid_StickMultiplikator = 0; |
1916 | holgerb | 366 | GPSInfo.Flags = 0; |
1936 | holgerb | 367 | FromNaviCtrl.AccErrorN = 0; |
368 | FromNaviCtrl.AccErrorR = 0; |
||
1691 | holgerb | 369 | FromNaviCtrl.CompassValue = -1; |
1703 | holgerb | 370 | NaviDataOkay = 0; |
1420 | killagreg | 371 | } |
1309 | hbuss | 372 | if(UBat < BattLowVoltageWarning) |
1254 | killagreg | 373 | { |
1765 | killagreg | 374 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
1254 | killagreg | 375 | if(BeepMuster == 0xffff) |
376 | { |
||
377 | beeptime = 6000; |
||
378 | BeepMuster = 0x0300; |
||
379 | } |
||
380 | } |
||
1765 | killagreg | 381 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
1420 | killagreg | 382 | |
1254 | killagreg | 383 | SPI_StartTransmitPacket(); |
384 | SendSPI = 4; |
||
2009 | holgerb | 385 | // +++++++++++++++++++++++++++++++++ |
386 | // Sekundentakt |
||
1512 | holgerb | 387 | if(++second == 49) |
388 | { |
||
389 | second = 0; |
||
2009 | holgerb | 390 | if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++; |
391 | else |
||
392 | { |
||
393 | timer2 = 1450; // 0,5 Minuten aufrunden |
||
394 | if(StartLuftdruck < Luftdruck) StartLuftdruck++; |
||
395 | else |
||
396 | if(StartLuftdruck > Luftdruck) StartLuftdruck--; |
||
397 | } |
||
1512 | holgerb | 398 | } |
2009 | holgerb | 399 | // +++++++++++++++++++++++++++++++++ |
1320 | hbuss | 400 | if(++timer2 == 2930) // eine Minute |
1298 | hbuss | 401 | { |
402 | timer2 = 0; |
||
403 | FlugMinuten++; |
||
404 | FlugMinutenGesamt++; |
||
1652 | holgerb | 405 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
406 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
||
407 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
||
408 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
||
1344 | hbuss | 409 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
1298 | hbuss | 410 | } |
1254 | killagreg | 411 | } |
921 | hbuss | 412 | LED_Update(); |
1486 | killagreg | 413 | Capacity_Update(); |
1936 | holgerb | 414 | } //else DebugOut.Analog[26]++; |
604 | hbuss | 415 | } |
2012 | holgerb | 416 | } |
417 | if(!SendSPI) { SPI_TransmitByte(); } |
||
1 | ingob | 418 | } |
419 | return (1); |
||
420 | } |
||
1944 | holgerb | 421 | //DebugOut.Analog[16] |
1 | ingob | 422 |