Subversion Repositories FlightCtrl

Rev

Rev 1193 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1189 kmpec 1
#include <inttypes.h>
2
#include "main.h"
3
//#include "fc.c"
4
 
5
uint16_t LED1_Timing = 0;
6
uint16_t LED2_Timing = 0;
7
unsigned char J16Blinkcount = 0, J16Mask = 1;
8
unsigned char J17Blinkcount = 0, J17Mask = 1;
9
 
10
// initializes the LED control outputs J16, J17
11
void LED_Init(void)
12
{
13
    // set PC2 & PC3 as output (control of J16 & J17)
14
        DDRC |= (1<<DDC2)|(1<<DDC3);
15
        J16_OFF;
16
        J17_OFF;
17
        J16Blinkcount = 0; J16Mask = 128;
18
        J17Blinkcount = 0; J17Mask = 128;
19
}
20
 
21
 
22
// called in UpdateMotors() every 2ms
23
void LED_Update(void)
24
{
25
 static char delay = 0;
26
 if(!delay--)  // 10ms Intervall
27
  {
28
 
29
  delay = 4;
30
 
31
  //wenn Höhe halten an -> UserParameter 1
32
  if(HoehenReglerAktiv > 0 )
33
  {
34
   if(!J16Blinkcount--)
35
   {
36
     J16Blinkcount = Parameter_J16Timing-1;
37
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
38
     if(J16Mask & EE_Parameter.UserParam1) J16_ON; else J16_OFF;
39
   }  
40
  }  
41
 
42
  //Wenn AID oder Pos.Hold an -> UserParameter2
43
  else
44
  if(Parameter_NaviGpsModeControl < 100 )
45
  {
46
  if(!J16Blinkcount--)
47
   {
48
     J16Blinkcount = Parameter_J16Timing-1;
49
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
50
     if(J16Mask & EE_Parameter.UserParam2) J16_ON; else J16_OFF;
51
   }  
52
  }
53
 else
54
 
55
  //wenn Coming Home an -> UserPArameter 3
56
 if(Parameter_NaviGpsModeControl > 150 )
57
  {
58
  if(!J16Blinkcount--)
59
   {
60
     J16Blinkcount = Parameter_J16Timing-1;
61
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
62
     if(J16Mask & EE_Parameter.UserParam3) J16_ON; else J16_OFF;
63
   }  
64
  }
65
 
66
  else
67
  {
68
   J16_ON;
69
  }
70
 
71
 J16_OFF;
72
 
73
 
74
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(EE_Parameter.J17Bitmask & 128) J17_ON; else J17_OFF;}
75
  else
76
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(EE_Parameter.J17Bitmask & 128) J17_OFF; else J17_ON;}
77
  else
78
  if(!J17Blinkcount--)
79
   {
80
     J17Blinkcount = Parameter_J17Timing-1;
81
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
82
     if(J17Mask & EE_Parameter.J17Bitmask) J17_ON; else J17_OFF;
83
   }  
84
  }
85
}