Subversion Repositories FlightCtrl

Rev

Rev 2093 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2093 Rev 2165
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 SendVersionToNavi = 1;
56
unsigned char SendVersionToNavi = 1;
57
unsigned char BattLowVoltageWarning = 94;
57
unsigned char BattLowVoltageWarning = 94;
58
unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0;
58
unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0;
59
unsigned int FlugSekunden = 0;
59
unsigned int FlugSekunden = 0;
60
pVoidFnct_pVoidFnctChar_const_fmt _printf_P;
60
pVoidFnct_pVoidFnctChar_const_fmt _printf_P;
61
unsigned char FoundMotors = 0;
61
unsigned char FoundMotors = 0;
62
unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box
62
unsigned char JetiBeep = 0; // to allow any Morse-Beeping of the Jeti-Box
63
 
63
 
64
unsigned char metrotest;
64
unsigned char metrotest;
65
void PrintLine(void)
65
void PrintLine(void)
66
{
66
{
67
 printf("\n\r===================================");
67
 printf("\n\r===================================");
68
}
68
}
69
 
69
 
70
static char panodelay = 0; ///martinw
70
static char panodelay = 0; ///martinw
71
//static char panoleddelay = 0; ///martinw
71
//static char panoleddelay = 0; ///martinw
72
 
72
 
73
void CalMk3Mag(void)
73
void CalMk3Mag(void)
74
{
74
{
75
 static unsigned char stick = 1;
75
 static unsigned char stick = 1;
76
 if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
76
 if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
77
 if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick)
77
 if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick)
78
  {
78
  {
79
   stick = 1;
79
   stick = 1;
80
   WinkelOut.CalcState++;
80
   WinkelOut.CalcState++;
81
   if(WinkelOut.CalcState > 4)
81
   if(WinkelOut.CalcState > 4)
82
    {
82
    {
83
//     WinkelOut.CalcState = 0; // in Uart.c
83
//     WinkelOut.CalcState = 0; // in Uart.c
84
     beeptime = 1000;
84
     beeptime = 1000;
85
    }
85
    }
86
   else Piep(WinkelOut.CalcState,150);
86
   else Piep(WinkelOut.CalcState,150);
87
  }
87
  }
88
  DebugOut.Analog[19] = WinkelOut.CalcState;
88
  //DebugOut.Analog[19] = WinkelOut.CalcState; // MartinR wird in fc.c verwendet
89
}
89
}
90
 
90
 
91
 
91
 
