Rev 935 | Go to most recent revision | Show entire file | Regard 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 | 20 | ||
- | 21 | // called in main loop every 2ms |
|
19 | // called in UpdateMotors() every 2ms |
22 | void LED_Update(void) |
- | 23 | { |
|
- | 24 | static int8_t delay = 0; |
|
- | 25 | ||
Line 20... | Line 26... | ||
20 | void LED_Update(void) |
26 | if(!delay--) // 10 ms intervall |
21 | { |
- | |
22 | static uint16_t J16_blinkcount = 0; |
27 | { |
23 | static uint16_t J17_blinkcount = 0; |
28 | delay = 4; |
24 | 29 | ||
25 | if (LED1_Time < 20) J16_ON; |
- | |
26 | else if(LED1_Time < 220) |
30 | |
- | 31 | if ((ParamSet.J16Timing > 250) && (FCParam.J16Timing > 230)) |
|
- | 32 | { |
|
- | 33 | if(ParamSet.J16Bitmask & 128) J16_ON; |
|
27 | { |
34 | 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--) |
|
Line 28... | Line 42... | ||
28 | if((2 * J16_blinkcount) < LED1_Time) J16_ON; |
42 | { |
29 | else J16_OFF; |
- | |
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; |
33 | - | ||
34 | if (LED2_Time < 20) J17_ON; |
46 | } |
- | 47 | ||
- | 48 | if ((ParamSet.J17Timing > 250) && (FCParam.J17Timing > 230)) |
|
- | 49 | { |
|
35 | else if(LED2_Time < 220) |
50 | if(ParamSet.J17Bitmask & 128) J17_ON; |
36 | { |
51 | else J17_OFF; |
- | 52 | } |
|
- | 53 | else if ((ParamSet.J17Timing > 250) && (FCParam.J17Timing < 10)) |
|
- | 54 | { |
|
- | 55 | if(ParamSet.J17Bitmask & 128) J17_OFF; |
|
- | 56 | else J17_ON; |
|
- | 57 | } |
|
- | 58 | else if(!J17Blinkcount--) |
|
- | 59 | { |