Subversion Repositories FlightCtrl

Rev

Rev 1812 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1813 - 1
/******************************************************************************************************************
2
V0.82b-Arthur-P 2010-12-18
3
------------------------------------------------------------------------------------------------------------------
4
Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs.
5
------------------------------------------------------------------------------------------------------------------
6
Besides adding this header. The following files have been modified:
7
* main.c: Remark header added with summary of changes to other files. Also remarked out variable i from function
8
  Mittelwert as this variable is not used. No other changes.
9
* menu.c: Modifed text to show branch name in MKTool window.
10
* fc.c: Modified motor smoothing routine.
11
* timer0.c: Added several variables and modified the servo control routines to allow control to be activated
12
* through a parameter, and to allow different shutter servo control.
13
* makefile: Modified to correctly name output file to reflect branch name.
14
All changes are clearly marked similar to this change.
15
******************************************************************************************************************/
1 ingob 16
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1338 ingob 17
// + Copyright (c) Holger Buss, Ingo Busker
18
// + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY
1 ingob 19
// + www.MikroKopter.com
20
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1051 killagreg 21
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
22
// + dass eine Nutzung (auch auszugsweise) nur für den privaten und nicht-kommerziellen Gebrauch zulässig ist.
23
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
24
// + bzgl. der Nutzungsbedingungen aufzunehmen.
1 ingob 25
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
26
// + Verkauf von Luftbildaufnahmen, usw.
27
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1051 killagreg 28
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
1 ingob 29
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
30
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
32
// + auf anderen Webseiten oder Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
33
// + eindeutig als Ursprung verlinkt und genannt werden
34
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
36
// + Benutzung auf eigene Gefahr
37
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
38
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1338 ingob 39
// + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
1 ingob 40
// + mit unserer Zustimmung zulässig
41
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
43
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1051 killagreg 44
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
1 ingob 45
// + this list of conditions and the following disclaimer.
46
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
47
// +     from this software without specific prior written permission.
1051 killagreg 48
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
1 ingob 49
// +     for non-commercial use (directly or indirectly)
1051 killagreg 50
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
1 ingob 51
// +     with our written permission
1051 killagreg 52
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
53
// +     clearly linked as origin
1338 ingob 54
// +   * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed
1 ingob 55
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
56
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
59
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
60
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
61
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
62
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
63
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
64
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1051 killagreg 65
// +  POSSIBILITY OF SUCH DAMAGE.
1 ingob 66
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67
#include "main.h"
68
 
1438 ingob 69
 
173 holgerb 70
unsigned char PlatinenVersion = 10;
723 hbuss 71
unsigned char SendVersionToNavi = 1;
1232 hbuss 72
unsigned char BattLowVoltageWarning = 94;
1298 hbuss 73
unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0;
1512 holgerb 74
unsigned int FlugSekunden = 0;
1444 ingob 75
pVoidFnct_pVoidFnctChar_const_fmt _printf_P;
1702 holgerb 76
unsigned char FoundMotors = 0;
1444 ingob 77
 
819 hbuss 78
void CalMk3Mag(void)
79
{
80
 static unsigned char stick = 1;
81
 if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
82
 if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick)
83
  {
84
   stick = 1;
85
   WinkelOut.CalcState++;
1051 killagreg 86
   if(WinkelOut.CalcState > 4)
87
    {
819 hbuss 88
//     WinkelOut.CalcState = 0; // in Uart.c
89
     beeptime = 1000;
1051 killagreg 90
    }
1232 hbuss 91
   else Piep(WinkelOut.CalcState,150);
819 hbuss 92
  }
93
  DebugOut.Analog[19] = WinkelOut.CalcState;
94
}
95
 
1438 ingob 96
 
1268 hbuss 97
void LipoDetection(unsigned char print)
98
{
1654 killagreg 99
        #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO
100
        unsigned int timer, cells;
101
        if(print) printf("\n\rBatt:");
102
        if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung
103
        {
104
                timer = SetDelay(500);
105
                if(print) while (!CheckDelay(timer));
1657 killagreg 106
                // up to 6s LiPo, less than 2s is technical impossible
107
                for(cells = 2; cells < 7; cells++)
1654 killagreg 108
                {
109
                        if(UBat < cells * MAX_CELL_VOLTAGE) break;
1420 killagreg 110
                }
1654 killagreg 111
 
112
                BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung;
113
                if(print)
114
                {
115
                        Piep(cells, 200);
116
                        printf(" %d Cells ", cells);
1420 killagreg 117
                }
1654 killagreg 118
        }
119
        else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
120
        if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
1268 hbuss 121
}
122
 
