Subversion Repositories FlightCtrl

Rev

Rev 1799 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
927 hbuss 1
#include <inttypes.h>
2
#include "main.h"
3
 
4
uint16_t LED1_Timing = 0;
5
uint16_t LED2_Timing = 0;
6
unsigned char J16Blinkcount = 0, J16Mask = 1;
7
unsigned char J17Blinkcount = 0, J17Mask = 1;
8
 
9
// initializes the LED control outputs J16, J17
10
void LED_Init(void)
11
{
1254 killagreg 12
        // set PC2 & PC3 as output (control of J16 & J17)
13
        DDRC |= (1<<DDC2)|(1<<DDC3);
14
        J16_OFF;
15
        J17_OFF;
16
        J16Blinkcount = 0; J16Mask = 128;
17
        J17Blinkcount = 0; J17Mask = 128;
927 hbuss 18
}
19
 
20
// called in UpdateMotors() every 2ms
21
void LED_Update(void)
22
{
1254 killagreg 23
        static char delay = 0;
24
        static unsigned char J16Bitmask = 0;
25
        static unsigned char J17Bitmask = 0;
1423 hbuss 26
        static unsigned char J16Warn = 0, J17Warn = 0;
1254 killagreg 27
        if(!delay--)  // 10ms Intervall
28
        {
29
        delay = 4;
1799 - 30
 
31
 
32
 
33
//MartinW: added        
34
        if(EE_Parameter.UserParam8 >0)  // 2ms Intervall ///
35
        {
36
        delay = 0;
37
        }
38
//MartinW
39
 
40
 
41
 
1769 holgerb 42
        if(FC_StatusFlags & (FC_STATUS_LOWBAT | FC_STATUS_EMERGENCY_LANDING) || (VersionInfo.HardwareError[1] & FC_ERROR1_I2C))
1254 killagreg 43
        {
1765 killagreg 44
                if(EE_Parameter.WARN_J16_Bitmask)
1423 hbuss 45
                 {
46
          if(!J16Warn) J16Blinkcount = 4;
47
          J16Warn = 1;
1765 killagreg 48
                 }
49
                if(EE_Parameter.WARN_J17_Bitmask)
1423 hbuss 50
                 {
51
          if(!J17Warn) J17Blinkcount = 4;
52
          J17Warn = 1;
1765 killagreg 53
                 }
1254 killagreg 54
        }
55
        else
56
        {
1423 hbuss 57
        J16Warn = 0;
58
        J17Warn = 0;
1254 killagreg 59
                J16Bitmask = EE_Parameter.J16Bitmask;
60
                J17Bitmask = EE_Parameter.J17Bitmask;
61
        }
62
 
1423 hbuss 63
 if(!J16Warn)
64
  {
1350 hbuss 65
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;}
927 hbuss 66
  else
1377 hbuss 67
  if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;}
1350 hbuss 68
  else
1802 - 69
 
70
   if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing < 10))  {if(J16Bitmask & 128) J16_OFF; else J16_ON;} //original
71
  //if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing < 2))  {if(J16Bitmask & 128) J16_OFF; else J16_ON;} // MartinW; um die LEDs so schnell wie möglich blinken zu lassen, bei <10 reagiert gar nicht mehr, bei mir ist "2" i.o.
72
 
1254 killagreg 73
  else
74
  if(!J16Blinkcount--)
927 hbuss 75
   {
76
     J16Blinkcount = Parameter_J16Timing-1;
77
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
1254 killagreg 78
     if(J16Mask & J16Bitmask) J16_ON; else J16_OFF;
79
   }
1423 hbuss 80
  }
1765 killagreg 81
  else
1423 hbuss 82
  if(!J16Blinkcount--)
83
   {
84
     J16Blinkcount = 10-1;
85
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
86
     if(J16Mask & EE_Parameter.WARN_J16_Bitmask) J16_ON; else J16_OFF;
87
   }
1350 hbuss 88
 
1423 hbuss 89
 if(!J17Warn)
90
  {
1350 hbuss 91
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;}
927 hbuss 92
  else
1570 holgerb 93
  if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing > 220)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;}
1350 hbuss 94
  else
1377 hbuss 95
  if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing < 10))  {if(J17Bitmask & 128) J17_OFF; else J17_ON;}
1254 killagreg 96
  else
97
  if(!J17Blinkcount--)
927 hbuss 98
   {
99
     J17Blinkcount = Parameter_J17Timing-1;
100
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
1254 killagreg 101
     if(J17Mask & J17Bitmask) J17_ON; else J17_OFF;
102
   }
927 hbuss 103
  }
1765 killagreg 104
  else
1423 hbuss 105
  if(!J17Blinkcount--)
106
   {
107
     J17Blinkcount = 10-1;
108
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
109
     if(J17Mask & EE_Parameter.WARN_J17_Bitmask) J17_ON; else J17_OFF;
110
   }
111
 }
927 hbuss 112
}
1423 hbuss 113