Rev 927 | Rev 1254 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 927 | Rev 929 | ||
---|---|---|---|
1 | #include <inttypes.h> |
1 | #include <inttypes.h> |
2 | #include "main.h" |
2 | #include "main.h" |
3 | 3 | ||
4 | uint16_t LED1_Timing = 0; |
4 | uint16_t LED1_Timing = 0; |
5 | uint16_t LED2_Timing = 0; |
5 | uint16_t LED2_Timing = 0; |
6 | unsigned char J16Blinkcount = 0, J16Mask = 1; |
6 | unsigned char J16Blinkcount = 0, J16Mask = 1; |
7 | unsigned char J17Blinkcount = 0, J17Mask = 1; |
7 | unsigned char 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; |
16 | J16Blinkcount = 0; J16Mask = 128; |
17 | J17Blinkcount = 0; J17Mask = 128; |
17 | J17Blinkcount = 0; J17Mask = 128; |
18 | } |
18 | } |
19 | 19 | ||
20 | 20 | ||
21 | // called in UpdateMotors() every 2ms |
21 | // called in UpdateMotors() every 2ms |
22 | void LED_Update(void) |
22 | void LED_Update(void) |
23 | { |
23 | { |
24 | static char delay = 0; |
24 | static char delay = 0; |
25 | if(!delay--) // 10ms Intervall |
25 | if(!delay--) // 10ms Intervall |
26 | { |
26 | { |
27 | delay = 4; |
27 | delay = 4; |
28 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 230)) J16_ON; |
28 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing > 230)) {if(EE_Parameter.J16Bitmask & 128) J16_ON; else J16_OFF;} |
29 | else |
29 | else |
30 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10)) J16_OFF; |
30 | if((EE_Parameter.J16Timing > 250) && (Parameter_J16Timing < 10)) {if(EE_Parameter.J16Bitmask & 128) J16_OFF; else J16_ON;} |
31 | else |
31 | else |
32 | if(!J16Blinkcount--) |
32 | if(!J16Blinkcount--) |
33 | { |
33 | { |
34 | J16Blinkcount = Parameter_J16Timing-1; |
34 | J16Blinkcount = Parameter_J16Timing-1; |
35 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
35 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
36 | if(J16Mask & EE_Parameter.J16Bitmask) J16_ON; else J16_OFF; |
36 | if(J16Mask & EE_Parameter.J16Bitmask) J16_ON; else J16_OFF; |
37 | } |
37 | } |
38 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) J17_ON; |
38 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing > 230)) {if(EE_Parameter.J17Bitmask & 128) J17_ON; else J17_OFF;} |
39 | else |
39 | else |
40 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10)) J17_OFF; |
40 | if((EE_Parameter.J17Timing > 250) && (Parameter_J17Timing < 10)) {if(EE_Parameter.J17Bitmask & 128) J17_OFF; else J17_ON;} |
41 | else |
41 | else |
42 | if(!J17Blinkcount--) |
42 | if(!J17Blinkcount--) |
43 | { |
43 | { |
44 | J17Blinkcount = Parameter_J17Timing-1; |
44 | J17Blinkcount = Parameter_J17Timing-1; |
45 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
45 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
46 | if(J17Mask & EE_Parameter.J17Bitmask) J17_ON; else J17_OFF; |
46 | if(J17Mask & EE_Parameter.J17Bitmask) J17_ON; else J17_OFF; |
47 | } |
47 | } |
48 | } |
48 | } |
49 | } |
49 | } |
50 | 50 |