1 ingob 123
//############################################################################
124
//Hauptprogramm
125
int main (void)
126
//############################################################################
127
{
1424 ingob 128
        unsigned int timer,i,timer2 = 0, timerPolling;
1479 killagreg 129
 
1051 killagreg 130
    DDRB  = 0x00;
131
    PORTB = 0x00;
188 holgerb 132
    for(timer = 0; timer < 1000; timer++); // verzögern
1660 holgerb 133
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
134
        PlatinenVersion = 21;
135
#else
136
        if(PINB & 0x01)
918 hbuss 137
     {
1051 killagreg 138
      if(PINB & 0x02) PlatinenVersion = 13;
139
       else           PlatinenVersion = 11;
918 hbuss 140
     }
1051 killagreg 141
    else
1021 hbuss 142
     {
1051 killagreg 143
      if(PINB & 0x02) PlatinenVersion = 20;
144
       else           PlatinenVersion = 10;
1021 hbuss 145
     }
1660 holgerb 146
#endif
173 holgerb 147
    DDRC  = 0x81; // SCL
1036 hbuss 148
    DDRC  |=0x40; // HEF4017 Reset
1 ingob 149
    PORTC = 0xff; // Pullup SDA
150
    DDRB  = 0x1B; // LEDs und Druckoffset
151
    PORTB = 0x01; // LED_Rot
152
    DDRD  = 0x3E; // Speaker & TXD & J3 J4 J5
1153 hbuss 153
        PORTD = 0x47; // LED
1171 hbuss 154
    HEF4017R_ON;
1 ingob 155
    MCUSR &=~(1<<WDRF);
156
    WDTCSR |= (1<<WDCE)|(1<<WDE);
157
    WDTCSR = 0;
158
 
1652 holgerb 159
    beeptime = 2500;
1660 holgerb 160
        StickGier = 0; PPM_in[K_GAS] = 0; StickRoll = 0; StickNick = 0;
161
    if(PlatinenVersion >= 20)  GIER_GRAD_FAKTOR = 1220; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC
1 ingob 162
    ROT_OFF;
1479 killagreg 163
 
1 ingob 164
    Timer_Init();
1156 hbuss 165
        TIMER2_Init();
1 ingob 166
        UART_Init();
167
    rc_sum_init();
168
        ADC_Init();
1743 holgerb 169
        I2C_Init(1);
597 ingob 170
        SPI_MasterInit();
1486 killagreg 171
        Capacity_Init();
1435 killagreg 172
        LIBFC_Init();
1431 ingob 173
        GRN_ON;
174
    sei();
1622 killagreg 175
        ParamSet_Init();
1344 hbuss 176
 
1435 killagreg 177
 
1211 hbuss 178
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179
// + Check connected BL-Ctrls
180
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1648 killagreg 181
        // Check connected BL-Ctrls
182
        BLFlags |= BLFLAG_READ_VERSION;
1662 killagreg 183
        motor_read = 0;  // read the first I2C-Data
1648 killagreg 184
        SendMotorData();
1683 killagreg 185
        timer = SetDelay(500);
186
        while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
1654 killagreg 187
 
1648 killagreg 188
    printf("\n\rFound BL-Ctrl: ");
1591 holgerb 189
    timer = SetDelay(4000);
1211 hbuss 190
        for(i=0; i < MAX_MOTORS; i++)
1622 killagreg 191
        {
192
                SendMotorData();
1683 killagreg 193
                while(!(BLFlags & BLFLAG_TX_COMPLETE)  && !CheckDelay(timer)); //wait for complete transfer
1622 killagreg 194
                if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up
195
                {
1648 killagreg 196
                        while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) )
197
                        {
198
                                SendMotorData();
1683 killagreg 199
                                while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
1648 killagreg 200
                        }
1232 hbuss 201
                }
1648 killagreg 202
                if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
203
                {
204
                        printf("%d",i+1);
1702 holgerb 205
                        FoundMotors++;
1652 holgerb 206
//                      if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) ");
1648 killagreg 207
                }
1622 killagreg 208
        }
1211 hbuss 209
        for(i=0; i < MAX_MOTORS; i++)
1051 killagreg 210
        {
1622 killagreg 211
                if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0)
212
                {
213
                        printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1);
1701 holgerb 214
                        ServoActive = 2; // just in case the FC would be used as camera-stabilizer
1111 hbuss 215
                }
1622 killagreg 216
                Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
1 ingob 217
        }
1622 killagreg 218
        printf("\n\r===================================");
1648 killagreg 219
 
1765 killagreg 220
    if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
