Subversion Repositories FlightCtrl

Rev

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

Rev Author Line No. Line
1189 kmpec 1
#include <inttypes.h>
2
#include "main.h"
3
 
1202 kmpec 4
 
1189 kmpec 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
 
1202 kmpec 31
 
32
 
33
 
34
/*
35
  //Unterspannungswarnung -> UserParameter4
36
  if(UBat < EE_Parameter.UnterspannungsWarnung)
37
  {
38
   if(!J16Blinkcount--)
39
   {
40
     J16Blinkcount = Parameter_J16Timing-1;
41
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
42
     if(J16Mask & EE_Parameter.UserParam4) J16_ON; else J16_OFF;
43
   }  
44
  }
45
 
46
*/
1197 kmpec 47
  //Wenn Höhe halten aktiv -Bitmuster = UserParameter1
1193 kmpec 48
  if(HoehenReglerAktiv > 0 && Parameter_NaviGpsModeControl > 90 && Parameter_NaviGpsModeControl < 200)
1189 kmpec 49
  {
50
   if(!J16Blinkcount--)
51
   {
52
     J16Blinkcount = Parameter_J16Timing-1;
53
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
54
     if(J16Mask & EE_Parameter.UserParam1) J16_ON; else J16_OFF;
55
   }  
56
  }  
57
 
1197 kmpec 58
  //Wenn AID aktiv -Bitmuster = UserParameter2
1189 kmpec 59
  else
60
  if(Parameter_NaviGpsModeControl < 100 )
61
  {
62
  if(!J16Blinkcount--)
63
   {
64
     J16Blinkcount = Parameter_J16Timing-1;
65
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
66
     if(J16Mask & EE_Parameter.UserParam2) J16_ON; else J16_OFF;
67
   }  
68
  }
69
 else
70
 
1197 kmpec 71
  //Wenn ComingHome aktiv -Bitmuster = UserParameter3
1189 kmpec 72
 if(Parameter_NaviGpsModeControl > 150 )
73
  {
74
  if(!J16Blinkcount--)
75
   {
76
     J16Blinkcount = Parameter_J16Timing-1;
77
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
78
     if(J16Mask & EE_Parameter.UserParam3) J16_ON; else J16_OFF;
79
   }  
80
  }
81
 
82
  else
83
  {
84
   J16_ON;
85
  }
86
 
87
 
88
 
89
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(EE_Parameter.J17Bitmask & 128) J17_ON; else J17_OFF;}
90
  else
91
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(EE_Parameter.J17Bitmask & 128) J17_OFF; else J17_ON;}
92
  else
93
  if(!J17Blinkcount--)
94
   {
95
     J17Blinkcount = Parameter_J17Timing-1;
96
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
97
     if(J17Mask & EE_Parameter.J17Bitmask) J17_ON; else J17_OFF;
98
   }  
99
  }
100
}