Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
689 form 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
{
12
        // set PC2 & PC3 as output (control of J16 & J17)
13
        DDRC |= (1<<DDC2)|(1<<DDC3);
14
/* Commented out for Spektrum Expander - Don't mess with my bits
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
/* Commented out for Spektrum Expander - Blinking doesn't work (yet?)
26
        static char delay = 0;
27
        static unsigned char J16Bitmask = 0;
28
        static unsigned char J17Bitmask = 0;
29
        if(!delay--)  // 10ms Intervall
30
        {
31
        delay = 4;
32
 
33
        if(MikroKopterFlags & FLAG_LOWBAT || SenderOkay < 128)
34
        {
35
                J16Bitmask = EE_Parameter.WARN_J16_Bitmask;
36
                J17Bitmask = EE_Parameter.WARN_J17_Bitmask;
37
        }
38
        else
39
        {
40
                J16Bitmask = EE_Parameter.J16Bitmask;
41
                J17Bitmask = EE_Parameter.J17Bitmask;
42
        }
43
 
44
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;}
45
  else
46
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;}
47
  else
48
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10))  {if(J16Bitmask & 128) J16_OFF; else J16_ON;}
49
  else
50
  if(!J16Blinkcount--)
51
   {
52
     J16Blinkcount = Parameter_J16Timing-1;
53
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
54
     if(J16Mask & J16Bitmask) J16_ON; else J16_OFF;
55
   }
56
 
57
  if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;}
58
  else
59
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;}
60
  else
61
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(J17Bitmask & 128) J17_OFF; else J17_ON;}
62
  else
63
  if(!J17Blinkcount--)
64
   {
65
     J17Blinkcount = Parameter_J17Timing-1;
66
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
67
     if(J17Mask & J17Bitmask) J17_ON; else J17_OFF;
68
   }
69
  }
70
*/
71
}