1702 holgerb 221
 
1529 killagreg 222
        //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
1622 killagreg 223
        {
224
                printf("\n\rCalibrating pressure sensor..");
225
                timer = SetDelay(1000);
226
                SucheLuftruckOffset();
227
                while (!CheckDelay(timer));
228
                printf("OK\n\r");
1 ingob 229
        }
1051 killagreg 230
 
1622 killagreg 231
        SetNeutral(0);
1 ingob 232
 
233
        ROT_OFF;
1051 killagreg 234
 
1 ingob 235
    beeptime = 2000;
1051 killagreg 236
    ExternControl.Digital[0] = 0x55;
1 ingob 237
 
1051 killagreg 238
 
1652 holgerb 239
        FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1);
240
        FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1);
1622 killagreg 241
 
1702 holgerb 242
        if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF))
1622 killagreg 243
        {
244
                FlugMinuten = 0;
245
                FlugMinutenGesamt = 0;
246
        }
247
    printf("\n\rFlight-time %u min  Total:%u min", FlugMinuten, FlugMinutenGesamt);
248
 
1211 hbuss 249
        printf("\n\rControl: ");
1 ingob 250
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
1211 hbuss 251
        else printf("Normal (ACC-Mode)");
1051 killagreg 252
 
1 ingob 253
    LcdClear();
173 holgerb 254
    I2CTimeout = 5000;
819 hbuss 255
    WinkelOut.Orientation = 1;
1268 hbuss 256
    LipoDetection(1);
1435 killagreg 257
 
1626 killagreg 258
        LIBFC_ReceiverInit(EE_Parameter.Receiver);
1444 ingob 259
 
1232 hbuss 260
        printf("\n\r===================================\n\r");
1622 killagreg 261
        //SpektrumBinding();
1350 hbuss 262
    timer = SetDelay(2000);
1424 ingob 263
        timerPolling = SetDelay(250);
1648 killagreg 264
 
1636 ingob 265
        Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt);   // Note: this won't waste flash memory, if #DEBUG is not active
1702 holgerb 266
    DebugOut.Status[0] = 0x01 | 0x02;
1648 killagreg 267
 
1 ingob 268
        while (1)