92
void LipoDetection(unsigned char print)
92
void LipoDetection(unsigned char print)
93
{
93
{
94
        #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO
94
        #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO
95
        unsigned int timer, cells;
95
        unsigned int timer, cells;
96
        if(print) printf("\n\rBatt:");
96
        if(print) printf("\n\rBatt:");
97
        if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung
97
        if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung
98
        {
98
        {
99
                timer = SetDelay(500);
99
                timer = SetDelay(500);
100
                if(print) while (!CheckDelay(timer));
100
                if(print) while (!CheckDelay(timer));
101
                // up to 6s LiPo, less than 2s is technical impossible
101
                // up to 6s LiPo, less than 2s is technical impossible
102
                for(cells = 2; cells < 7; cells++)
102
                for(cells = 2; cells < 7; cells++)
103
                {
103
                {
104
                        if(UBat < cells * MAX_CELL_VOLTAGE) break;
104
                        if(UBat < cells * MAX_CELL_VOLTAGE) break;
105
                }
105
                }
106
 
106
 
107
                BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung;
107
                BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung;
108
                if(print)
108
                if(print)
109
                {
109
                {
110
                        Piep(cells, 200);
110
                        Piep(cells, 200);
111
                        printf(" %d Cells ", cells);
111
                        printf(" %d Cells ", cells);
112
                }
112
                }
113
        }
113
        }
114
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
114
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
115
        //if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
115
        //if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
116
        if(print) printf("Low Batt level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); /// Martinw; removed memorysaving
116
        if(print) printf("Low Batt level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); /// Martinw; removed memorysaving
117
}
117
}
118
 
118
 
119
//############################################################################
119
//############################################################################
120
//Hauptprogramm
120
//Hauptprogramm
121
int main (void)
121
int main (void)
122
//############################################################################
122
//############################################################################
123
{
123
{
124
        unsigned int timer,i,timer2 = 0, timerPolling;
124
        unsigned int timer,i,timer2 = 0, timerPolling;
125
 
125
 
126
    DDRB  = 0x00;
126
    DDRB  = 0x00;
127
    PORTB = 0x00;
127
    PORTB = 0x00;
128
    for(timer = 0; timer < 1000; timer++); // verzögern
128
    for(timer = 0; timer < 1000; timer++); // verzögern
129
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
129
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
130
        PlatinenVersion = 21;
130
        PlatinenVersion = 21;
131
#else
131
#else
132
        if(PINB & 0x01)
132
        if(PINB & 0x01)
133
     {
133
     {
134
      if(PINB & 0x02) PlatinenVersion = 13;
134
      if(PINB & 0x02) PlatinenVersion = 13;
135
       else           PlatinenVersion = 11;
135
       else           PlatinenVersion = 11;
136
     }
136
     }
137
    else
137
    else
138
     {
138
     {
139
      if(PINB & 0x02) PlatinenVersion = 20;
139
      if(PINB & 0x02) PlatinenVersion = 20;
140
       else           PlatinenVersion = 10;
140
       else           PlatinenVersion = 10;
141
     }
141
     }
142
#endif
142
#endif
143
    DDRC  = 0x81; // SCL
143
    DDRC  = 0x81; // SCL
144
    DDRC  |=0x40; // HEF4017 Reset
144
    DDRC  |=0x40; // HEF4017 Reset
145
    PORTC = 0xff; // Pullup SDA
145
    PORTC = 0xff; // Pullup SDA
146
    DDRB  = 0x1B; // LEDs und Druckoffset
146
    DDRB  = 0x1B; // LEDs und Druckoffset
147
    PORTB = 0x01; // LED_Rot
147
    PORTB = 0x01; // LED_Rot
148
    DDRD  = 0x3E; // Speaker & TXD & J3 J4 J5
148
    DDRD  = 0x3E; // Speaker & TXD & J3 J4 J5
149
        PORTD = 0x47; // LED
149
        PORTD = 0x47; // LED
150
    HEF4017R_ON;
150
    HEF4017R_ON;
151
    MCUSR &=~(1<<WDRF);
151
    MCUSR &=~(1<<WDRF);
152
    WDTCSR |= (1<<WDCE)|(1<<WDE);
152
    WDTCSR |= (1<<WDCE)|(1<<WDE);
153
    WDTCSR = 0;
153
    WDTCSR = 0;
154
 
154
 
155
    beeptime = 2500;
155
    beeptime = 2500;
156
        StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0;
156
        StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0;
157
    if(PlatinenVersion >= 20)  GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC
157
    if(PlatinenVersion >= 20)  GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC
158
    ROT_OFF;
158
    ROT_OFF;
159
 
159
 
160
    Timer_Init();
160
    Timer_Init();
161
        TIMER2_Init();
161
        TIMER2_Init();
162
        UART_Init();
162
        UART_Init();
163
    rc_sum_init();
163
    rc_sum_init();
164
        ADC_Init();
164
        ADC_Init();
165
        I2C_Init(1);
165
        I2C_Init(1);
166
        SPI_MasterInit();
166
        SPI_MasterInit();
167
        //Capacity_Init(); //Moved by metro
167
        //Capacity_Init(); //Moved by metro
168
        LIBFC_Init();
168
        LIBFC_Init();
169
        GRN_ON;
169
        GRN_ON;
170
    sei();
170
    sei();
171
        ParamSet_Init();
171
        ParamSet_Init();
172
    Capacity_Init(); //Moved by metro
172
    Capacity_Init(); //Moved by metro
173
 
173
 
174
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175
// + Check connected BL-Ctrls
175
// + Check connected BL-Ctrls
176
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
176
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177
        // Check connected BL-Ctrls
177
        // Check connected BL-Ctrls
178
        BLFlags |= BLFLAG_READ_VERSION;
178
        BLFlags |= BLFLAG_READ_VERSION;
179
        motor_read = 0;  // read the first I2C-Data
179
        motor_read = 0;  // read the first I2C-Data
180
        SendMotorData();
180
        SendMotorData();
181
        timer = SetDelay(500);
181
        timer = SetDelay(500);
182
        while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
182
        while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
183
 
183
 
184
    printf("\n\rFound BL-Ctrl: ");
184
    printf("\n\rFound BL-Ctrl: ");
185
    timer = SetDelay(4000);
185
    timer = SetDelay(4000);
186
        for(i=0; i < MAX_MOTORS; i++)
186
        for(i=0; i < MAX_MOTORS; i++)
187
        {
187
        {
188
                SendMotorData();
188
                SendMotorData();
189
                while(!(BLFlags & BLFLAG_TX_COMPLETE)  && !CheckDelay(timer)); //wait for complete transfer
189
                while(!(BLFlags & BLFLAG_TX_COMPLETE)  && !CheckDelay(timer)); //wait for complete transfer
190
                if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up
190
                if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up
191
                {
191
                {
192
                        while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) )
192
                        while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) )
193
                        {
193
                        {
194
                                SendMotorData();
194
                                SendMotorData();
195
                                while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
195
                                while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
196
                        }
196
                        }
197
                }
197
                }
198
                if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
198
                if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
199
                {
199
                {
200
                        printf("%d",i+1);
200
                        printf("%d",i+1);
201
                        FoundMotors++;
201
                        FoundMotors++;
202
//                      if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) ");
202
//                      if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) ");
203
                }
203
                }
204
        }
204
        }
