Subversion Repositories FlightCtrl

Rev

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

Rev 2081 Rev 2093
Line 51... Line 51...
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 BattLowVoltageWarning = 94;
57
unsigned char BattLowVoltageWarning = 94;
57
unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0;
58
unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0;
58
unsigned int FlugSekunden = 0;
59
unsigned int FlugSekunden = 0;
59
pVoidFnct_pVoidFnctChar_const_fmt _printf_P;
60
pVoidFnct_pVoidFnctChar_const_fmt _printf_P;
60
unsigned char FoundMotors = 0;
61
unsigned char FoundMotors = 0;
61
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
Line -... Line 63...
-
 
63
 
62
 
64
unsigned char metrotest;
63
void PrintLine(void)
65
void PrintLine(void)
64
{
66
{
65
 printf("\n\r===================================");
67
 printf("\n\r===================================");
Line -... Line 68...
-
 
68
}
-
 
69
 
Line 66... Line 70...
66
}
70
static char panodelay = 0; ///martinw
67
 
71
//static char panoleddelay = 0; ///martinw
68
 
72
 
69
void CalMk3Mag(void)
73
void CalMk3Mag(void)
Line 106... Line 110...
106
                        Piep(cells, 200);
110
                        Piep(cells, 200);
107
                        printf(" %d Cells ", cells);
111
                        printf(" %d Cells ", cells);
108
                }
112
                }
109
        }
113
        }
110
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
114
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
111
        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
112
}
117
}
Line 113... Line 118...
113
 
118
 
114
//############################################################################
119
//############################################################################
115
//Hauptprogramm
120
//Hauptprogramm
Line 157... Line 162...
157
        UART_Init();
162
        UART_Init();
158
    rc_sum_init();
163
    rc_sum_init();
159
        ADC_Init();
164
        ADC_Init();
160
        I2C_Init(1);
165
        I2C_Init(1);
161
        SPI_MasterInit();
166
        SPI_MasterInit();
162
        Capacity_Init();
167
        //Capacity_Init(); //Moved by metro
163
        LIBFC_Init();
168
        LIBFC_Init();
164
        GRN_ON;
169
        GRN_ON;
165
    sei();
170
    sei();
166
        ParamSet_Init();
171
        ParamSet_Init();
167
 
-
 
-
 
172
    Capacity_Init(); //Moved by metro
Line 168... Line 173...
168
 
173
 
169
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
170
// + Check connected BL-Ctrls
175
// + Check connected BL-Ctrls
171
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
176
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 211... Line 216...
211
 
216
 
Line 212... Line 217...
212
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
217
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
213
 
218
 
214
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
219
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
-
 
220
        {
215
        {
221
                //printf("\n\rCalibrating pressure sensor..");
216
                printf("\n\rCalibrating pressure sensor..");
222
                printf("\n\rCal. pressure sensor");/// Martinw; removed memorysaving
217
                timer = SetDelay(1000);
223
                timer = SetDelay(1000);
218
                SucheLuftruckOffset();
224
                SucheLuftruckOffset();
219
                while (!CheckDelay(timer));
225
                while (!CheckDelay(timer));
Line 236... Line 242...
236
                FlugMinuten = 0;
242
                FlugMinuten = 0;
237
                FlugMinutenGesamt = 0;
243
                FlugMinutenGesamt = 0;
238
        }
244
        }
239
    printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt);
245
    printf("\n\rFlight-time %u min Total:%u min", FlugMinuten, FlugMinutenGesamt);
Line -... Line 246...
-
 
246
 
-
 
247
#ifdef WITH_MKTOOL_Display                      // MartinW; for no MKT Display main.h
240
 
248
#warning : "### with MKTool Display ###"
-
 
249
    LcdClear();
-
 
250
        #endif
241
    LcdClear();
251
 
242
    I2CTimeout = 5000;
252
    I2CTimeout = 5000;
243
    WinkelOut.Orientation = 1;
253
    WinkelOut.Orientation = 1;
244
    LipoDetection(1);
254
    LipoDetection(1);
