Go to most recent revision | Details | 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" |
||
53 | |||
1438 | ingob | 54 | |
173 | holgerb | 55 | unsigned char PlatinenVersion = 10; |
723 | hbuss | 56 | unsigned char SendVersionToNavi = 1; |
1232 | hbuss | 57 | unsigned char BattLowVoltageWarning = 94; |
1298 | hbuss | 58 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
1512 | holgerb | 59 | unsigned int FlugSekunden = 0; |
1444 | ingob | 60 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
1702 | holgerb | 61 | unsigned char FoundMotors = 0; |
1834 | holgerb | 62 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
1444 | ingob | 63 | |
819 | hbuss | 64 | void CalMk3Mag(void) |
65 | { |
||
66 | static unsigned char stick = 1; |
||
67 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
||
68 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
||
69 | { |
||
70 | stick = 1; |
||
71 | WinkelOut.CalcState++; |
||
1051 | killagreg | 72 | if(WinkelOut.CalcState > 4) |
73 | { |
||
819 | hbuss | 74 | // WinkelOut.CalcState = 0; // in Uart.c |
75 | beeptime = 1000; |
||
1051 | killagreg | 76 | } |
1232 | hbuss | 77 | else Piep(WinkelOut.CalcState,150); |
819 | hbuss | 78 | } |
79 | DebugOut.Analog[19] = WinkelOut.CalcState; |
||
80 | } |
||
81 | |||
1438 | ingob | 82 | |
1268 | hbuss | 83 | void LipoDetection(unsigned char print) |
84 | { |
||
1654 | killagreg | 85 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
86 | unsigned int timer, cells; |
||
87 | if(print) printf("\n\rBatt:"); |
||
88 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
||
89 | { |
||
90 | timer = SetDelay(500); |
||
91 | if(print) while (!CheckDelay(timer)); |
||
1657 | killagreg | 92 | // up to 6s LiPo, less than 2s is technical impossible |
93 | for(cells = 2; cells < 7; cells++) |
||
1654 | killagreg | 94 | { |
95 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
||
1420 | killagreg | 96 | } |
1654 | killagreg | 97 | |
98 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
||
99 | if(print) |
||
100 | { |
||
101 | Piep(cells, 200); |
||
102 | printf(" %d Cells ", cells); |
||
1420 | killagreg | 103 | } |
1654 | killagreg | 104 | } |
105 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
||
106 | if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
||
1268 | hbuss | 107 | } |
108 | |||
1 | ingob | 109 | //############################################################################ |
110 | //Hauptprogramm |
||
111 | int main (void) |
||
112 | //############################################################################ |
||
113 | { |
||
1424 | ingob | 114 | unsigned int timer,i,timer2 = 0, timerPolling; |
1479 | killagreg | 115 | |
1051 | killagreg | 116 | DDRB = 0x00; |
117 | PORTB = 0x00; |
||
188 | holgerb | 118 | for(timer = 0; timer < 1000; timer++); // verzögern |
1660 | holgerb | 119 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
120 | PlatinenVersion = 21; |
||
121 | #else |
||
122 | if(PINB & 0x01) |
||
918 | hbuss | 123 | { |
1051 | killagreg | 124 | if(PINB & 0x02) PlatinenVersion = 13; |
125 | else PlatinenVersion = 11; |
||
918 | hbuss | 126 | } |
1051 | killagreg | 127 | else |
1021 | hbuss | 128 | { |
1051 | killagreg | 129 | if(PINB & 0x02) PlatinenVersion = 20; |
130 | else PlatinenVersion = 10; |
||
1021 | hbuss | 131 | } |
1660 | holgerb | 132 | #endif |
173 | holgerb | 133 | DDRC = 0x81; // SCL |
1036 | hbuss | 134 | DDRC |=0x40; // HEF4017 Reset |
1 | ingob | 135 | PORTC = 0xff; // Pullup SDA |
136 | DDRB = 0x1B; // LEDs und Druckoffset |
||
137 | PORTB = 0x01; // LED_Rot |
||
138 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
1153 | hbuss | 139 | PORTD = 0x47; // LED |
1171 | hbuss | 140 | HEF4017R_ON; |
1 | ingob | 141 | MCUSR &=~(1<<WDRF); |
142 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
143 | WDTCSR = 0; |
||
144 | |||
1652 | holgerb | 145 | beeptime = 2500; |
1660 | holgerb | 146 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
147 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
1 | ingob | 148 | ROT_OFF; |
1479 | killagreg | 149 | |
1 | ingob | 150 | Timer_Init(); |
1156 | hbuss | 151 | TIMER2_Init(); |
1 | ingob | 152 | UART_Init(); |
153 | rc_sum_init(); |
||
154 | ADC_Init(); |
||
1743 | holgerb | 155 | I2C_Init(1); |
597 | ingob | 156 | SPI_MasterInit(); |
1486 | killagreg | 157 | Capacity_Init(); |
1435 | killagreg | 158 | LIBFC_Init(); |
1431 | ingob | 159 | GRN_ON; |
160 | sei(); |
||
1622 | killagreg | 161 | ParamSet_Init(); |
1344 | hbuss | 162 | |
1435 | killagreg | 163 | |
1211 | hbuss | 164 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
165 | // + Check connected BL-Ctrls |
||
166 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1648 | killagreg | 167 | // Check connected BL-Ctrls |
168 | BLFlags |= BLFLAG_READ_VERSION; |
||
1662 | killagreg | 169 | motor_read = 0; // read the first I2C-Data |
1648 | killagreg | 170 | SendMotorData(); |
1683 | killagreg | 171 | timer = SetDelay(500); |
172 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
1654 | killagreg | 173 | |
1648 | killagreg | 174 | printf("\n\rFound BL-Ctrl: "); |
1591 | holgerb | 175 | timer = SetDelay(4000); |
1211 | hbuss | 176 | for(i=0; i < MAX_MOTORS; i++) |
1622 | killagreg | 177 | { |
178 | SendMotorData(); |
||
1683 | killagreg | 179 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1622 | killagreg | 180 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
181 | { |
||
1648 | killagreg | 182 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
183 | { |
||
184 | SendMotorData(); |
||
1683 | killagreg | 185 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1648 | killagreg | 186 | } |
1232 | hbuss | 187 | } |
1648 | killagreg | 188 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
189 | { |
||
190 | printf("%d",i+1); |
||
1702 | holgerb | 191 | FoundMotors++; |
1652 | holgerb | 192 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
1648 | killagreg | 193 | } |
1622 | killagreg | 194 | } |
1211 | hbuss | 195 | for(i=0; i < MAX_MOTORS; i++) |
1051 | killagreg | 196 | { |
1622 | killagreg | 197 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
198 | { |
||
199 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
||
1701 | holgerb | 200 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
1111 | hbuss | 201 | } |
1622 | killagreg | 202 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
1 | ingob | 203 | } |
1622 | killagreg | 204 | printf("\n\r==================================="); |
1648 | killagreg | 205 | |
1765 | killagreg | 206 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
1702 | holgerb | 207 | |
1529 | killagreg | 208 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
1622 | killagreg | 209 | { |
210 | printf("\n\rCalibrating pressure sensor.."); |
||
211 | timer = SetDelay(1000); |
||
212 | SucheLuftruckOffset(); |
||
213 | while (!CheckDelay(timer)); |
||
214 | printf("OK\n\r"); |
||
1 | ingob | 215 | } |
1051 | killagreg | 216 | |
1622 | killagreg | 217 | SetNeutral(0); |
1 | ingob | 218 | |
219 | ROT_OFF; |
||
1051 | killagreg | 220 | |
1 | ingob | 221 | beeptime = 2000; |
1051 | killagreg | 222 | ExternControl.Digital[0] = 0x55; |
1 | ingob | 223 | |
1051 | killagreg | 224 | |
1652 | holgerb | 225 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
226 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
1622 | killagreg | 227 | |
1702 | holgerb | 228 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
1622 | killagreg | 229 | { |
230 | FlugMinuten = 0; |
||
231 | FlugMinutenGesamt = 0; |
||
232 | } |
||
233 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
||
234 | |||
1211 | hbuss | 235 | printf("\n\rControl: "); |
1 | ingob | 236 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
1211 | hbuss | 237 | else printf("Normal (ACC-Mode)"); |
1051 | killagreg | 238 | |
1 | ingob | 239 | LcdClear(); |
173 | holgerb | 240 | I2CTimeout = 5000; |
819 | hbuss | 241 | WinkelOut.Orientation = 1; |
1268 | hbuss | 242 | LipoDetection(1); |
1435 | killagreg | 243 | |
1626 | killagreg | 244 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
1444 | ingob | 245 | |
1232 | hbuss | 246 | printf("\n\r===================================\n\r"); |
1622 | killagreg | 247 | //SpektrumBinding(); |
1350 | hbuss | 248 | timer = SetDelay(2000); |
1424 | ingob | 249 | timerPolling = SetDelay(250); |
1648 | killagreg | 250 | |
1636 | ingob | 251 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
1702 | holgerb | 252 | DebugOut.Status[0] = 0x01 | 0x02; |
1834 | holgerb | 253 | JetiBeep = 0; |
1 | ingob | 254 | while (1) |
255 | { |
||
1777 | ingob | 256 | |
257 | if (JetiUpdateModeActive) while (1); |
||
258 | |||
1424 | ingob | 259 | if(CheckDelay(timerPolling)) |
1419 | ingob | 260 | { |
1424 | ingob | 261 | timerPolling = SetDelay(100); |
1435 | killagreg | 262 | LIBFC_Polling(); |
1419 | ingob | 263 | } |
264 | if(UpdateMotor && AdReady) // ReglerIntervall |
||
1051 | killagreg | 265 | { |
1171 | hbuss | 266 | UpdateMotor=0; |
819 | hbuss | 267 | if(WinkelOut.CalcState) CalMk3Mag(); |
1644 | holgerb | 268 | else MotorRegler(); |
269 | SendMotorData(); |
||
1 | ingob | 270 | ROT_OFF; |
1765 | killagreg | 271 | if(SenderOkay) { SenderOkay--; VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM; } |
1603 | killagreg | 272 | else |
273 | { |
||
274 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
275 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
1765 | killagreg | 276 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
1603 | killagreg | 277 | } |
1420 | killagreg | 278 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | holgerb | 279 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
280 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
1309 | hbuss | 281 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1210 | hbuss | 282 | if(!--I2CTimeout || MissingMotor) |
173 | holgerb | 283 | { |
1254 | killagreg | 284 | if(!I2CTimeout) |
1210 | hbuss | 285 | { |
1662 | killagreg | 286 | I2C_Reset(); |
1210 | hbuss | 287 | I2CTimeout = 5; |
1322 | hbuss | 288 | DebugOut.Analog[28]++; // I2C-Error |
1765 | killagreg | 289 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
1702 | holgerb | 290 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1322 | hbuss | 291 | } |
1051 | killagreg | 292 | if((BeepMuster == 0xffff) && MotorenEin) |
293 | { |
||
173 | holgerb | 294 | beeptime = 10000; |
295 | BeepMuster = 0x0080; |
||
1051 | killagreg | 296 | } |
1 | ingob | 297 | } |
1051 | killagreg | 298 | else |
1 | ingob | 299 | { |
1051 | killagreg | 300 | ROT_OFF; |
1765 | killagreg | 301 | if(!beeptime) |
1702 | holgerb | 302 | { |
1765 | killagreg | 303 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
304 | } |
||
1 | ingob | 305 | } |
1639 | holgerb | 306 | if(!UpdateMotor) |
307 | { |
||
1760 | holgerb | 308 | if(CalculateServoSignals) CalculateServo(); |
309 | DatenUebertragung(); |
||
310 | BearbeiteRxDaten(); |
||
1254 | killagreg | 311 | if(CheckDelay(timer)) |
312 | { |
||
1512 | holgerb | 313 | static unsigned char second; |
1420 | killagreg | 314 | timer += 20; // 20 ms interval |
1702 | holgerb | 315 | if(MissingMotor) |
316 | { |
||
1765 | killagreg | 317 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
1702 | holgerb | 318 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1765 | killagreg | 319 | } |
320 | else |
||
1702 | holgerb | 321 | { |
1765 | killagreg | 322 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_BL_MISSING; |
1702 | holgerb | 323 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
1765 | killagreg | 324 | } |
1702 | holgerb | 325 | |
1765 | killagreg | 326 | if(I2CTimeout > 6) VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
327 | |||
1420 | killagreg | 328 | if(PcZugriff) PcZugriff--; |
329 | else |
||
330 | { |
||
331 | ExternControl.Config = 0; |
||
332 | ExternStickNick = 0; |
||
333 | ExternStickRoll = 0; |
||
334 | ExternStickGier = 0; |
||
335 | if(BeepMuster == 0xffff && SenderOkay == 0) |
||
336 | { |
||
337 | beeptime = 15000; |
||
338 | BeepMuster = 0x0c00; |
||
339 | } |
||
340 | } |
||
1682 | holgerb | 341 | if(NaviDataOkay > 200) |
1420 | killagreg | 342 | { |
343 | NaviDataOkay--; |
||
1765 | killagreg | 344 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
1420 | killagreg | 345 | } |
346 | else |
||
347 | { |
||
1702 | holgerb | 348 | if(NC_Version.Compatible) |
349 | { |
||
1765 | killagreg | 350 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
1702 | holgerb | 351 | if(BeepMuster == 0xffff && MotorenEin) |
352 | { |
||
353 | beeptime = 15000; |
||
354 | BeepMuster = 0xA800; |
||
355 | } |
||
1765 | killagreg | 356 | } |
1420 | killagreg | 357 | GPS_Nick = 0; |
358 | GPS_Roll = 0; |
||
1683 | killagreg | 359 | //if(!beeptime) |
1691 | holgerb | 360 | FromNaviCtrl.CompassValue = -1; |
1703 | holgerb | 361 | NaviDataOkay = 0; |
1420 | killagreg | 362 | } |
1309 | hbuss | 363 | if(UBat < BattLowVoltageWarning) |
1254 | killagreg | 364 | { |
1765 | killagreg | 365 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
1254 | killagreg | 366 | if(BeepMuster == 0xffff) |
367 | { |
||
368 | beeptime = 6000; |
||
369 | BeepMuster = 0x0300; |
||
370 | } |
||
371 | } |
||
1765 | killagreg | 372 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
1420 | killagreg | 373 | |
1254 | killagreg | 374 | SPI_StartTransmitPacket(); |
375 | SendSPI = 4; |
||
1320 | hbuss | 376 | if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden |
1529 | killagreg | 377 | else |
1512 | holgerb | 378 | if(++second == 49) |
379 | { |
||
380 | second = 0; |
||
381 | FlugSekunden++; |
||
382 | } |
||
1320 | hbuss | 383 | if(++timer2 == 2930) // eine Minute |
1298 | hbuss | 384 | { |
385 | timer2 = 0; |
||
386 | FlugMinuten++; |
||
387 | FlugMinutenGesamt++; |
||
1652 | holgerb | 388 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
389 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
||
390 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
||
391 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
||
1344 | hbuss | 392 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
1298 | hbuss | 393 | } |
1254 | killagreg | 394 | } |
921 | hbuss | 395 | LED_Update(); |
1486 | killagreg | 396 | Capacity_Update(); |
1639 | holgerb | 397 | } |
604 | hbuss | 398 | } |
723 | hbuss | 399 | if(!SendSPI) { SPI_TransmitByte(); } |
1 | ingob | 400 | } |
401 | return (1); |
||
402 | } |
||
403 | |||
1219 | hbuss | 404 |