205
        for(i=0; i < MAX_MOTORS; i++)
205
        for(i=0; i < MAX_MOTORS; i++)
206
        {
206
        {
207
                if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0)
207
                if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0)
208
                {
208
                {
209
                        printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1);
209
                        printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1);
210
                        ServoActive = 2; // just in case the FC would be used as camera-stabilizer
210
                        ServoActive = 2; // just in case the FC would be used as camera-stabilizer
211
                }
211
                }
212
                Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
212
                Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
213
        }
213
        }
214
   PrintLine();// ("\n\r===================================");
214
   PrintLine();// ("\n\r===================================");
215
 
215
 
216
 
216
 
217
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
217
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
218
 
218
 
219
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
219
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
220
        {
220
        {
221
                //printf("\n\rCalibrating pressure sensor..");
221
                //printf("\n\rCalibrating pressure sensor..");
222
                printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving
222
                printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving
223
                timer = SetDelay(1000);
223
                timer = SetDelay(1000);
224
                SucheLuftruckOffset();
224
                SucheLuftruckOffset();
225
                while (!CheckDelay(timer));
225
                while (!CheckDelay(timer));
226
                printf("OK\n\r");
226
                printf("OK\n\r");
227
        }
227
        }
228
 
228
 
229
        SetNeutral(0);
229
        SetNeutral(0);
230
 
230
 
231
        ROT_OFF;
231
        ROT_OFF;
232
 
232
 
233
    beeptime = 2000;
233
    beeptime = 2000;
234
    ExternControl.Digital[0] = 0x55;
234
    ExternControl.Digital[0] = 0x55;
235
 
235
 
236
 
236
 
237
        FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1);
237
        FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1);
238
        FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1);
238
        FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1);
239
 
239
 
240
        if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF))
240
        if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF))
241
        {
241
        {
242
                FlugMinuten = 0;
242
                FlugMinuten = 0;
243
                FlugMinutenGesamt = 0;
243
                FlugMinutenGesamt = 0;
244
        }
244
        }
245
    printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt);
245
    printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt);
246
 
246
 
247
#ifdef WITH_MKTOOL_Display                      // MartinW; for no MKT Display main.h
247
#ifdef WITH_MKTOOL_Display                      // MartinW; for no MKT Display main.h
248
#warning : "### with MKTool Display ###"
248
#warning : "### with MKTool Display ###"
249
    LcdClear();
