Rev 935 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 935 | Rev 936 | ||
---|---|---|---|
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" |
|
4 | 5 | ||
5 | uint16_t LED1_Time = 0; |
6 | uint8_t J16Blinkcount = 0, J16Mask = 1; |
6 | uint16_t LED2_Time = 0; |
- | |
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; |
14 | J16_OFF; |
15 | J17_OFF; |
15 | J17_OFF; |
- | 16 | J16Blinkcount = 0; J16Mask = 128; |
|
- | 17 | J17Blinkcount = 0; J17Mask = 128; |
|
16 | } |
18 | } |
17 | 19 | ||
18 | 20 | ||
19 | // called in UpdateMotors() every 2ms |
21 | // called in main loop every 2ms |
20 | void LED_Update(void) |
22 | void LED_Update(void) |
21 | { |
- | |
22 | static uint16_t J16_blinkcount = 0; |
23 | { |
23 | static uint16_t J17_blinkcount = 0; |
24 | static int8_t delay = 0; |
24 | - | ||
25 | if (LED1_Time < 20) J16_ON; |
25 | |
26 | else if(LED1_Time < 220) |
- | |
27 | { |
26 | if(!delay--) // 10 ms intervall |
28 | if((2 * J16_blinkcount) < LED1_Time) J16_ON; |
- | |
29 | else J16_OFF; |
- | |
30 | if(J16_blinkcount++ >= LED1_Time) J16_blinkcount = 0; |
- | |
- | 27 | { |
|
- | 28 | delay = 4; |
|
- | 29 | ||
31 | } |
30 | |
- | 31 | if ((ParamSet.J16Timing > 250) && (FCParam.J16Timing > 230)) |
|
- | 32 | { |
|
- | 33 | if(ParamSet.J16Bitmask & 128) J16_ON; |
|
- | 34 | else J16_OFF; |
|
- | 35 | } |
|
- | 36 | else if ((ParamSet.J16Timing > 250) && (FCParam.J16Timing < 10)) |
|
- | 37 | { |
|
32 | else J16_ON; |
38 | if(ParamSet.J16Bitmask & 128) J16_OFF; |
- | 39 | else J16_ON; |
|
- | 40 | } |
|
- | 41 | else if(!J16Blinkcount--) |
|
- | 42 | { |
|
- | 43 | J16Blinkcount = FCParam.J16Timing - 1; |
|
- | 44 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
|
- | 45 | if(J16Mask & ParamSet.J16Bitmask) J16_ON; else J16_OFF; |
|
33 | 46 | } |
|
34 | if (LED2_Time < 20) J17_ON; |
47 | |
35 | else if(LED2_Time < 220) |
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)) |
|
- | 54 | { |
|
- | 55 | if(ParamSet.J17Bitmask & 128) J17_OFF; |
|
- | 56 | else J17_ON; |
|
36 | { |
57 | } |
- | 58 | else if(!J17Blinkcount--) |
|
- | 59 | { |
|
- | 60 | J17Blinkcount = FCParam.J17Timing - 1; |
|
37 | if((2 * J17_blinkcount) < LED2_Time) J17_ON; |
61 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
38 | else J17_OFF; |
- | |
39 | if(J17_blinkcount++ >= LED2_Time) J17_blinkcount = 0; |
62 | if(J17Mask & ParamSet.J17Bitmask) J17_ON; else J17_OFF; |
40 | } |
63 | } |
41 | else J17_ON; |
64 | } |
42 | } |
65 | } |
43 | 66 |