Subversion Repositories FlightCtrl

Rev

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

Rev 1494 Rev 1554
Line 7... Line 7...
7
unsigned char J17Blinkcount = 0, J17Mask = 1;
7
unsigned char J17Blinkcount = 0, J17Mask = 1;
Line 8... Line 8...
8
 
8
 
9
// initializes the LED control outputs J16, J17
9
// initializes the LED control outputs J16, J17
10
void LED_Init(void)
10
void LED_Init(void)
11
{
11
{
12
        // set PC2 & PC3 as output (control of J16 & J17)
12
    // set PC2 & PC3 as output (control of J16 & J17)
13
        DDRC |= (1<<DDC2)|(1<<DDC3);
13
    DDRC |= (1<<DDC2)|(1<<DDC3);
14
        J16_OFF;
14
    J16_OFF;
15
        J17_OFF;
15
    J17_OFF;
16
        J16Blinkcount = 0; J16Mask = 128;
16
    J16Blinkcount = 0; J16Mask = 128;
17
        J17Blinkcount = 0; J17Mask = 128;
17
    J17Blinkcount = 0; J17Mask = 128;
Line 18... Line 18...
18
}
18
}
19
 
19
 
20
// called in UpdateMotors() every 2ms
20
// called in UpdateMotors() every 2ms
21
void LED_Update(void)
21
void LED_Update(void)
22
{
22
{
23
        static char delay = 0;
23
    static char delay = 0;
24
        static unsigned char J16Bitmask = 0;
24
    static unsigned char J16Bitmask = 0;
25
        static unsigned char J17Bitmask = 0;
25
    static unsigned char J17Bitmask = 0;
26
        if(!delay--)  // 10ms Intervall
26
    if(!delay--)  // 10ms Intervall
Line 27... Line 27...
27
        {
27
    {
28
        delay = 4;
28
        delay = 4;
29
 
29
 
30
        if(MikroKopterFlags & FLAG_LOWBAT || SenderOkay < 128)
30
        if(MikroKopterFlags & FLAG_LOWBAT || SenderOkay < 128)
31
        {
31
        {
32
                J16Bitmask = EE_Parameter.WARN_J16_Bitmask;
32
            J16Bitmask = EE_Parameter.WARN_J16_Bitmask;
33
                J17Bitmask = EE_Parameter.WARN_J17_Bitmask;
33
            J17Bitmask = EE_Parameter.WARN_J17_Bitmask;
34
        }
34
        }
35
        else
35
        else
36
        {
36
        {
Line 37... Line 37...
37
                J16Bitmask = EE_Parameter.J16Bitmask;
37
            J16Bitmask = EE_Parameter.J16Bitmask;
38
                J17Bitmask = EE_Parameter.J17Bitmask;
38
            J17Bitmask = EE_Parameter.J17Bitmask;
39
        }
39
        }
40
 
40
 
41
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;}
41
        if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;}
42
  else
42
        else
43
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;}
43
            if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;}
44
  else
44
            else
45
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10))  {if(J16Bitmask & 128) J16_OFF; else J16_ON;}
45
                if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10))  {if(J16Bitmask & 128) J16_OFF; else J16_ON;}
46
  else
46
                else
47
  if(!J16Blinkcount--)
47
                    if(!J16Blinkcount--)
48
   {
48
                    {
Line 49... Line 49...
49
     J16Blinkcount = Parameter_J16Timing-1;
49
                        J16Blinkcount = Parameter_J16Timing-1;
50
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
50
                        if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
51
     if(J16Mask & J16Bitmask) J16_ON; else J16_OFF;
51
                        if(J16Mask & J16Bitmask) J16_ON; else J16_OFF;
52
   }
52
                    }
53
 
53
 
54
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;}
54
        if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;}
55
  else
55
        else
56
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;}
56
            if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;}
57
  else
57
            else
58
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(J17Bitmask & 128) J17_OFF; else J17_ON;}
58
                if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(J17Bitmask & 128) J17_OFF; else J17_ON;}
59
  else
59
                else
60
  if(!J17Blinkcount--)
60
                    if(!J17Blinkcount--)
61
   {
61
                    {
62
     J17Blinkcount = Parameter_J17Timing-1;
62
                        J17Blinkcount = Parameter_J17Timing-1;