249
    LcdClear();
250
        #endif
250
        #endif
251
 
251
 
252
    I2CTimeout = 5000;
252
    I2CTimeout = 5000;
253
    WinkelOut.Orientation = 1;
253
    WinkelOut.Orientation = 1;
254
    LipoDetection(1);
254
    LipoDetection(1);
255
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
255
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
256
    PrintLine();// ("\n\r===================================");
256
    PrintLine();// ("\n\r===================================");
257
        //SpektrumBinding();
257
        //SpektrumBinding();
258
    timer = SetDelay(2000);
258
    timer = SetDelay(2000);
259
        timerPolling = SetDelay(250);
259
        timerPolling = SetDelay(250);
260
 
260
 
261
        Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt);   // Note: this won't waste flash memory, if #DEBUG is not active
261
        Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt);   // Note: this won't waste flash memory, if #DEBUG is not active
262
    DebugOut.Status[0] = 0x01 | 0x02;
262
    DebugOut.Status[0] = 0x01 | 0x02;
263
        JetiBeep = 0;
263
        JetiBeep = 0;
264
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
264
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
265
 
265
 
266
//#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))      ///MartinW; only for 1284er
266
//#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))      ///MartinW; only for 1284er
267
//#warning : "### with Sponsored Message ###"
267
//#warning : "### with Sponsored Message ###"
268
    // printf("\n\rJETI+ / HoTT+ Version sponsored by Flyinghigh.ch, progammed by metro, MartinW\n\r");
268
    // printf("\n\rJETI+ / HoTT+ Version sponsored by Flyinghigh.ch, progammed by metro, MartinW\n\r");
269
        printf("\n\rACC-HH Version progammed by MartinR\n\r");
269
        printf("\n\rACC-HH Version progammed by MartinR\n\r");
270
//#endif
270
//#endif
271
 
271
 
272
 
272
 
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
 
276
 
277
//GRN_ON;
277
//GRN_ON;
278
        if(UpdateMotor && AdReady)      // ReglerIntervall
278
        if(UpdateMotor && AdReady)      // ReglerIntervall
