Subversion Repositories FlightCtrl

Rev

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

Rev Author Line No. Line
1068 thjac 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
extern char MotorenEin;
10
 
11
// initializes the LED control outputs J16, J17
12
void LED_Init(void)
13
{
14
    // set PC2 & PC3 as output (control of J16 & J17)
15
        DDRC |= (1<<DDC2)|(1<<DDC3);
16
        J16_OFF;
17
        J17_OFF;
18
        J16Blinkcount = 0; J16Mask = 128;
19
        J17Blinkcount = 0; J17Mask = 128;
20
}
21
 
22
 
23
// called in UpdateMotors() every 2ms
24
void LED_Update(void)
25
{
1076 thjac 26
        static char delay = 0;
1068 thjac 27
 
1076 thjac 28
        /* Die Ausgänge J16/J17 lassen sich wahlweise über die Motoren koppeln, so daß
29
         * die Ausgänge bei ausgeschalteten Motoren unabhängig vom eingestellten Blink-Muster
30
         * deaktiviert sind.
31
         */
32
 
33
        if( PARAM_LED_ENGINE_ENABLED && !MotorenEin ) {
34
                J16_OFF;
35
                J17_OFF;
1068 thjac 36
 
1076 thjac 37
                return;
38
        }
1068 thjac 39
 
40
 if(!delay--)  // 10ms Intervall
41
  {
42
  delay = 4;
43
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 230)) {if(EE_Parameter.J16Bitmask & 128) J16_ON; else J16_OFF;}
44
  else
45
  if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10))  {if(EE_Parameter.J16Bitmask & 128) J16_OFF; else J16_ON;}
46
  else
47
  if(!J16Blinkcount--)
48
   {
49
     J16Blinkcount = Parameter_J16Timing-1;
50
     if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2;
51
     if(J16Mask & EE_Parameter.J16Bitmask) J16_ON; else J16_OFF;
52
   }  
53
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(EE_Parameter.J17Bitmask & 128) J17_ON; else J17_OFF;}
54
  else
55
  if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10))  {if(EE_Parameter.J17Bitmask & 128) J17_OFF; else J17_ON;}
56
  else
57
  if(!J17Blinkcount--)
58
   {
59
     J17Blinkcount = Parameter_J17Timing-1;
60
     if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2;
61
     if(J17Mask & EE_Parameter.J17Bitmask) J17_ON; else J17_OFF;
62
   }  
63
  }
64
}