245
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
255
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
Line 250... Line 260...
250
 
260
 
251
        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
252
    DebugOut.Status[0] = 0x01 | 0x02;
262
    DebugOut.Status[0] = 0x01 | 0x02;
253
        JetiBeep = 0;
263
        JetiBeep = 0;
-
 
264
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
-
 
265
 
-
 
266
//#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))      ///MartinW; only for 1284er
-
 
267
//#warning : "### with Sponsored Message ###"
-
 
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");
-
 
270
//#endif
-
 
271
 
254
    if(EE_Parameter.ExtraConfig & CFG_NO_RCOFF_BEEPING)   DisableRcOffBeeping = 1;
272
 
255
        while (1)
273
        while (1)
256
        {
274
        {
Line 257... Line 275...
257
        if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off
275
        if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off
Line 310... Line 328...
310
                        BearbeiteRxDaten();
328
                        BearbeiteRxDaten();
311
                        if(CheckDelay(timer))
329
                        if(CheckDelay(timer))
312
                        {
330
                        {
313
                                static unsigned char second;
331
                                static unsigned char second;
314
                                timer += 20; // 20 ms interval
332
                                timer += 20; // 20 ms interval
315
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
333
#if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU))
-
 
334
        #warning : "### with Hottmenu ###"
316
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
335
                                if(EE_Parameter.Receiver == RECEIVER_HOTT) HoTT_Menu();
317
#endif
336
#endif
318
                                if(MissingMotor)
337
                                if(MissingMotor)
319
                                 {
338
                                 {
320
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
339
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
Line 409... Line 428...
409
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
428
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
410
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
429
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
411
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
430
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
412
                             }
431
                             }
413
                        }
432
                        }
-
 
433
                       
-
 
434
#ifdef WITH_PANOTRIGGER         ///  MartinW main.h means no memsave
-
 
435
#warning : "### with  Panorama Trigger Function ###"
-
 
436
//// Pano Trigger
-
 
437
if(Parameter_UserParam8 >= 200) //enable/disable Pano Trigger Function
-
 
438
{
-
 
439
        if(Parameter_UserParam4 <=9) { Parameter_UserParam4 = 10; }
-
 
440
        degreedivold = degreediv;
-
 
441
        degreediv = (ErsatzKompass / GIER_GRAD_FAKTOR) / Parameter_UserParam4;//Division
-
 
442
                       
-
 
443
        if((degreediv-degreedivold)==2||(degreediv-degreedivold)==1||(degreediv-degreedivold)== -2||(degreediv-degreedivold)== -1)
-
 
444
                {
-
 
445
               
-
 
446
                if(panodelay == 0)
-
 
447
                        {
-
 
448
                        panotrigger= 1; // muss wieder geleert werden
-
 
449
                        ROT_ON;
-
 
450
                        J16_ON;
-
 
451
                        panodelay = Parameter_UserParam5;
-
 
452
                        }
-
 
453
                }
-
 
454
               
-
 
455
                else
-
 
456
                        {
-
 
457
                        if(panodelay <= Parameter_UserParam6) //ms Intervall
-
 
458
                                                {
-
 
459
                                                //panoleddelay = Parameter_UserParam6;
-
 
460
                                                J16_OFF;
-
 
461
                                                ROT_OFF;
-
 
462
                                                }  
-
 
463
                        if(panodelay > 0)
-
 
464
                                {
-
 
465
                                panodelay--;
-
 
466
                                }
-
 
467
                       
-
 
468
                        }      
-
 
469
}// END if(Parameter_UserParam4 >= 1)
-
 
470
//// Pano Trigger
-
 
471
 
-
 
472
#else
-
 
473
#warning : "### without  Panorama Trigger Function ###" 
-
 
474
 
-
 
475
#endif
-
 
476
                       
-
 
477
                       
-
 
478
                       
414
           LED_Update();
479
           LED_Update();
415
           Capacity_Update();
480
           Capacity_Update();
416
           } //else DebugOut.Analog[26]++;
481
           } //else DebugOut.Analog[26]++;
417
          }
482
          }
418
         }
483
         }