279
            {
279
            {
280
//GRN_OFF;
280
//GRN_OFF;
281
                        UpdateMotor=0;    
281
                        UpdateMotor=0;    
282
            if(WinkelOut.CalcState) CalMk3Mag();
282
            if(WinkelOut.CalcState) CalMk3Mag();
283
            else  MotorRegler();
283
            else  MotorRegler();
284
                        SendMotorData();
284
                        SendMotorData();
285
            ROT_OFF;
285
            ROT_OFF;
286
            if(SenderOkay)  { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ }
286
            if(SenderOkay)  { SenderOkay--; /*VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;*/ }
287
                        else
287
                        else
288
                        {
288
                        {
289
                                TIMSK1 |= _BV(ICIE1); // enable PPM-Input
289
                                TIMSK1 |= _BV(ICIE1); // enable PPM-Input
290
                                PPM_in[0] = 0; // set RSSI to zero on data timeout
290
                                PPM_in[0] = 0; // set RSSI to zero on data timeout
291
                                VersionInfo.HardwareError[1] |= FC_ERROR1_PPM;
291
                                VersionInfo.HardwareError[1] |= FC_ERROR1_PPM;
292
                        }
292
                        }
293
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
293
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
294
//if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160;
294
//if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160;
295
//if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101;
295
//if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101;
296
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
296
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
297
            if(!--I2CTimeout || MissingMotor)
297
            if(!--I2CTimeout || MissingMotor)
298
                {
298
                {
299
                  if(!I2CTimeout)
299
                  if(!I2CTimeout)
300
                                   {
300
                                   {
301
                                    I2C_Reset();
301
                                    I2C_Reset();
302
                    I2CTimeout = 5;
302
                    I2CTimeout = 5;
303
                                        DebugOut.Analog[28]++; // I2C-Error
303
                                        DebugOut.Analog[28]++; // I2C-Error
304
                                        VersionInfo.HardwareError[1] |= FC_ERROR1_I2C;
304
                                        VersionInfo.HardwareError[1] |= FC_ERROR1_I2C;
305
                                        DebugOut.Status[1] |= 0x02; // BL-Error-Status
305
                                        DebugOut.Status[1] |= 0x02; // BL-Error-Status
306
                                   }
306
                                   }
307
                  if((BeepMuster == 0xffff) && MotorenEin)
307
                  if((BeepMuster == 0xffff) && MotorenEin)
308
                   {
308
                   {
309
                    beeptime = 25000;
309
                    beeptime = 25000;
310
                    BeepMuster = 0x0080;
310
                    BeepMuster = 0x0080;
311
                   }
311
                   }
312
                }
312
                }
313
            else
313
            else
314
                {
314
                {
315
                 ROT_OFF;
315
                 ROT_OFF;
316
                }
316
                }
317
                  LIBFC_Polling();
317
                  LIBFC_Polling();
318
 
318
 
319
          if(!UpdateMotor)
319
          if(!UpdateMotor)
320
                  {
320
                  {
321
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
321
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
322
                   if(NewSBusData) ProcessSBus();  
322
                   if(NewSBusData) ProcessSBus();  
323
                   else
323
                   else
324
#endif
324
#endif
325
                   {
325
                   {
326
                        if(CalculateServoSignals) CalculateServo();
326
                        if(CalculateServoSignals) CalculateServo();
327
                        DatenUebertragung();
327
                        DatenUebertragung();
328
                        BearbeiteRxDaten();
328
                        BearbeiteRxDaten();
329
                        if(CheckDelay(timer))
329
                        if(CheckDelay(timer))
330
                        {
330
                        {
331
                                static unsigned char second;
331
                                static unsigned char second;
332
                                timer += 20; // 20 ms interval
332
                                timer += 20; // 20 ms interval
333
#if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU))
333
#if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU))
334
        #warning : "### with Hottmenu ###"
334
        #warning : "### with Hottmenu ###"
335
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
335
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
336
#endif
336
#endif
337
                                if(MissingMotor)
337
                                if(MissingMotor)
338
                                 {
338
                                 {
339
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
339
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
340
                                  DebugOut.Status[1] |= 0x02; // BL-Error-Status
340
                                  DebugOut.Status[1] |= 0x02; // BL-Error-Status
341
                                 }
341
                                 }
342
                                 else
342
                                 else
343
                                 {
343
                                 {
344
                                   if(!beeptime)
344
                                   if(!beeptime)
345
                                    {
345
                                    {
346
                                     if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status
346
                                     if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status
347
                                        }
347
                                        }
348
                                 }
348
                                 }
349
                                if(DisableRcOffBeeping) if(SenderOkay > 150) { DisableRcOffBeeping = 0; beeptime = 5000;};
349
                                if(DisableRcOffBeeping) if(SenderOkay > 150) { DisableRcOffBeeping = 0; beeptime = 5000;};
350
                                if(PcZugriff) PcZugriff--;
350
                                if(PcZugriff) PcZugriff--;
351
                                else
351
                                else
352
                                {
352
                                {
353
                                        ExternControl.Config = 0;
353
                                        ExternControl.Config = 0;
354
                                        ExternStickNick = 0;
354
                                        ExternStickNick = 0;
355
                                        ExternStickRoll = 0;
355
                                        ExternStickRoll = 0;
356
                                        ExternStickGier = 0;
356
                                        ExternStickGier = 0;
357
                                        if(!SenderOkay)
357
                                        if(!SenderOkay)
358
                                        {
358
                                        {
359
                                          if(BeepMuster == 0xffff && DisableRcOffBeeping != 2)  
359
                                          if(BeepMuster == 0xffff && DisableRcOffBeeping != 2)  
360
                                          {
360
                                          {
361
                                                  beeptime = 15000;
361
                                                  beeptime = 15000;
362
                                                  BeepMuster = 0x0c00;
362
                                                  BeepMuster = 0x0c00;
363
                                                  if(DisableRcOffBeeping) DisableRcOffBeeping = 2;
363
                                                  if(DisableRcOffBeeping) DisableRcOffBeeping = 2;
364
                                          }
364
                                          }
365
                                        }
365
                                        }
366
                                }
366
                                }
367
                                if(NaviDataOkay > 200)
367
                                if(NaviDataOkay > 200)
368
                                {
368
                                {
369
                                        NaviDataOkay--;
369
                                        NaviDataOkay--;
370
                                        VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX;
370
                                        VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX;
371
                                }
371
                                }
372
                                else
372
                                else
373
                                {
373
                                {
374
                                        if(NC_Version.Compatible)
374
                                        if(NC_Version.Compatible)
375
                                         {
375
                                         {
376
                                           VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX;
376
                                           VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX;
377
                                           NC_ErrorCode = 9; // "ERR: no NC communication"
377
                                           NC_ErrorCode = 9; // "ERR: no NC communication"
378
                       if(BeepMuster == 0xffff && MotorenEin)
378
                       if(BeepMuster == 0xffff && MotorenEin)
379
                                                {
379
                                                {
380
                                                        beeptime = 15000;
380
                                                        beeptime = 15000;
381
                                                        BeepMuster = 0xA800;
381
                                                        BeepMuster = 0xA800;
382
                                                }
382
                                                }
383
                                         }
383
                                         }
384
                                        GPS_Nick = 0;
384
                                        GPS_Nick = 0;
385
                                        GPS_Roll = 0;
385
                                        GPS_Roll = 0;
386
                                        GPS_Aid_StickMultiplikator = 0;
386
                                        GPS_Aid_StickMultiplikator = 0;
387
                                        GPSInfo.Flags = 0;
387
                                        GPSInfo.Flags = 0;
388
                                        FromNaviCtrl.AccErrorN = 0;
388
                                        FromNaviCtrl.AccErrorN = 0;
389
                                        FromNaviCtrl.AccErrorR = 0;
389
                                        FromNaviCtrl.AccErrorR = 0;
390
                    FromNaviCtrl.CompassValue = -1;
390
                    FromNaviCtrl.CompassValue = -1;
391
                    NaviDataOkay = 0;
391
                    NaviDataOkay = 0;
392
                                }
392
                                }
393
                           if(UBat < BattLowVoltageWarning)
393
                           if(UBat < BattLowVoltageWarning)
394
                                {
394
                                {
395
                                        FC_StatusFlags |= FC_STATUS_LOWBAT;
395
                                        FC_StatusFlags |= FC_STATUS_LOWBAT;
396
                                        if(BeepMuster == 0xffff)
396
                                        if(BeepMuster == 0xffff)
397
                                        {
397
                                        {
398
                                                beeptime = 6000;
398
                                                beeptime = 6000;
399
                                                BeepMuster = 0x0300;
399
                                                BeepMuster = 0x0300;
400
                                        }
400
                                        }
401
                                }
401
                                }
402
                                else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT;
402
                                else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT;
403
 
403
 
404
                                SPI_StartTransmitPacket();
404
                                SPI_StartTransmitPacket();
405
                                SendSPI = 4;
405
                                SendSPI = 4;
406
                                // +++++++++++++++++++++++++++++++++
406
                                // +++++++++++++++++++++++++++++++++
407
                                // Sekundentakt
407
                                // Sekundentakt
408
                if(++second == 49)
408
                if(++second == 49)
409
                                 {
409
                                 {
410
                                   second = 0;
410
                                   second = 0;
411
                                   if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++;
411
                                   if(FC_StatusFlags & FC_STATUS_FLY) FlugSekunden++;
412
                                   else
412
                                   else
413
                                    {
413
                                    {
414
                                         timer2 = 1450; // 0,5 Minuten aufrunden
414
                                         timer2 = 1450; // 0,5 Minuten aufrunden
415
                                         if(StartLuftdruck < Luftdruck) StartLuftdruck++;
415
                                         if(StartLuftdruck < Luftdruck) StartLuftdruck++;
416
                                         else
416
                                         else
417
                                         if(StartLuftdruck > Luftdruck) StartLuftdruck--;
417
                                         if(StartLuftdruck > Luftdruck) StartLuftdruck--;
418
                                        }
418
                                        }
419
                                 }
419
                                 }
420
                                // +++++++++++++++++++++++++++++++++
420
                                // +++++++++++++++++++++++++++++++++
421
                                if(++timer2 == 2930)  // eine Minute
421
                                if(++timer2 == 2930)  // eine Minute
422
                                 {
422
                                 {
423
                                   timer2 = 0;
423
                                   timer2 = 0;
424
                   FlugMinuten++;
424
                   FlugMinuten++;
425
                       FlugMinutenGesamt++;
425
                       FlugMinutenGesamt++;
426
                   SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256);
426
                   SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256);
427
                   SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256);
427
                   SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256);
428
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
428
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
429
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
429
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
430
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
430
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
431
                             }
431
                             }
432
                        }
432
                        }
433
                       
433
                       
434
#ifdef WITH_PANOTRIGGER         ///  MartinW main.h means no memsave
434
#ifdef WITH_PANOTRIGGER         ///  MartinW main.h means no memsave
435
#warning : "### with  Panorama Trigger Function ###"
435
#warning : "### with  Panorama Trigger Function ###"
436
//// Pano Trigger
436
//// Pano Trigger
437
if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function
437
if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function
438
{
438
{
439
        if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; }
439
        if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; }
440
        degreedivold = degreediv;
440
        degreedivold = degreediv;
441
        degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division
441
        degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division
442
                       
442
                       
443
        if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1)
443
        if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1)