269
        {
1777 ingob 270
 
271
        if (JetiUpdateModeActive) while (1);
272
 
1424 ingob 273
        if(CheckDelay(timerPolling))
1419 ingob 274
        {
1424 ingob 275
          timerPolling = SetDelay(100);
1435 killagreg 276
          LIBFC_Polling();
1419 ingob 277
        }
278
        if(UpdateMotor && AdReady)      // ReglerIntervall
1051 killagreg 279
            {
1171 hbuss 280
                    UpdateMotor=0;
819 hbuss 281
            if(WinkelOut.CalcState) CalMk3Mag();
1644 holgerb 282
            else  MotorRegler();
283
                        SendMotorData();
1 ingob 284
            ROT_OFF;
1765 killagreg 285
            if(SenderOkay)  { SenderOkay--; VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM; }
1603 killagreg 286
                        else
287
                        {
288
                                TIMSK1 |= _BV(ICIE1); // enable PPM-Input
289
                                PPM_in[0] = 0; // set RSSI to zero on data timeout
1765 killagreg 290
                                VersionInfo.HardwareError[1] |= FC_ERROR1_PPM;
1603 killagreg 291
                        }
1420 killagreg 292
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1481 holgerb 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;
1309 hbuss 295
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1210 hbuss 296
            if(!--I2CTimeout || MissingMotor)
173 holgerb 297
                {
1254 killagreg 298
                  if(!I2CTimeout)
1210 hbuss 299
                                   {
1662 killagreg 300
                                    I2C_Reset();
1210 hbuss 301
                    I2CTimeout = 5;
1322 hbuss 302
                                        DebugOut.Analog[28]++; // I2C-Error
1765 killagreg 303
                                        VersionInfo.HardwareError[1] |= FC_ERROR1_I2C;
1702 holgerb 304
                                        DebugOut.Status[1] |= 0x02; // BL-Error-Status
1322 hbuss 305
                                   }
1051 killagreg 306
                  if((BeepMuster == 0xffff) && MotorenEin)
307
                   {
173 holgerb 308
                    beeptime = 10000;
309
                    BeepMuster = 0x0080;
1051 killagreg 310
                   }
1 ingob 311
                }
1051 killagreg 312
            else
1 ingob 313
                {
1051 killagreg 314
                 ROT_OFF;
1765 killagreg 315
                                 if(!beeptime)
1702 holgerb 316
                                  {
1765 killagreg 317
                                   VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C;
318
                                  }
1 ingob 319
                }
1639 holgerb 320
          if(!UpdateMotor)
321
                   {
1760 holgerb 322
                        if(CalculateServoSignals) CalculateServo();
323
                        DatenUebertragung();
324
                        BearbeiteRxDaten();
1254 killagreg 325
                        if(CheckDelay(timer))
326
                        {
1512 holgerb 327
                                static unsigned char second;
1420 killagreg 328
                                timer += 20; // 20 ms interval
1702 holgerb 329
                                if(MissingMotor)
330
                                 {
1765 killagreg 331
                                  VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
1702 holgerb 332
                                  DebugOut.Status[1] |= 0x02; // BL-Error-Status
1765 killagreg 333
                                 }
334
                                 else
1702 holgerb 335
                                 {
1765 killagreg 336
                                   VersionInfo.HardwareError[1] &= ~FC_ERROR1_BL_MISSING;
1702 holgerb 337
                                   if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status
1765 killagreg 338
                                 }
1702 holgerb 339
 
1765 killagreg 340
                            if(I2CTimeout > 6) VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C;
341
 
1420 killagreg 342
                                if(PcZugriff) PcZugriff--;
343
                                else
344
                                {
345
                                        ExternControl.Config = 0;
346
                                        ExternStickNick = 0;
347
                                        ExternStickRoll = 0;
348
                                        ExternStickGier = 0;
349
                                        if(BeepMuster == 0xffff && SenderOkay == 0)
350
                                        {
351
                                                beeptime = 15000;
352
                                                BeepMuster = 0x0c00;
353
                                        }
354
                                }
1682 holgerb 355
                                if(NaviDataOkay > 200)
1420 killagreg 356
                                {
357
                                        NaviDataOkay--;
1765 killagreg 358
                                        VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX;
1420 killagreg 359
                                }
360
                                else
361
                                {
1702 holgerb 362
                                        if(NC_Version.Compatible)
363
                                         {
1765 killagreg 364
                                                VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX;
1702 holgerb 365
                       if(BeepMuster == 0xffff && MotorenEin)
366
                                                {
367
                                                        beeptime = 15000;
368
                                                        BeepMuster = 0xA800;
369
                                                }
1765 killagreg 370
                                         }
1420 killagreg 371
                                        GPS_Nick = 0;
372
                                        GPS_Roll = 0;
1683 killagreg 373
                                        //if(!beeptime)
1691 holgerb 374
                    FromNaviCtrl.CompassValue = -1;
1703 holgerb 375
                    NaviDataOkay = 0;
1420 killagreg 376
                                }
1309 hbuss 377
                           if(UBat < BattLowVoltageWarning)
1254 killagreg 378
                                {
1765 killagreg 379
                                        FC_StatusFlags |= FC_STATUS_LOWBAT;
1254 killagreg 380
                                        if(BeepMuster == 0xffff)
381
                                        {
382
                                                beeptime = 6000;
383
                                                BeepMuster = 0x0300;
384
                                        }
385
                                }
1765 killagreg 386
                                else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT;
1420 killagreg 387
 
1254 killagreg 388
                                SPI_StartTransmitPacket();
389
                                SendSPI = 4;
1320 hbuss 390
                                if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden
1529 killagreg 391
                                else
1512 holgerb 392
                if(++second == 49)
393
                                 {
394
                                   second = 0;
395
                                   FlugSekunden++;
396
                                 }
1320 hbuss 397
                                if(++timer2 == 2930)  // eine Minute
1298 hbuss 398
                                 {
399
                                   timer2 = 0;
400
                   FlugMinuten++;
401
                       FlugMinutenGesamt++;
1652 holgerb 402
                   SetParamByte(PID_FLIGHT_MINUTES,FlugMinuten / 256);
403
                   SetParamByte(PID_FLIGHT_MINUTES+1,FlugMinuten % 256);
404
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL,FlugMinutenGesamt / 256);
405
                   SetParamByte(PID_FLIGHT_MINUTES_TOTAL+1,FlugMinutenGesamt % 256);
1344 hbuss 406
                                   timer = SetDelay(20); // falls "timer += 20;" mal nicht geht
1298 hbuss 407
                             }
1254 killagreg 408
                        }
921 hbuss 409
           LED_Update();
1486 killagreg 410
           Capacity_Update();
1639 holgerb 411
           }
604 hbuss 412
          }
723 hbuss 413
     if(!SendSPI) { SPI_TransmitByte(); }
1 ingob 414
    }
415
 return (1);
416
}
417
 
1219 hbuss 418