Rev 2345 | Rev 2348 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2345 | Rev 2346 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + www.MikroKopter.com |
2 | // + www.MikroKopter.com |
3 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 | // + Software Nutzungsbedingungen (english version: see below) |
4 | // + Software Nutzungsbedingungen (english version: see below) |
5 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
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 |
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 |
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. |
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. |
9 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
11 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
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. |
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 |
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. |
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 |
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. |
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 |
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 |
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. |
19 | // + des Mitverschuldens offen. |
20 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
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. |
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. |
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 |
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. |
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. |
25 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
26 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
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. |
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. |
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 | // + Software LICENSING TERMS |
29 | // + Software LICENSING TERMS |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
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 |
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*. |
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. |
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 |
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 |
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. |
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 |
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. |
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 |
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 |
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 |
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 |
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. |
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 |
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. |
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 |
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. |
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. |
49 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
50 | // + #### END OF LICENSING TERMS #### |
50 | // + #### END OF LICENSING TERMS #### |
51 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
51 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
52 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
52 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
53 | #include "main.h" |
53 | #include "main.h" |
54 | unsigned char DisableRcOffBeeping = 0; |
54 | unsigned char DisableRcOffBeeping = 0; |
55 | unsigned char PlatinenVersion = 10; |
55 | unsigned char PlatinenVersion = 10; |
56 | unsigned char BattLowVoltageWarning = 94; |
56 | unsigned char BattLowVoltageWarning = 94; |
57 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
57 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
58 | unsigned int FlugSekunden = 0; |
58 | unsigned int FlugSekunden = 0; |
59 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
59 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
60 | unsigned char FoundMotors = 0; |
60 | unsigned char FoundMotors = 0; |
61 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
61 | unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box |
62 | unsigned char ActiveParamSet = 3; |
62 | unsigned char ActiveParamSet = 3; |
63 | 63 | ||
64 | void PrintLine(void) |
64 | void PrintLine(void) |
65 | { |
65 | { |
66 | printf("\n\r==================================="); |
66 | printf("\n\r==================================="); |
67 | } |
67 | } |
68 | 68 | ||
69 | 69 | ||
70 | void CalMk3Mag(void) |
70 | void CalMk3Mag(void) |
71 | { |
71 | { |
72 | static unsigned char stick = 1; |
72 | static unsigned char stick = 1; |
73 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
73 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0; |
74 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
74 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick) |
75 | { |
75 | { |
76 | stick = 1; |
76 | stick = 1; |
77 | WinkelOut.CalcState++; |
77 | WinkelOut.CalcState++; |
78 | if(WinkelOut.CalcState > 4) |
78 | if(WinkelOut.CalcState > 4) |
79 | { |
79 | { |
80 | // WinkelOut.CalcState = 0; // in Uart.c |
80 | // WinkelOut.CalcState = 0; // in Uart.c |
81 | beeptime = 1000; |
81 | beeptime = 1000; |
82 | } |
82 | } |
83 | else Piep(WinkelOut.CalcState,150); |
83 | else Piep(WinkelOut.CalcState,150); |
84 | } |
84 | } |
85 | } |
85 | } |
86 | 86 | ||
87 | 87 | ||
88 | void LipoDetection(unsigned char print) |
88 | void LipoDetection(unsigned char print) |
89 | { |
89 | { |
90 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
90 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
91 | unsigned int timer, cells; |
91 | unsigned int timer, cells; |
92 | if(print) printf("\n\rBatt:"); |
92 | if(print) printf("\n\rBatt:"); |
93 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
93 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
94 | { |
94 | { |
95 | timer = SetDelay(500); |
95 | timer = SetDelay(500); |
96 | if(print) while (!CheckDelay(timer)); |
96 | if(print) while (!CheckDelay(timer)); |
97 | // up to 6s LiPo, less than 2s is technical impossible |
97 | // up to 6s LiPo, less than 2s is technical impossible |
98 | for(cells = 2; cells < 7; cells++) |
98 | for(cells = 2; cells < 7; cells++) |
99 | { |
99 | { |
100 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
100 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
101 | } |
101 | } |
102 | 102 | ||
103 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
103 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
104 | if(print) |
104 | if(print) |
105 | { |
105 | { |
106 | Piep(cells, 200); |
106 | Piep(cells, 200); |
107 | printf(" %d Cells ", cells); |
107 | printf(" %d Cells ", cells); |
108 | } |
108 | } |
109 | } |
109 | } |
110 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
110 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
111 | if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
111 | if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
112 | } |
112 | } |
113 | 113 | ||
114 | //############################################################################ |
114 | //############################################################################ |
115 | //Hauptprogramm |
115 | //Hauptprogramm |
116 | int main (void) |
116 | int main (void) |
117 | //############################################################################ |
117 | //############################################################################ |
118 | { |
118 | { |
119 | unsigned int timer,i,timer2 = 0, timerPolling; |
119 | unsigned int timer,i,timer2 = 0, timerPolling; |
120 | unsigned char update_spi = 1; |
120 | unsigned char update_spi = 1; |
121 | DDRB = 0x00; |
121 | DDRB = 0x00; |
122 | PORTB = 0x00; |
122 | PORTB = 0x00; |
123 | DDRD = 0x0A; // UART & J3 J4 J5 |
123 | DDRD = 0x0A; // UART & J3 J4 J5 |
124 | PORTD = 0x5F; // PPM-Input & UART |
124 | PORTD = 0x5F; // PPM-Input & UART |
125 | for(timer = 0; timer < 1000; timer++); // verzögern |
125 | for(timer = 0; timer < 1000; timer++); // verzögern |
126 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
126 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
127 | unsigned char AccZ_ErrorCnt = 0; |
127 | unsigned char AccZ_ErrorCnt = 0; |
128 | if(PINB & 0x02) |
128 | if(PINB & 0x02) |
129 | { |
129 | { |
130 | if(PIND & 0x10) PlatinenVersion = 21; // No Bridge from J4 to GND |
130 | if(PIND & 0x10) PlatinenVersion = 21; // No Bridge from J4 to GND |
131 | else { PlatinenVersion = 22; ACC_AltitudeControl = 1;}; |
131 | else { PlatinenVersion = 22; ACC_AltitudeControl = 1;}; |
132 | } |
132 | } |
133 | else |
133 | else |
134 | { |
134 | { |
135 | PlatinenVersion = 23; ACC_AltitudeControl = 1; |
135 | PlatinenVersion = 23; ACC_AltitudeControl = 1; |
136 | } |
136 | } |
137 | #else |
137 | #else |
138 | if(PINB & 0x01) |
138 | if(PINB & 0x01) |
139 | { |
139 | { |
140 | if(PINB & 0x02) PlatinenVersion = 13; |
140 | if(PINB & 0x02) PlatinenVersion = 13; |
141 | else PlatinenVersion = 11; |
141 | else PlatinenVersion = 11; |
142 | } |
142 | } |
143 | else |
143 | else |
144 | { |
144 | { |
145 | if(PINB & 0x02) PlatinenVersion = 20; |
145 | if(PINB & 0x02) PlatinenVersion = 20; |
146 | else |
146 | else |
147 | { |
147 | { |
148 | PlatinenVersion = 10; |
148 | PlatinenVersion = 10; |
149 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
149 | DDRD = 0x3E; // Speaker & TXD & J3 J4 J5 |
150 | PORTD = 0x47; // |
150 | PORTD = 0x47; // |
151 | } |
151 | } |
152 | } |
152 | } |
153 | #endif |
153 | #endif |
154 | 154 | ||
155 | DDRC = 0x81; // I2C, Spaker |
155 | DDRC = 0x81; // I2C, Spaker |
156 | DDRC |=0x40; // HEF4017 Reset |
156 | DDRC |=0x40; // HEF4017 Reset |
157 | PORTC = 0xff; // Pullup SDA |
157 | PORTC = 0xff; // Pullup SDA |
158 | DDRB = 0x1B; // LEDs und Druckoffset |
158 | DDRB = 0x1B; // LEDs und Druckoffset |
159 | PORTB = 0x01; // LED_Rot |
159 | PORTB = 0x01; // LED_Rot |
160 | 160 | ||
161 | HEF4017Reset_ON; |
161 | HEF4017Reset_ON; |
162 | MCUSR &=~(1<<WDRF); |
162 | MCUSR &=~(1<<WDRF); |
163 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
163 | WDTCSR |= (1<<WDCE)|(1<<WDE); |
164 | WDTCSR = 0; |
164 | WDTCSR = 0; |
165 | 165 | ||
166 | beeptime = 2500; |
166 | beeptime = 2500; |
167 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
167 | StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0; |
168 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
168 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
169 | ROT_OFF; |
169 | ROT_OFF; |
170 | GRN_ON; |
170 | GRN_ON; |
171 | 171 | ||
172 | Timer_Init(); |
172 | Timer_Init(); |
173 | TIMER2_Init(); |
173 | TIMER2_Init(); |
174 | UART_Init(); |
174 | UART_Init(); |
175 | rc_sum_init(); |
175 | rc_sum_init(); |
176 | ADC_Init(); |
176 | ADC_Init(); |
177 | I2C_Init(1); |
177 | I2C_Init(1); |
178 | SPI_MasterInit(); |
178 | SPI_MasterInit(); |
179 | Capacity_Init(); |
179 | Capacity_Init(); |
180 | LIBFC_Init(LIB_FC_COMPATIBLE); |
180 | LIBFC_Init(LIB_FC_COMPATIBLE); |
181 | GRN_ON; |
181 | GRN_ON; |
182 | sei(); |
182 | sei(); |
183 | ParamSet_Init(); |
183 | ParamSet_Init(); |
184 | 184 | ||
185 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
185 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
186 | // + Check connected BL-Ctrls |
186 | // + Check connected BL-Ctrls |
187 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
187 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
188 | // Check connected BL-Ctrls |
188 | // Check connected BL-Ctrls |
189 | BLFlags |= BLFLAG_READ_VERSION; |
189 | BLFlags |= BLFLAG_READ_VERSION; |
190 | motor_read = 0; // read the first I2C-Data |
190 | motor_read = 0; // read the first I2C-Data |
191 | SendMotorData(); |
191 | SendMotorData(); |
192 | timer = SetDelay(500); |
192 | timer = SetDelay(500); |
193 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
193 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
194 | 194 | ||
195 | printf("\n\rFound BL-Ctrl: "); |
195 | printf("\n\rFound BL-Ctrl: "); |
196 | timer = SetDelay(4000); |
196 | timer = SetDelay(4000); |
197 | for(i=0; i < MAX_MOTORS; i++) |
197 | for(i=0; i < MAX_MOTORS; i++) |
198 | { |
198 | { |
199 | SendMotorData(); |
199 | SendMotorData(); |
200 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
200 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
201 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
201 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
202 | { |
202 | { |
203 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
203 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
204 | { |
204 | { |
205 | SendMotorData(); |
205 | SendMotorData(); |
206 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
206 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
207 | } |
207 | } |
208 | } |
208 | } |
209 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
209 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
210 | { |
210 | { |
211 | printf("%d",i+1); |
211 | printf("%d",i+1); |
212 | FoundMotors++; |
212 | FoundMotors++; |
213 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
213 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
214 | } |
214 | } |
215 | } |
215 | } |
216 | for(i=0; i < MAX_MOTORS; i++) |
216 | for(i=0; i < MAX_MOTORS; i++) |
217 | { |
217 | { |
218 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
218 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
219 | { |
219 | { |
220 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
220 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
221 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
221 | ServoActive = 2; // just in case the FC would be used as camera-stabilizer |
222 | } |
222 | } |
223 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
223 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
224 | } |
224 | } |
225 | PrintLine();// ("\n\r==================================="); |
225 | PrintLine();// ("\n\r==================================="); |
226 | 226 | ||
227 | 227 | ||
228 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
228 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER; |
229 | 229 | ||
230 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
230 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
231 | { |
231 | { |
232 | printf("\n\rCalibrating pressure sensor.."); |
232 | printf("\n\rCalibrating pressure sensor.."); |
233 | timer = SetDelay(1000); |
233 | timer = SetDelay(1000); |
234 | SucheLuftruckOffset(); |
234 | SucheLuftruckOffset(); |
235 | while (!CheckDelay(timer)); |
235 | while (!CheckDelay(timer)); |
236 | printf("OK\n\r"); |
236 | printf("OK\n\r"); |
237 | } |
237 | } |
238 | 238 | ||
239 | SetNeutral(0); |
239 | SetNeutral(0); |
240 | 240 | ||
241 | ROT_OFF; |
241 | ROT_OFF; |
242 | 242 | ||
243 | beeptime = 2000; |
243 | beeptime = 2000; |
244 | ExternControl.Digital[0] = 0x55; |
244 | ExternControl.Digital[0] = 0x55; |
245 | 245 | ||
246 | 246 | ||
247 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
247 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
248 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
248 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
249 | 249 | ||
250 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
250 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
251 | { |
251 | { |
252 | FlugMinuten = 0; |
252 | FlugMinuten = 0; |
253 | FlugMinutenGesamt = 0; |
253 | FlugMinutenGesamt = 0; |
254 | } |
254 | } |
255 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
255 | printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt); |
256 | LcdClear(); |
256 | LcdClear(); |
257 | I2CTimeout = 5000; |
257 | I2CTimeout = 5000; |
258 | WinkelOut.Orientation = 1; |
258 | WinkelOut.Orientation = 1; |
259 | LipoDetection(1); |
259 | LipoDetection(1); |
260 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
260 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
261 | PrintLine();// ("\n\r==================================="); |
261 | PrintLine();// ("\n\r==================================="); |
262 | //SpektrumBinding(); |
262 | //SpektrumBinding(); |
263 | timer = SetDelay(2000); |
263 | timer = SetDelay(2000); |
264 | timerPolling = SetDelay(250); |
264 | timerPolling = SetDelay(250); |
265 | 265 | ||
266 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
266 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
267 | //printf("\n\rEE_Parameter size:%i\n\r", PARAMSET_STRUCT_LEN); |
267 | //printf("\n\rEE_Parameter size:%i\n\r", PARAMSET_STRUCT_LEN); |
268 | 268 | ||
269 | DebugOut.Status[0] = 0x01 | 0x02; |
269 | DebugOut.Status[0] = 0x01 | 0x02; |
270 | JetiBeep = 0; |
270 | JetiBeep = 0; |
271 | if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING) DisableRcOffBeeping = 1; |
271 | if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING) DisableRcOffBeeping = 1; |
272 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
272 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
273 | while(1) |
273 | while(1) |
274 | { |
274 | { |
275 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
275 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
276 | //GRN_ON; |
276 | //GRN_ON; |
277 | if(UpdateMotor && AdReady) // ReglerIntervall |
277 | if(UpdateMotor && AdReady) // ReglerIntervall |
278 | { |
278 | { |
279 | //GRN_OFF; |
279 | //GRN_OFF; |
280 | UpdateMotor=0; |
280 | UpdateMotor=0; |
281 | if(WinkelOut.CalcState) CalMk3Mag(); |
281 | if(WinkelOut.CalcState) CalMk3Mag(); |
282 | else MotorRegler(); |
282 | else MotorRegler(); |
283 | SendMotorData(); |
283 | SendMotorData(); |
284 | ROT_OFF; |
284 | ROT_OFF; |
285 | if(SenderOkay) { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ } |
285 | if(SenderOkay) { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ } |
286 | else |
286 | else |
287 | { |
287 | { |
288 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
288 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
289 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
289 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
290 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
290 | VersionInfo.HardwareError[1] |= FC_ERROR1_PPM; |
291 | } |
291 | } |
292 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
292 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
293 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
293 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
294 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
294 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
295 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
295 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
296 | if(!--I2CTimeout || MissingMotor) |
296 | if(!--I2CTimeout || MissingMotor) |
297 | { |
297 | { |
298 | if(!I2CTimeout) |
298 | if(!I2CTimeout) |
299 | { |
299 | { |
300 | I2C_Reset(); |
300 | I2C_Reset(); |
301 | I2CTimeout = 5; |
301 | I2CTimeout = 5; |
302 | DebugOut.Analog[28]++; // I2C-Error |
302 | DebugOut.Analog[28]++; // I2C-Error |
303 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
303 | VersionInfo.HardwareError[1] |= FC_ERROR1_I2C; |
304 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
304 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
305 | } |
305 | } |
306 | if((BeepMuster == 0xffff) && MotorenEin) |
306 | if((BeepMuster == 0xffff) && MotorenEin) |
307 | { |
307 | { |
308 | beeptime = 25000; |
308 | beeptime = 25000; |
309 | BeepMuster = 0x0080; |
309 | BeepMuster = 0x0080; |
310 | } |
310 | } |
311 | } |
311 | } |
312 | else |
312 | else |
313 | { |
313 | { |
314 | ROT_OFF; |
314 | ROT_OFF; |
315 | } |
315 | } |
316 | LIBFC_Polling(); |
316 | LIBFC_Polling(); |
317 | 317 | ||
318 | if(!UpdateMotor) |
318 | if(!UpdateMotor) |
319 | { |
319 | { |
320 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
320 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
321 | if(NewSBusData) ProcessSBus(); |
321 | if(NewSBusData) ProcessSBus(); |
322 | else |
322 | else |
323 | #endif |
323 | #endif |
324 | { |
324 | { |
325 | if(CalculateServoSignals) CalculateServo(); |
325 | if(CalculateServoSignals) CalculateServo(); |
326 | DatenUebertragung(); |
326 | DatenUebertragung(); |
327 | BearbeiteRxDaten(); |
327 | BearbeiteRxDaten(); |
328 | if(CheckDelay(timer)) |
328 | if(CheckDelay(timer)) |
329 | { |
329 | { |
330 | static unsigned char second; |
330 | static unsigned char second; |
331 | timer += 20; // 20 ms interval |
331 | timer += 20; // 20 ms interval |
332 | CalcNickServoValue(); |
332 | CalcNickServoValue(); |
333 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
333 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
334 | if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu(); |
334 | if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu(); |
335 | else |
335 | else |
336 | if(EE_Parameter.Receiver == RECEIVER_JETI) BuildJeti_Vario(); |
336 | if(EE_Parameter.Receiver == RECEIVER_JETI) BuildJeti_Vario(); |
337 | // ++++++++++++++++++++++++++++ |
337 | // ++++++++++++++++++++++++++++ |
338 | // + check the ACC-Z range |
338 | // + check the ACC-Z range |
339 | if(ACC_AltitudeControl && ((Aktuell_az < 300) || (DebugOut.Analog[7] < (128 * 4) && Aktuell_az > 850))) // DebugOut.Analog[7] = GasMischanteil |
339 | if(ACC_AltitudeControl && ((Aktuell_az < 300) || (DebugOut.Analog[7] < (128 * 4) && Aktuell_az > 850))) // DebugOut.Analog[7] = GasMischanteil |
340 | { |
340 | { |
341 | if(++AccZ_ErrorCnt > 50) |
341 | if(++AccZ_ErrorCnt > 50) |
342 | { |
342 | { |
343 | if(MotorenEin) VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_TOP; |
343 | if(MotorenEin) VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_TOP; |
344 | else CalibrationDone = 0; |
344 | else CalibrationDone = 0; |
345 | } |
345 | } |
346 | } |
346 | } |
347 | else AccZ_ErrorCnt = 0; |
347 | else AccZ_ErrorCnt = 0; |
348 | // ++++++++++++++++++++++++++++ |
348 | // ++++++++++++++++++++++++++++ |
349 | #endif |
349 | #endif |
350 | if(MissingMotor) |
350 | if(MissingMotor) |
351 | { |
351 | { |
352 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
352 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
353 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
353 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
354 | } |
354 | } |
355 | else |
355 | else |
356 | { |
356 | { |
357 | if(!beeptime) |
357 | if(!beeptime) |
358 | { |
358 | { |
359 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
359 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
360 | } |
360 | } |
361 | } |
361 | } |
362 | if(DisableRcOffBeeping) if(SenderOkay > 150) { DisableRcOffBeeping = 0; beeptime = 5000;}; |
362 | if(DisableRcOffBeeping) if(SenderOkay > 150) { DisableRcOffBeeping = 0; beeptime = 5000;}; |
363 | if(PcZugriff) PcZugriff--; |
363 | if(PcZugriff) PcZugriff--; |
364 | else |
364 | else |
365 | { |
365 | { |
366 | ExternControl.Config = 0; |
366 | ExternControl.Config = 0; |
367 | ExternStickNick = 0; |
367 | ExternStickNick = 0; |
368 | ExternStickRoll = 0; |
368 | ExternStickRoll = 0; |
369 | ExternStickGier = 0; |
369 | ExternStickGier = 0; |
370 | if(!SenderOkay) |
370 | if(!SenderOkay) |
371 | { |
371 | { |
372 | if(BeepMuster == 0xffff && DisableRcOffBeeping != 2) |
372 | if(BeepMuster == 0xffff && DisableRcOffBeeping != 2) |
373 | { |
373 | { |
374 | beeptime = 15000; |
374 | beeptime = 15000; |
375 | BeepMuster = 0x0c00; |
375 | BeepMuster = 0x0c00; |
376 | if(DisableRcOffBeeping) DisableRcOffBeeping = 2; |
376 | if(DisableRcOffBeeping) DisableRcOffBeeping = 2; |
377 | } |
377 | } |
378 | } |
378 | } |
379 | } |
379 | } |
380 | if(NaviDataOkay > 200) |
380 | if(NaviDataOkay > 200) |
381 | { |
381 | { |
382 | NaviDataOkay--; |
382 | NaviDataOkay--; |
383 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
383 | VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX; |
384 | VersionInfo.Flags |= FC_VERSION_FLAG_NC_PRESENT; |
384 | VersionInfo.Flags |= FC_VERSION_FLAG_NC_PRESENT; |
385 | } |
385 | } |
386 | else |
386 | else |
387 | { |
387 | { |
388 | if(NC_Version.Compatible) |
388 | if(NC_Version.Compatible) |
389 | { |
389 | { |
390 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
390 | VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX; |
391 | NC_ErrorCode = 9; // "ERR: no NC communication" |
391 | NC_ErrorCode = 9; // "ERR: no NC communication" |
392 | if(BeepMuster == 0xffff && MotorenEin) |
392 | if(BeepMuster == 0xffff && MotorenEin) |
393 | { |
393 | { |
394 | beeptime = 15000; |
394 | beeptime = 15000; |
395 | BeepMuster = 0xA800; |
395 | BeepMuster = 0xA800; |
396 | } |
396 | } |
397 | } |
397 | } |
398 | GPS_Nick = 0; |
398 | GPS_Nick = 0; |
399 | GPS_Roll = 0; |
399 | GPS_Roll = 0; |
400 | GPS_Aid_StickMultiplikator = 0; |
400 | GPS_Aid_StickMultiplikator = 0; |
401 | GPSInfo.Flags = 0; |
401 | GPSInfo.Flags = 0; |
402 | FromNaviCtrl.AccErrorN = 0; |
402 | FromNaviCtrl.AccErrorN = 0; |
403 | FromNaviCtrl.AccErrorR = 0; |
403 | FromNaviCtrl.AccErrorR = 0; |
404 | FromNaviCtrl.CompassValue = -1; |
404 | FromNaviCtrl.CompassValue = -1; |
405 | FromNC_AltitudeSpeed = 0; |
405 | FromNC_AltitudeSpeed = 0; |
406 | FromNC_AltitudeSetpoint = 0; |
406 | FromNC_AltitudeSetpoint = 0; |
407 | VersionInfo.Flags &= ~FC_VERSION_FLAG_NC_PRESENT; |
407 | VersionInfo.Flags &= ~FC_VERSION_FLAG_NC_PRESENT; |
408 | NaviDataOkay = 0; |
408 | NaviDataOkay = 0; |
409 | } |
409 | } |
410 | if(UBat < BattLowVoltageWarning) |
410 | if(UBat < BattLowVoltageWarning) |
411 | { |
411 | { |
412 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
412 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
413 | if(BeepMuster == 0xffff) |
413 | if(BeepMuster == 0xffff) |
414 | { |
414 | { |
415 | beeptime = 6000; |
415 | beeptime = 6000; |
416 | BeepMuster = 0x0300; |
416 | BeepMuster = 0x0300; |
417 | } |
417 | } |
418 | } |
418 | } |
419 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
419 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
420 | SendSPI = SPI_BYTEGAP; |
420 | SendSPI = SPI_BYTEGAP; |
421 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
421 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
422 | // +++++++++++++++++++++++++++++++++ |
422 | // +++++++++++++++++++++++++++++++++ |
423 | // Sekundentakt |
423 | // Sekundentakt |
424 | if(++second == 49) |
424 | if(++second == 49) |
425 | { |
425 | { |
426 | second = 0; |
426 | second = 0; |
- | 427 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
|
427 | if(ShowSettingNameTime) ShowSettingNameTime--; |
428 | if(ShowSettingNameTime) ShowSettingNameTime--; |
- | 429 | #endif |
|
428 | if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++; |
430 | if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++; |
429 | else timer2 = 1450; // 0,5 Minuten aufrunden |
431 | else timer2 = 1450; // 0,5 Minuten aufrunden |
430 | if(modell_fliegt < 1024) |
432 | if(modell_fliegt < 1024) |
431 | { |
433 | { |
432 | if(StartLuftdruck < Luftdruck) StartLuftdruck += 5; |
434 | if(StartLuftdruck < Luftdruck) StartLuftdruck += 5; |
433 | else |
435 | else |
434 | if(StartLuftdruck > Luftdruck) StartLuftdruck -= 5; |
436 | if(StartLuftdruck > Luftdruck) StartLuftdruck -= 5; |
435 | } |
437 | } |
436 | } |
438 | } |
437 | // +++++++++++++++++++++++++++++++++ |
439 | // +++++++++++++++++++++++++++++++++ |
438 | if(++timer2 == 2930) // eine Minute |
440 | if(++timer2 == 2930) // eine Minute |
439 | { |
441 | { |
440 | timer2 = 0; |
442 | timer2 = 0; |
441 | FlugMinuten++; |
443 | FlugMinuten++; |
442 | FlugMinutenGesamt++; |
444 | FlugMinutenGesamt++; |
443 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
445 | SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256); |
444 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
446 | SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256); |
445 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
447 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256); |
446 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
448 | SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256); |
447 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
449 | timer = SetDelay(20); // falls "timer += 20;" mal nicht geht |
448 | } |
450 | } |
449 | } |
451 | } |
450 | LED_Update(); |
452 | LED_Update(); |
451 | Capacity_Update(); |
453 | Capacity_Update(); |
452 | } //else DebugOut.Analog[26]++; |
454 | } //else DebugOut.Analog[26]++; |
453 | } |
455 | } |
454 | if(update_spi) update_spi--; |
456 | if(update_spi) update_spi--; |
455 | } // 500Hz |
457 | } // 500Hz |
456 | if(update_spi == 0) { SPI_StartTransmitPacket(); update_spi = 12;} // 41Hz |
458 | if(update_spi == 0) { SPI_StartTransmitPacket(); update_spi = 12;} // 41Hz |
457 | else if(!SendSPI) { SPI_TransmitByte(); } |
459 | else if(!SendSPI) { SPI_TransmitByte(); } |
458 | } |
460 | } |
459 | } |
461 | } |
460 | //DebugOut.Analog[16] |
462 | //DebugOut.Analog[16] |
461 | 463 | ||
462 | 464 |