444
                {
444
                {
445
               
445
               
446
                if(panodelay == 0)
446
                if(panodelay == 0)
447
                        {
447
                        {
448
                        panotrigger= 1; // muss wieder geleert werden
448
                        panotrigger= 1; // muss wieder geleert werden
449
                        ROT_ON;
449
                        ROT_ON;
450
                        J16_ON;
450
                        J16_ON;
451
                        panodelay = Parameter_UserParam5;
451
                        panodelay = Parameter_UserParam5;
452
                        }
452
                        }
453
                }
453
                }
454
               
454
               
455
                else
455
                else
456
                        {
456
                        {
457
                        if(panodelay <= Parameter_UserParam6) //ms Intervall
457
                        if(panodelay <= Parameter_UserParam6) //ms Intervall
458
                                                {
458
                                                {
459
                                                //panoleddelay = Parameter_UserParam6;
459
                                                //panoleddelay = Parameter_UserParam6;
460
                                                J16_OFF;
460
                                                J16_OFF;
461
                                                ROT_OFF;
461
                                                ROT_OFF;
462
                                                }  
462
                                                }  
463
                        if(panodelay > 0)
463
                        if(panodelay > 0)
464
                                {
464
                                {
465
                                panodelay--;
465
                                panodelay--;
466
                                }
466
                                }
467
                       
467
                       
468
                        }      
468
                        }      
469
}// END if(Parameter_UserParam4 >= 1)
469
}// END if(Parameter_UserParam4 >= 1)
470
//// Pano Trigger
470
//// Pano Trigger
471
 
471
 
472
#else
472
#else
473
#warning : "### without  Panorama Trigger Function ###" 
473
#warning : "### without  Panorama Trigger Function ###" 
474
 
474
 
475
#endif
475
#endif
476
                       
476
                       
477
                       
477
                       
478
                       
478
                       
479
           LED_Update();
479
           LED_Update();
480
           Capacity_Update();
480
           Capacity_Update();
481
           } //else DebugOut.Analog[26]++;
481
           } //else DebugOut.Analog[26]++;
482
          }
482
          }
483
         }
483
         }
484
         if(!SendSPI) { SPI_TransmitByte(); }
484
         if(!SendSPI) { SPI_TransmitByte(); }
485
    }
485
    }
486
 return (1);
486
 return (1);
487
}
487
}
488
//DebugOut.Analog[16]
488
//DebugOut.Analog[16]
489
 
489
 
490
 
490