Subversion Repositories FlightCtrl

Rev

Rev 1994 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1994 Rev 1995
Line 58... Line 58...
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
Line -... Line 62...
-
 
62
 
-
 
63
static char panodelay = 0; ///martinw
-
 
64
//static char panoleddelay = 0; ///martinw
62
 
65
 
63
void CalMk3Mag(void)
66
void CalMk3Mag(void)
64
{
67
{
65
 static unsigned char stick = 1;
68
 static unsigned char stick = 1;
66
 if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
69
 if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
Line 100... Line 103...
100
                        Piep(cells, 200);
103
                        Piep(cells, 200);
101
                        printf(" %d Cells ", cells);
104
                        printf(" %d Cells ", cells);
102
                }
105
                }
103
        }
106
        }
104
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
107
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
105
        if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
108
        //if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
-
 
109
        if(print) printf("Low Batt level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); /// Martinw; removed memorysaving
-
 
110
 
106
}
111
}
Line 107... Line 112...
107
 
112
 
108
//############################################################################
113
//############################################################################
109
//Hauptprogramm
114
//Hauptprogramm
Line 151... Line 156...
151
        UART_Init();
156
        UART_Init();
152
    rc_sum_init();
157
    rc_sum_init();
153
        ADC_Init();
158
        ADC_Init();
154
        I2C_Init(1);
159
        I2C_Init(1);
155
        SPI_MasterInit();
160
        SPI_MasterInit();
156
        Capacity_Init();
-
 
157
        LIBFC_Init();
161
        LIBFC_Init();
158
        GRN_ON;
162
        GRN_ON;
159
    sei();
163
    sei();
160
        ParamSet_Init();
164
        ParamSet_Init();
161
 
-
 
-
 
165
    Capacity_Init(); //Moved by metro
Line 162... Line 166...
162
 
166
 
163
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
167
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
164
// + Check connected BL-Ctrls
168
// + Check connected BL-Ctrls
165
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
169
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 193... Line 197...
193
        }
197
        }
194
        for(i=0; i < MAX_MOTORS; i++)
198
        for(i=0; i < MAX_MOTORS; i++)
195
        {
199
        {
196
                if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0)
200
                if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0)
197
                {
201
                {
198
                        printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1);
202
                        //printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1);
-
 
203
                        printf("\n\r\n\r!!MISSING BL-CTRL: %d!!",i+1);/// Martinw; removed memorysaving
199
                        ServoActive = 2; // just in case the FC would be used as camera-stabilizer
204
                        ServoActive = 2; // just in case the FC would be used as camera-stabilizer
200
                }
205
                }
201
                Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
206
                Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
202
        }
207
        }
203
        printf("\n\r===================================");
208
                //printf("\n\r===================================");/// Martinw; removed memorysaving
-
 
209
                printf("\n\r=");/// Martinw; removed memorysaving
-
 
210
 
Line 204... Line 211...
204
 
211
 
Line 205... Line 212...
205
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
212
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
206
 
213
 
207
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
214
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
-
 
215
        {
208
        {
216
                //printf("\n\rCalibrating pressure sensor..");
209
                printf("\n\rCalibrating pressure sensor..");
217
                printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving
210
                timer = SetDelay(1000);
218
                timer = SetDelay(1000);
211
                SucheLuftruckOffset();
219
                SucheLuftruckOffset();
212
                while (!CheckDelay(timer));
220
                while (!CheckDelay(timer));
Line 233... Line 241...
233
 
241
 
234
        printf("\n\rControl: ");
242
        printf("\n\rControl: ");
235
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
243
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
Line -... Line 244...
-
 
244
        else printf("Normal (ACC-Mode)");
-
 
245
       
236
        else printf("Normal (ACC-Mode)");
246
#ifdef WITH_MKTOOL_Display                      // MartinW; for no MKT Display main.h
-
 
247
#warning : "### with MKTool Display ###"
-
 
248
    LcdClear();
237
 
249
        #endif
238
    LcdClear();
250
 
239
    I2CTimeout = 5000;
251
    I2CTimeout = 5000;
Line 240... Line 252...
240
    WinkelOut.Orientation = 1;
252
    WinkelOut.Orientation = 1;
Line 241... Line 253...
241
    LipoDetection(1);
253
    LipoDetection(1);
-
 
254
 
242
 
255
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
243
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
256
 
244
 
257
        //printf("\n\r===================================\n\r");
Line 245... Line 258...
245
        printf("\n\r===================================\n\r");
258
        printf("\n\r=\n\r");    /// Martinw; removed memorysaving
246
        //SpektrumBinding();
259
        //SpektrumBinding();
247
    timer = SetDelay(2000);
260
    timer = SetDelay(2000);
248
        timerPolling = SetDelay(250);
261
        timerPolling = SetDelay(250);
Line -... Line 262...
-
 
262
 
-
 
263
        Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt);   // Note: this won't waste flash memory, if #DEBUG is not active
-
 
264
    DebugOut.Status[0] = 0x01 | 0x02;
-
 
265
        JetiBeep = 0;
-
 
266
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
-
 
267
 
-
 
268
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))        ///MartinW; only for 1284er
249
 
