Rev 1880 | 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" |
||
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 | |
1897 | - | 64 | unsigned char delayjetibeep = 0;/// |
65 | unsigned char delayjetibeepset =0;/// |
||
66 | static char panodelay = 0; ///martinw |
||
67 | static char panoleddelay = 0; ///martinw |
||
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; |
||
1897 | - | 111 | //if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
112 | if(print) printf("Low Batt level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); /// Martinw; removed memorysaving |
||
113 | |||
1268 | hbuss | 114 | } |
115 | |||
1 | ingob | 116 | //############################################################################ |
117 | //Hauptprogramm |
||
118 | int main (void) |
||
119 | //############################################################################ |
||
120 | { |
||
1424 | ingob | 121 | unsigned int timer,i,timer2 = 0, timerPolling; |
1479 | killagreg | 122 | |
1051 | killagreg | 123 | DDRB = 0x00; |
124 | PORTB = 0x00; |
||
188 | holgerb | 125 | for(timer = 0; timer < 1000; timer++); // verzögern |
1660 | holgerb | 126 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
127 | PlatinenVersion = 21; |
||
128 | #else |
||
129 | if(PINB & 0x01) |
||
918 | hbuss | 130 | { |
1051 | killagreg | 131 | if(PINB & 0x02) PlatinenVersion = 13; |
132 | else PlatinenVersion = 11; |
||
918 | hbuss | 133 | } |
1051 | killagreg | 134 | else |
1021 | hbuss | 135 | { |
1051 | killagreg | 136 | if(PINB & 0x02) PlatinenVersion = 20; |
137 | else PlatinenVersion = 10; |
||
1021 | hbuss | 138 | } |
1660 | holgerb | 139 | #endif |
173 | holgerb | 140 | DDRC = 0x81; // SCL |
1036 | hbuss | 141 | DDRC |=0x40; // HEF4017 Reset |
1 | ingob | 142 | PORTC = 0xff; // Pullup SDA |
143 | DDRB = 0x1B; // LEDs und Druckoffset |
||
144 | PORTB = 0x01; // LED_Rot |
||
145 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
||
1153 | hbuss | 146 | PORTD = 0x47; // LED |
1171 | hbuss | 147 | HEF4017R_ON; |
1 | ingob | 148 | MCUSR &=~(1<<WDRF); |
149 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
||
150 | WDTCSR = 0; |
||
151 | |||
1652 | holgerb | 152 | beeptime = 2500; |
1660 | holgerb | 153 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
154 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
||
1 | ingob | 155 | ROT_OFF; |
1479 | killagreg | 156 | |
1 | ingob | 157 | Timer_Init(); |
1156 | hbuss | 158 | TIMER2_Init(); |
1 | ingob | 159 | UART_Init(); |
160 | rc_sum_init(); |
||
161 | ADC_Init(); |
||
1743 | holgerb | 162 | I2C_Init(1); |
597 | ingob | 163 | SPI_MasterInit(); |
1486 | killagreg | 164 | Capacity_Init(); |
1435 | killagreg | 165 | LIBFC_Init(); |
1431 | ingob | 166 | GRN_ON; |
167 | sei(); |
||
1622 | killagreg | 168 | ParamSet_Init(); |
1344 | hbuss | 169 | |
1435 | killagreg | 170 | |
1211 | hbuss | 171 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
172 | // + Check connected BL-Ctrls |
||
173 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1648 | killagreg | 174 | // Check connected BL-Ctrls |
175 | BLFlags |= BLFLAG_READ_VERSION; |
||
1662 | killagreg | 176 | motor_read = 0; // read the first I2C-Data |
1648 | killagreg | 177 | SendMotorData(); |
1683 | killagreg | 178 | timer = SetDelay(500); |
179 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
||
1654 | killagreg | 180 | |
1648 | killagreg | 181 | printf("\n\rFound BL-Ctrl: "); |
1591 | holgerb | 182 | timer = SetDelay(4000); |
1211 | hbuss | 183 | for(i=0; i < MAX_MOTORS; i++) |
1622 | killagreg | 184 | { |
185 | SendMotorData(); |
||
1683 | killagreg | 186 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1622 | killagreg | 187 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
188 | { |
||
1648 | killagreg | 189 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
190 | { |
||
191 | SendMotorData(); |
||
1683 | killagreg | 192 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
1648 | killagreg | 193 | } |
1232 | hbuss | 194 | } |
1648 | killagreg | 195 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
196 | { |
||
197 | printf("%d",i+1); |
||
1702 | holgerb | 198 | FoundMotors++; |
1652 | holgerb | 199 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
1648 | killagreg | 200 | } |
1622 | killagreg | 201 | } |
1211 | hbuss | 202 | for(i=0; i < MAX_MOTORS; i++) |
1051 | killagreg | 203 | { |
1622 | killagreg | 204 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
205 | { |
||
1897 | - | 206 | //printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
207 | printf("\n\r\n\r!!MISSING BL-CTRL: %d!!",i+1);/// Martinw; removed memorysaving |
||
1701 | holgerb | 208 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
1111 | hbuss | 209 | } |
1622 | killagreg | 210 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
1 | ingob | 211 | } |
1897 | - | 212 | //printf("\n\r===================================");/// Martinw; removed memorysaving |
213 | printf("\n\r=");/// Martinw; removed memorysaving |
||
1648 | killagreg | 214 | |
1897 | - | 215 | |
1765 | killagreg | 216 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
1702 | holgerb | 217 | |
1529 | killagreg | 218 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
1622 | killagreg | 219 | { |
1897 | - | 220 | //printf("\n\rCalibrating pressure sensor.."); |
221 | printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving |
||
1622 | killagreg | 222 | timer = SetDelay(1000); |
223 | SucheLuftruckOffset(); |
||
224 | while (!CheckDelay(timer)); |
||
225 | printf("OK\n\r"); |
||
1 | ingob | 226 | } |
1051 | killagreg | 227 | |
1622 | killagreg | 228 | SetNeutral(0); |
1 | ingob | 229 | |
230 | ROT_OFF; |
||
1051 | killagreg | 231 | |
1 | ingob | 232 | beeptime = 2000; |
1051 | killagreg | 233 | ExternControl.Digital[0] = 0x55; |
1 | ingob | 234 | |
1051 | killagreg | 235 | |
1652 | holgerb | 236 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
237 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
||
1622 | killagreg | 238 | |
1702 | holgerb | 239 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
1622 | killagreg | 240 | { |
241 | FlugMinuten = 0; |
||
242 | FlugMinutenGesamt = 0; |
||
243 | } |
||
244 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
||
245 | |||
1211 | hbuss | 246 | printf("\n\rControl: "); |
1 | ingob | 247 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
1211 | hbuss | 248 | else printf("Normal (ACC-Mode)"); |
1897 | - | 249 | |
250 | #ifdef WITH_MKTOOL_Display // MartinW; for no MKT Display main.h |
||
251 | #warning : "### with MKTool Display ###" |
||
252 | LcdClear(); |
||
253 | #endif |
||
1051 | killagreg | 254 | |
173 | holgerb | 255 | I2CTimeout = 5000; |
819 | hbuss | 256 | WinkelOut.Orientation = 1; |
1268 | hbuss | 257 | LipoDetection(1); |
1435 | killagreg | 258 | |
1626 | killagreg | 259 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
1444 | ingob | 260 | |
1897 | - | 261 | //printf("\n\r===================================\n\r"); |
262 | printf("\n\r=\n\r"); /// Martinw; removed memorysaving |
||
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; |
1897 | - | 269 | |
270 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) ///MartinW; only for 1284er |
||
271 | //#warning : "### with Sponsored Message ###" |
||
272 | printf("\n\rJETI+ Version sponsored by Flyinghigh.ch, progammed by MartinW\n\r"); |
||
273 | #else |
||
274 | #endif |
||
275 | |||
276 | |||
1834 | holgerb | 277 | JetiBeep = 0; |
1 | ingob | 278 | while (1) |
279 | { |
||
1777 | ingob | 280 | |
281 | if (JetiUpdateModeActive) while (1); |
||
282 | |||
1424 | ingob | 283 | if(CheckDelay(timerPolling)) |
1419 | ingob | 284 | { |
1424 | ingob | 285 | timerPolling = SetDelay(100); |
1435 | killagreg | 286 | LIBFC_Polling(); |
1897 | - | 287 | |
288 | #ifdef WITH_JETI_BEEP /// MartinW main.h |
||
289 | #warning : "### with JetiBeep Delay ###" |
||
290 | |||
291 | if(!(JetiBeep == 0)) |
||
292 | { |
||
293 | delayjetibeep++; |
||
294 | } |
||
295 | if(delayjetibeep == delayjetibeepset ) |
||
296 | { |
||
297 | delayjetibeep = 0; |
||
298 | JetiBeep = 0; |
||
299 | } |
||
300 | |||
301 | #else |
||
302 | #warning : "### without JetiBeep Delay ###" |
||
303 | JetiBeep = 0; |
||
304 | #endif |
||
305 | |||
306 | |||
1419 | ingob | 307 | } |
308 | if(UpdateMotor && AdReady) // ReglerIntervall |
||
1051 | killagreg | 309 | { |
1171 | hbuss | 310 | UpdateMotor=0; |
819 | hbuss | 311 | if(WinkelOut.CalcState) CalMk3Mag(); |
1644 | holgerb | 312 | else MotorRegler(); |
313 | SendMotorData(); |
||
1 | ingob | 314 | ROT_OFF; |
1765 | killagreg | 315 | if(SenderOkay) { SenderOkay--; VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM; } |
1603 | killagreg | 316 | else |
317 | { |
||
318 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
||
319 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
||
1765 | killagreg | 320 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
1603 | killagreg | 321 | } |
1420 | killagreg | 322 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | holgerb | 323 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
324 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
||
1309 | hbuss | 325 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1210 | hbuss | 326 | if(!--I2CTimeout || MissingMotor) |
173 | holgerb | 327 | { |
1254 | killagreg | 328 | if(!I2CTimeout) |
1210 | hbuss | 329 | { |
1662 | killagreg | 330 | I2C_Reset(); |
1210 | hbuss | 331 | I2CTimeout = 5; |
1322 | hbuss | 332 | DebugOut.Analog[28]++; // I2C-Error |
1765 | killagreg | 333 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
1702 | holgerb | 334 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1322 | hbuss | 335 | } |
1051 | killagreg | 336 | if((BeepMuster == 0xffff) && MotorenEin) |
337 | { |
||
173 | holgerb | 338 | beeptime = 10000; |
339 | BeepMuster = 0x0080; |
||
1051 | killagreg | 340 | } |
1 | ingob | 341 | } |
1051 | killagreg | 342 | else |
1 | ingob | 343 | { |
1051 | killagreg | 344 | ROT_OFF; |
1765 | killagreg | 345 | if(!beeptime) |
1702 | holgerb | 346 | { |
1765 | killagreg | 347 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
348 | } |
||
1 | ingob | 349 | } |
1639 | holgerb | 350 | if(!UpdateMotor) |
351 | { |
||
1760 | holgerb | 352 | if(CalculateServoSignals) CalculateServo(); |
353 | DatenUebertragung(); |
||
354 | BearbeiteRxDaten(); |
||
1254 | killagreg | 355 | if(CheckDelay(timer)) |
356 | { |
||
1512 | holgerb | 357 | static unsigned char second; |
1420 | killagreg | 358 | timer += 20; // 20 ms interval |
1702 | holgerb | 359 | if(MissingMotor) |
360 | { |
||
1765 | killagreg | 361 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
1702 | holgerb | 362 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
1765 | killagreg | 363 | } |
364 | else |
||
1702 | holgerb | 365 | { |
1765 | killagreg | 366 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_BL_MISSING; |
1702 | holgerb | 367 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
1765 | killagreg | 368 | } |
1702 | holgerb | 369 | |
1765 | killagreg | 370 | if(I2CTimeout > 6) VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C; |
371 | |||
1420 | killagreg | 372 | if(PcZugriff) PcZugriff--; |
373 | else |
||
374 | { |
||
375 | ExternControl.Config = 0; |
||
376 | ExternStickNick = 0; |
||
377 | ExternStickRoll = 0; |
||
378 | ExternStickGier = 0; |
||
379 | if(BeepMuster == 0xffff && SenderOkay == 0) |
||
380 | { |
||
381 | beeptime = 15000; |
||
382 | BeepMuster = 0x0c00; |
||
383 | } |
||
384 | } |
||
1682 | holgerb | 385 | if(NaviDataOkay > 200) |
1420 | killagreg | 386 | { |
387 | NaviDataOkay--; |
||
1765 | killagreg | 388 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
1420 | killagreg | 389 | } |
390 | else |
||
391 | { |
||
1702 | holgerb | 392 | if(NC_Version.Compatible) |
393 | { |
||
1765 | killagreg | 394 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
1702 | holgerb | 395 | if(BeepMuster == 0xffff && MotorenEin) |
396 | { |
||
397 | beeptime = 15000; |
||
398 | BeepMuster = 0xA800; |
||
399 | } |
||
1765 | killagreg | 400 | } |
1420 | killagreg | 401 | GPS_Nick = 0; |
402 | GPS_Roll = 0; |
||
1683 | killagreg | 403 | //if(!beeptime) |
1691 | holgerb | 404 | FromNaviCtrl.CompassValue = -1; |
1703 | holgerb | 405 | NaviDataOkay = 0; |
1420 | killagreg | 406 | } |
1309 | hbuss | 407 | if(UBat < BattLowVoltageWarning) |
1254 | killagreg | 408 | { |
1765 | killagreg | 409 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
1254 | killagreg | 410 | if(BeepMuster == 0xffff) |
411 | { |
||
412 | beeptime = 6000; |
||
413 | BeepMuster = 0x0300; |
||
414 | } |
||
415 | } |
||
1765 | killagreg | 416 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
1420 | killagreg | 417 | |
1254 | killagreg | 418 | SPI_StartTransmitPacket(); |
419 | SendSPI = 4; |
||
1320 | hbuss | 420 | if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden |
1529 | killagreg | 421 | else |
1512 | holgerb | 422 | if(++second == 49) |
423 | { |
||
424 | second = 0; |
||
425 | FlugSekunden++; |
||
426 | } |
||
1320 | hbuss | 427 | if(++timer2 == 2930) // eine Minute |
1298 | hbuss | 428 | { |
429 | timer2 = 0; |
||
430 | FlugMinuten++; |
||
431 | FlugMinutenGesamt++; |
||
1652 | holgerb | 432 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
433 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
||
434 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
||
435 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
||
1344 | hbuss | 436 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
1298 | hbuss | 437 | } |
1254 | killagreg | 438 | } |
1897 | - | 439 | |
440 | #ifdef WITH_PANOTRIGGER /// MartinW main.h means no memsave |
||
441 | #warning : "### with Panorama Trigger Function ###" |
||
442 | //// Pano Trigger |
||
443 | if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function |
||
444 | { |
||
445 | if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; } |
||
446 | degreedivold = degreediv; |
||
447 | degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division |
||
448 | |||
449 | if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1) |
||
450 | { |
||
451 | |||
452 | if(panodelay == 0) |
||
453 | { |
||
454 | panotrigger= 1; // muss wieder geleert werden |
||
455 | ROT_ON; |
||
456 | J16_ON; |
||
457 | panodelay = Parameter_UserParam5; |
||
458 | } |
||
459 | } |
||
460 | |||
461 | else |
||
462 | { |
||
463 | if(panodelay <= Parameter_UserParam6) //ms Intervall |
||
464 | { |
||
465 | //panoleddelay = Parameter_UserParam6; |
||
466 | J16_OFF; |
||
467 | ROT_OFF; |
||
468 | } |
||
469 | if(panodelay > 0) |
||
470 | { |
||
471 | panodelay--; |
||
472 | } |
||
473 | |||
474 | } |
||
475 | }// END if(Parameter_UserParam4 >= 1) |
||
476 | //// Pano Trigger |
||
477 | |||
478 | #else |
||
479 | #warning : "### without Panorama Trigger Function ###" |
||
480 | |||
481 | #endif |
||
482 | |||
483 | |||
484 | |||
921 | hbuss | 485 | LED_Update(); |
1486 | killagreg | 486 | Capacity_Update(); |
1839 | holgerb | 487 | } //else DebugOut.Analog[26]++; |
604 | hbuss | 488 | } |
723 | hbuss | 489 | if(!SendSPI) { SPI_TransmitByte(); } |
1 | ingob | 490 | } |
491 | return (1); |
||
492 | } |
||
493 | |||
1219 | hbuss | 494 |