Rev 929 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
927 | hbuss | 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 | { |
||
1254 | killagreg | 12 | // set PC2 & PC3 as output (control of J16 & J17) |
13 | DDRC |= (1<<DDC2)|(1<<DDC3); |
||
14 | J16_OFF; |
||
15 | J17_OFF; |
||
16 | J16Blinkcount = 0; J16Mask = 128; |
||
17 | J17Blinkcount = 0; J17Mask = 128; |
||
927 | hbuss | 18 | } |
19 | |||
20 | |||
21 | // called in UpdateMotors() every 2ms |
||
22 | void LED_Update(void) |
||
23 | { |
||
1254 | killagreg | 24 | static char delay = 0; |
25 | static unsigned char J16Bitmask = 0; |
||
26 | static unsigned char J17Bitmask = 0; |
||
27 | |||
28 | if(!delay--) // 10ms Intervall |
||
29 | { |
||
30 | delay = 4; |
||
31 | |||
32 | if(MikroKopterFlags & FLAG_LOWBAT) |
||
33 | { |
||
34 | J16Bitmask = EE_Parameter.WARN_J16_Bitmask; |
||
35 | J17Bitmask = EE_Parameter.WARN_J17_Bitmask; |
||
36 | } |
||
37 | else |
||
38 | { |
||
39 | J16Bitmask = EE_Parameter.J16Bitmask; |
||
40 | J17Bitmask = EE_Parameter.J17Bitmask; |
||
41 | } |
||
42 | |||
43 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 230)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;} |
||
927 | hbuss | 44 | else |
1254 | killagreg | 45 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} |
46 | else |
||
47 | if(!J16Blinkcount--) |
||
927 | hbuss | 48 | { |
49 | J16Blinkcount = Parameter_J16Timing-1; |
||
50 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
||
1254 | killagreg | 51 | if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
52 | } |
||
53 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;} |
||
927 | hbuss | 54 | else |
1254 | killagreg | 55 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10)) {if(J17Bitmask & 128) J17_OFF; else J17_ON;} |
56 | else |
||
57 | if(!J17Blinkcount--) |
||
927 | hbuss | 58 | { |
59 | J17Blinkcount = Parameter_J17Timing-1; |
||
60 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
||
1254 | killagreg | 61 | if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
62 | } |
||
927 | hbuss | 63 | } |
64 | } |