269
//#warning : "### with Sponsored Message ###"
250
        Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt);   // Note: this won't waste flash memory, if #DEBUG is not active
270
    printf("\n\rJETI+ Version sponsored by Flyinghigh.ch, progammed by MartinW\n\r");
251
    DebugOut.Status[0] = 0x01 | 0x02;
271
#else
Line -... Line 272...
-
 
272
#endif
252
        JetiBeep = 0;
273
 
253
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
274
 
254
 
275
        while (1)
255
        while (1)
276
        {
256
        {
277
        if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off
257
        if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off
278
                               
Line 305... Line 326...
305
                        BearbeiteRxDaten();
326
                        BearbeiteRxDaten();
306
                        if(CheckDelay(timer))
327
                        if(CheckDelay(timer))
307
                        {
328
                        {
308
                                static unsigned char second;
329
                                static unsigned char second;
309
                                timer += 20; // 20 ms interval
330
                                timer += 20; // 20 ms interval
310
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
331
#if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU))
-
 
332
        #warning : "### with Hottmenu ###"
311
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
333
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
312
#endif
334
#endif
313
                                if(MissingMotor)
335
                                if(MissingMotor)
314
                                 {
336
                                 {
315
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
337
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
Line 396... Line 418...
396
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
418
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
397
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
419
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
398
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
420
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
399
                             }
421
                             }
400
                        }
422
                        }
-
 
423
                       
-
 
424
#ifdef WITH_PANOTRIGGER         ///  MartinW main.h means no memsave
-
 
425
#warning : "### with  Panorama Trigger Function ###"
-
 
426
//// Pano Trigger
-
 
427
if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function
-
 
428
{
-
 
429
        if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; }
-
 
430
        degreedivold = degreediv;
-
 
431
        degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division
-
 
432
                       
-
 
433
        if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1)
-
 
434
                {
-
 
435
               
-
 
436
                if(panodelay == 0)
-
 
437
                        {
-
 
438
                        panotrigger= 1; // muss wieder geleert werden
-
 
439
                        ROT_ON;
-
 
440
                        J16_ON;
-
 
441
                        panodelay = Parameter_UserParam5;
-
 
442
                        }
-
 
443
                }
-
 
444
               
-
 
445
                else
-
 
446
                        {
-
 
447
                        if(panodelay <= Parameter_UserParam6) //ms Intervall
-
 
448
                                                {
-
 
449
                                                //panoleddelay = Parameter_UserParam6;
-
 
450
                                                J16_OFF;
-
 
451
                                                ROT_OFF;
-
 
452
                                                }  
-
 
453
                        if(panodelay > 0)
-
 
454
                                {
-
 
455
                                panodelay--;
-
 
456
                                }
-
 
457
                       
-
 
458
                        }      
-
 
459
}// END if(Parameter_UserParam4 >= 1)
-
 
460
//// Pano Trigger
-
 
461
 
-
 
462
#else
-
 
463
#warning : "### without  Panorama Trigger Function ###" 
-
 
464
 
-
 
465
#endif
-
 
466
                       
-
 
467
                       
-
 
468
                       
401
           LED_Update();
469
           LED_Update();
402
           Capacity_Update();
470
           Capacity_Update();
403
           } //else DebugOut.Analog[26]++;
471
           } //else DebugOut.Analog[26]++;
404
          }
472
          }
405
     if(!SendSPI) { SPI_TransmitByte(); }
473
     if(!SendSPI) { SPI_TransmitByte(); }
406
    }
474
    }
407
 return (1);
475
 return (1);
408
}
476
}
409
//DebugOut.Analog[16]
-
 
-
 
477