Rev 935 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 935 | Rev 936 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include <inttypes.h> |
1 | #include <inttypes.h> |
2 | #include "led.h" |
2 | #include "led.h" |
3 | #include "fc.h" |
3 | #include "fc.h" |
- | 4 | #include "eeprom.h" |
|
Line 4... | Line 5... | ||
4 | 5 | ||
5 | uint16_t LED1_Time = 0; |
6 | uint8_t J16Blinkcount = 0, J16Mask = 1; |
6 | uint16_t LED2_Time = 0; |
- | |
Line 7... | Line 7... | ||
7 | 7 | uint8_t J17Blinkcount = 0, J17Mask = 1; |
|
8 | 8 | ||
9 | // initializes the LED control outputs J16, J17 |
9 | // initializes the LED control outputs J16, J17 |
10 | void LED_Init(void) |
10 | void LED_Init(void) |
11 | { |
11 | { |
12 | // set PC2 & PC3 as output (control of J16 & J17) |
12 | // set PC2 & PC3 as output (control of J16 & J17) |
13 | DDRC |= (1<<DDC2)|(1<<DDC3); |
13 | DDRC |= (1<<DDC2)|(1<<DDC3); |
- | 14 | J16_OFF; |
|
- | 15 | J17_OFF; |
|
14 | J16_OFF; |
16 | J16Blinkcount = 0; J16Mask = 128; |
Line 15... | Line 17... | ||
15 | J17_OFF; |
17 | J17Blinkcount = 0; J17Mask = 128; |
16 | } |
18 | } |
17 | 19 | ||
18 | - | ||
19 | // called in UpdateMotors() every 2ms |
20 | |
Line 20... | Line 21... | ||
20 | void LED_Update(void) |
21 | // called in main loop every 2ms |
21 | { |
- | |
22 | static uint16_t J16_blinkcount = 0; |
22 | void LED_Update(void) |
23 | static uint16_t J17_blinkcount = 0; |
- | |
24 | 23 | { |
|
25 | if (LED1_Time < 20) J16_ON; |
- | |
26 | else if(LED1_Time < 220) |
- | |
27 | { |
- | |
Line -... | Line 24... | ||
- | 24 | static int8_t delay = 0; |
|
- | 25 | ||
- | 26 | if(!delay--) // 10 ms intervall |
|
28 | if((2 * J16_blinkcount) < LED1_Time) J16_ON; |
27 | { |
- | 28 | delay = 4; |
|
- | 29 | ||
- | 30 | ||
- | 31 | if ((ParamSet.J16Timing > 250) && (FCParam.J16Timing > 230)) |
|
- | 32 | { |
|
- | 33 | if(ParamSet.J16Bitmask & 128) J16_ON; |
|
- | 34 | else J16_OFF; |
|
29 | else J16_OFF; |
35 | } |
- | 36 | else if ((ParamSet.J16Timing > 250) && (FCParam.J16Timing < 10)) |
|
- | 37 | { |
|
- | 38 | if(ParamSet.J16Bitmask & 128) J16_OFF; |
|
- | 39 | else J16_ON; |
|
- | 40 | } |
|
- | 41 | else if(!J16Blinkcount--) |
|
- | 42 | { |
|
30 | if(J16_blinkcount++ >= LED1_Time) J16_blinkcount = 0; |
43 | J16Blinkcount = FCParam.J16Timing - 1; |
31 | } |
44 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
32 | else J16_ON; |
45 | if(J16Mask & ParamSet.J16Bitmask) J16_ON; else J16_OFF; |
- | 46 | } |
|
- | 47 | ||
- | 48 | if ((ParamSet.J17Timing > 250) && (FCParam.J17Timing > 230)) |
|
- | 49 | { |
|
- | 50 | if(ParamSet.J17Bitmask & 128) J17_ON; |
|
- | 51 | else J17_OFF; |
|
- | 52 | } |
|
- | 53 | else if ((ParamSet.J17Timing > 250) && (FCParam.J17Timing < 10)) |
|
33 | 54 | { |
|
- | 55 | if(ParamSet.J17Bitmask & 128) J17_OFF; |
|
- | 56 | else J17_ON; |
|
- | 57 | } |
|
34 | if (LED2_Time < 20) J17_ON; |
58 | else if(!J17Blinkcount--) |
35 | else if(LED2_Time < 220) |
- | |
36 | { |
59 | { |