Rev 1813 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1813 | - | 1 | /****************************************************************************************************************** |
2 | V0.82b-Arthur-P 2010-12-18 |
||
3 | ------------------------------------------------------------------------------------------------------------------ |
||
4 | Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
||
5 | ------------------------------------------------------------------------------------------------------------------ |
||
6 | Besides adding this header. The following files have been modified: |
||
7 | * main.c: Remark header added with summary of changes to other files. Also remarked out variable i from function |
||
8 | Mittelwert as this variable is not used. No other changes. |
||
9 | * menu.c: Modifed text to show branch name in MKTool window. |
||
10 | * fc.c: Modified motor smoothing routine. |
||
11 | * timer0.c: Added several variables and modified the servo control routines to allow control to be activated |
||
12 | * through a parameter, and to allow different shutter servo control. |
||
1819 | - | 13 | * timer0.c and rc.c: Replaced if(Platinenversion < 20) with a modified if statement to allow parameter control for external |
14 | * HEF4017. |
||
1813 | - | 15 | * makefile: Modified to correctly name output file to reflect branch name. |
16 | All changes are clearly marked similar to this change. |
||
17 | ******************************************************************************************************************/ |
||
1 | ingob | 18 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1338 | ingob | 19 | // + Copyright (c) Holger Buss, Ingo Busker |
20 | // + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
||
1 | ingob | 21 | // + www.MikroKopter.com |
22 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 23 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
24 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten und nicht-kommerziellen Gebrauch zulässig ist. |
||
25 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
||
26 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
1 | ingob | 27 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
28 | // + Verkauf von Luftbildaufnahmen, usw. |
||
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 30 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
1 | ingob | 31 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
32 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
33 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
34 | // + auf anderen Webseiten oder Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
35 | // + eindeutig als Ursprung verlinkt und genannt werden |
||
36 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
37 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
38 | // + Benutzung auf eigene Gefahr |
||
39 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
40 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1338 | ingob | 41 | // + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
1 | ingob | 42 | // + mit unserer Zustimmung zulässig |
43 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
44 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
45 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1051 | killagreg | 46 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
1 | ingob | 47 | // + this list of conditions and the following disclaimer. |
48 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
49 | // + from this software without specific prior written permission. |
||
1051 | killagreg | 50 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
1 | ingob | 51 | // + for non-commercial use (directly or indirectly) |
1051 | killagreg | 52 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
1 | ingob | 53 | // + with our written permission |
1051 | killagreg | 54 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
55 | // + clearly linked as origin |
||
1338 | ingob | 56 | // + * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
1 | ingob | 57 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
58 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
59 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
60 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
61 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
62 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
63 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
64 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
65 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
66 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
1051 | killagreg | 67 | // + POSSIBILITY OF SUCH DAMAGE. |
1 | ingob | 68 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
69 | #include "main.h" |
||
70 | |||
1438 | ingob | 71 | |
173 | holgerb | 72 | unsigned char PlatinenVersion = 10; |
723 | hbuss | 73 | unsigned char SendVersionToNavi = 1; |
1232 | hbuss | 74 | unsigned char BattLowVoltageWarning = 94; |
1298 | hbuss | 75 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
1512 | holgerb | 76 | unsigned int FlugSekunden = 0; |
1444 | ingob | 77 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
1702 | holgerb | 78 | unsigned char FoundMotors = 0; |
1444 | ingob | 79 | |
819 | hbuss | 80 | void CalMk3Mag(void) |
81 | { |
||
82 | static unsigned char stick = 1; |
||
83 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
||
84 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
||
85 | { |
||
86 | stick = 1; |
||
87 | WinkelOut.CalcState++; |
||
1051 | killagreg | 88 | if(WinkelOut.CalcState > 4) |
89 | { |
||
819 | hbuss | 90 | // WinkelOut.CalcState = 0; // in Uart.c |
91 | beeptime = 1000; |
||
1051 | killagreg | 92 | } |
1232 | hbuss | 93 | else Piep(WinkelOut.CalcState,150); |
819 | hbuss | 94 | } |
95 | DebugOut.Analog[19] = WinkelOut.CalcState; |
||
96 | } |
||
97 | |||
1438 | ingob | 98 | |
1268 | hbuss | 99 | void LipoDetection(unsigned char print) |
100 | { |
||
1654 | killagreg | 101 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
102 | unsigned int timer, cells; |
||
103 | if(print) printf("\n\rBatt:"); |
||
104 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
||
105 | { |
||
106 | timer = SetDelay(500); |
||
107 | if(print) while (!CheckDelay(timer)); |
||
1657 | killagreg | 108 | // up to 6s LiPo, less than 2s is technical impossible |
109 | for(cells = 2; cells < 7; cells++) |
||
1654 | killagreg | 110 | { |
111 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
||
1420 | killagreg | 112 | } |
1654 | killagreg | 113 | |
114 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
||
115 | if(print) |
||
116 | { |
||
117 | Piep(cells, 200); |
||
118 | printf(" %d Cells ", cells); |
||
1420 | killagreg | 119 | } |
1654 | killagreg | 120 | } |
121 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
||
122 | if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
||
1268 | hbuss | 123 | } |
124 | |||
1 | ingob | 125 | //############################################################################ |
126 | //Hauptprogramm |
||
127 | int main (void) |
||
128 | //############################################################################ |
||
129 | { |
||
1424 | ingob | 130 | unsigned int timer,i,timer2 = 0, timerPolling; |
1479 | killagreg | 131 | |
1051 | killagreg | 132 | DDRB = 0x00; |
133 | PORTB = 0x00; |
||
188 | holgerb | 134 | for(timer = 0; timer < 1000; timer++); // verzögern |
1660 | holgerb | 135 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
136 | PlatinenVersion = 21; |
||
137 | #else |
||
138 | if(PINB & 0x01) |
||
918 | hbuss | 139 | { |
1051 | killagreg | 140 | if(PINB & 0x02) PlatinenVersion = 13; |
141 | else PlatinenVersion = 11; |
||
918 | hbuss | 142 | } |
1051 | killagreg | 143 | else |
1021 | hbuss | 144 | { |
1051 | killagreg | 145 | if(PINB & 0x02) PlatinenVersion = 20; |
146 | else PlatinenVersion = 10; |
||
1021 | hbuss | 147 | } |
1660 | holgerb | 148 | #endif |
173 | holgerb | 149 | DDRC = 0x81; // SCL |
1036 | hbuss | 150 | DDRC |=0x40; // HEF4017 Reset |
1 | ingob | 151 | PORTC = 0xff; // Pullup SDA |
152 | DDRB = 0x1B; // LEDs und Druckoffset |
||
153 | PORTB = 0x01; // LED_Rot |
||
154 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
1153 | hbuss | 155 | PORTD = 0x47; // LED |
1171 | hbuss | 156 | HEF4017R_ON; |
1 | ingob | 157 | MCUSR &=~(1<<WDRF); |
158 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
159 | WDTCSR = 0; |
||
160 | |||
1652 | holgerb | 161 | beeptime = 2500; |
1660 | holgerb | 162 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
163 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
1 | ingob | 164 | ROT_OFF; |
1479 | killagreg | 165 | |
1 | ingob | 166 | Timer_Init(); |
1156 | hbuss | 167 | TIMER2_Init(); |
1 | ingob | 168 | UART_Init(); |
169 | rc_sum_init(); |
||
170 | ADC_Init(); |
||
1743 | holgerb | 171 | I2C_Init(1); |
597 | ingob | 172 | SPI_MasterInit(); |
1486 | killagreg | 173 | Capacity_Init(); |
1435 | killagreg | 174 | LIBFC_Init(); |
1431 | ingob | 175 | GRN_ON; |
176 | sei(); |
||
1622 | killagreg | 177 | ParamSet_Init(); |
1344 | hbuss | 178 | |
1435 | killagreg | 179 | |
1211 | hbuss | 180 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
181 | // + Check connected BL-Ctrls |
||
182 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1648 | killagreg | 183 | // Check connected BL-Ctrls |
184 | BLFlags |= BLFLAG_READ_VERSION; |
||
1662 | killagreg | 185 | motor_read = 0; // read the first I2C-Data |
1648 | killagreg | 186 | SendMotorData(); |
1683 | killagreg | 187 | timer = SetDelay(500); |
188 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
1654 | killagreg | 189 | |
1648 | killagreg | 190 | printf("\n\rFound BL-Ctrl: "); |
1591 | holgerb | 191 | timer = SetDelay(4000); |
1211 | hbuss | 192 | for(i=0; i < MAX_MOTORS; i++) |
1622 | killagreg | 193 | { |
194 | SendMotorData(); |
||
1683 | killagreg | 195 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1622 | killagreg | 196 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
197 | { |
||
1648 | killagreg | 198 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
199 | { |
||
200 | SendMotorData(); |
||
1683 | killagreg | 201 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1648 | killagreg | 202 | } |
1232 | hbuss | 203 | } |
1648 | killagreg | 204 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
205 | { |
||
206 | printf("%d",i+1); |
||
1702 | holgerb | 207 | FoundMotors++; |
1652 | holgerb | 208 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
1648 | killagreg | 209 | } |
1622 | killagreg | 210 | } |
1211 | hbuss | 211 | for(i=0; i < MAX_MOTORS; i++) |
1051 | killagreg | 212 | { |
1622 | killagreg | 213 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
214 | { |
||
215 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
||
1701 | holgerb | 216 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
1111 | hbuss | 217 | } |
1622 | killagreg | 218 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
1 | ingob | 219 | } |
1622 | killagreg | 220 | printf("\n\r==================================="); |
1648 | killagreg | 221 | |
1765 | killagreg | 222 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
1702 | holgerb | 223 | |
1529 | killagreg | 224 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
1622 | killagreg | 225 | { |
226 | printf("\n\rCalibrating pressure sensor.."); |
||
227 | timer = SetDelay(1000); |
||
228 | SucheLuftruckOffset(); |
||
229 | while (!CheckDelay(timer)); |
||
230 | printf("OK\n\r"); |
||
1 | ingob | 231 | } |
1051 | killagreg | 232 | |
1622 | killagreg | 233 | SetNeutral(0); |
1 | ingob | 234 | |
235 | ROT_OFF; |
||
1051 | killagreg | 236 | |
1 | ingob | 237 | beeptime = 2000; |
1051 | killagreg | 238 | ExternControl.Digital[0] = 0x55; |
1 | ingob | 239 | |
1051 | killagreg | 240 | |
1652 | holgerb | 241 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
242 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
1622 | killagreg | 243 | |
1702 | holgerb | 244 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
1622 | killagreg | 245 | { |
246 | FlugMinuten = 0; |
||
247 | FlugMinutenGesamt = 0; |
||
248 | } |
||
249 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
||
250 | |||
1211 | hbuss | 251 | printf("\n\rControl: "); |
1 | ingob | 252 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
1211 | hbuss | 253 | else printf("Normal (ACC-Mode)"); |
1051 | killagreg | 254 | |
1 | ingob | 255 | LcdClear(); |
173 | holgerb | 256 | I2CTimeout = 5000; |
819 | hbuss | 257 | WinkelOut.Orientation = 1; |
1268 | hbuss | 258 | LipoDetection(1); |
1435 | killagreg | 259 | |
1626 | killagreg | 260 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
1444 | ingob | 261 | |
1232 | hbuss | 262 | printf("\n\r===================================\n\r"); |
1622 | killagreg | 263 | //SpektrumBinding(); |
1350 | hbuss | 264 | timer = SetDelay(2000); |
1424 | ingob | 265 | timerPolling = SetDelay(250); |
1648 | killagreg | 266 | |
1636 | ingob | 267 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
1702 | holgerb | 268 | DebugOut.Status[0] = 0x01 | 0x02; |
1648 | killagreg | 269 | |
1 | ingob | 270 | while (1) |
271 | { |
||
1777 | ingob | 272 | |
273 | if (JetiUpdateModeActive) while (1); |
||
274 | |||
1424 | ingob | 275 | if(CheckDelay(timerPolling)) |
1419 | ingob | 276 | { |
1424 | ingob | 277 | timerPolling = SetDelay(100); |
1435 | killagreg | 278 | LIBFC_Polling(); |
1419 | ingob | 279 | } |
280 | if(UpdateMotor && AdReady) // ReglerIntervall |
||
1051 | killagreg | 281 | { |
1171 | hbuss | 282 | UpdateMotor=0; |
819 | hbuss | 283 | if(WinkelOut.CalcState) CalMk3Mag(); |
1644 | holgerb | 284 | else MotorRegler(); |
285 | SendMotorData(); |
||
1 | ingob | 286 | ROT_OFF; |
1765 | killagreg | 287 | if(SenderOkay) { SenderOkay--; VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM; } |
1603 | killagreg | 288 | else |
289 | { |
||
290 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
291 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
1765 | killagreg | 292 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
1603 | killagreg | 293 | } |
1420 | killagreg | 294 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | holgerb | 295 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
296 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
1309 | hbuss | 297 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1210 | hbuss | 298 | if(!--I2CTimeout || MissingMotor) |
173 | holgerb | 299 | { |
1254 | killagreg | 300 | if(!I2CTimeout) |
1210 | hbuss | 301 | { |
1662 | killagreg | 302 | I2C_Reset(); |
1210 | hbuss | 303 | I2CTimeout = 5; |
1322 | hbuss | 304 | DebugOut.Analog[28]++; // I2C-Error |
1765 | killagreg | 305 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
1702 | holgerb | 306 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1322 | hbuss | 307 | } |
1051 | killagreg | 308 | if((BeepMuster == 0xffff) && MotorenEin) |
309 | { |
||
173 | holgerb | 310 | beeptime = 10000; |
311 | BeepMuster = 0x0080; |
||
1051 | killagreg | 312 | } |
1 | ingob | 313 | } |
1051 | killagreg | 314 | else |
1 | ingob | 315 | { |
1051 | killagreg | 316 | ROT_OFF; |
1765 | killagreg | 317 | if(!beeptime) |
1702 | holgerb | 318 | { |
1765 | killagreg | 319 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
320 | } |
||
1 | ingob | 321 | } |
1639 | holgerb | 322 | if(!UpdateMotor) |
323 | { |
||
1760 | holgerb | 324 | if(CalculateServoSignals) CalculateServo(); |
325 | DatenUebertragung(); |
||
326 | BearbeiteRxDaten(); |
||
1254 | killagreg | 327 | if(CheckDelay(timer)) |
328 | { |
||
1512 | holgerb | 329 | static unsigned char second; |
1420 | killagreg | 330 | timer += 20; // 20 ms interval |
1702 | holgerb | 331 | if(MissingMotor) |
332 | { |
||
1765 | killagreg | 333 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
1702 | holgerb | 334 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1765 | killagreg | 335 | } |
336 | else |
||
1702 | holgerb | 337 | { |
1765 | killagreg | 338 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_BL_MISSING; |
1702 | holgerb | 339 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
1765 | killagreg | 340 | } |
1702 | holgerb | 341 | |
1765 | killagreg | 342 | if(I2CTimeout > 6) VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
343 | |||
1420 | killagreg | 344 | if(PcZugriff) PcZugriff--; |
345 | else |
||
346 | { |
||
347 | ExternControl.Config = 0; |
||
348 | ExternStickNick = 0; |
||
349 | ExternStickRoll = 0; |
||
350 | ExternStickGier = 0; |
||
351 | if(BeepMuster == 0xffff && SenderOkay == 0) |
||
352 | { |
||
353 | beeptime = 15000; |
||
354 | BeepMuster = 0x0c00; |
||
355 | } |
||
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 | { |
||
1765 | killagreg | 366 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
1702 | holgerb | 367 | if(BeepMuster == 0xffff && MotorenEin) |
368 | { |
||
369 | beeptime = 15000; |
||
370 | BeepMuster = 0xA800; |
||
371 | } |
||
1765 | killagreg | 372 | } |
1420 | killagreg | 373 | GPS_Nick = 0; |
374 | GPS_Roll = 0; |
||
1683 | killagreg | 375 | //if(!beeptime) |
1691 | holgerb | 376 | FromNaviCtrl.CompassValue = -1; |
1703 | holgerb | 377 | NaviDataOkay = 0; |
1420 | killagreg | 378 | } |
1309 | hbuss | 379 | if(UBat < BattLowVoltageWarning) |
1254 | killagreg | 380 | { |
1765 | killagreg | 381 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
1254 | killagreg | 382 | if(BeepMuster == 0xffff) |
383 | { |
||
384 | beeptime = 6000; |
||
385 | BeepMuster = 0x0300; |
||
386 | } |
||
387 | } |
||
1765 | killagreg | 388 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
1420 | killagreg | 389 | |
1254 | killagreg | 390 | SPI_StartTransmitPacket(); |
391 | SendSPI = 4; |
||
1320 | hbuss | 392 | if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden |
1529 | killagreg | 393 | else |
1512 | holgerb | 394 | if(++second == 49) |
395 | { |
||
396 | second = 0; |
||
397 | FlugSekunden++; |
||
398 | } |
||
1320 | hbuss | 399 | if(++timer2 == 2930) // eine Minute |
1298 | hbuss | 400 | { |
401 | timer2 = 0; |
||
402 | FlugMinuten++; |
||
403 | FlugMinutenGesamt++; |
||
1652 | holgerb | 404 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
405 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
||
406 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
||
407 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
||
1344 | hbuss | 408 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
1298 | hbuss | 409 | } |
1254 | killagreg | 410 | } |
921 | hbuss | 411 | LED_Update(); |
1486 | killagreg | 412 | Capacity_Update(); |
1639 | holgerb | 413 | } |
604 | hbuss | 414 | } |
723 | hbuss | 415 | if(!SendSPI) { SPI_TransmitByte(); } |
1 | ingob | 416 | } |
417 | return (1); |
||
418 | } |
||
419 | |||
1219 | hbuss | 420 |