Rev 1739 | 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 | // called in UpdateMotors() every 2ms |
||
21 | void LED_Update(void) |
||
22 | { |
||
1254 | killagreg | 23 | static char delay = 0; |
24 | static unsigned char J16Bitmask = 0; |
||
25 | static unsigned char J17Bitmask = 0; |
||
1423 | hbuss | 26 | static unsigned char J16Warn = 0, J17Warn = 0; |
1254 | killagreg | 27 | if(!delay--) // 10ms Intervall |
28 | { |
||
29 | delay = 4; |
||
1756 | - | 30 | |
31 | |||
32 | if(EE_Parameter.UserParam8 >0) // 2ms Intervall /// |
||
33 | { |
||
34 | delay = 0; |
||
35 | } |
||
1254 | killagreg | 36 | |
1756 | - | 37 | |
38 | |||
1423 | hbuss | 39 | if(FCFlags & (FCFLAG_LOWBAT | FCFLAG_NOTLANDUNG | FCFLAG_I2CERR)) |
1254 | killagreg | 40 | { |
1423 | hbuss | 41 | if(EE_Parameter.WARN_J16_Bitmask) |
42 | { |
||
43 | if(!J16Warn) J16Blinkcount = 4; |
||
44 | J16Warn = 1; |
||
45 | } |
||
46 | if(EE_Parameter.WARN_J17_Bitmask) |
||
47 | { |
||
48 | if(!J17Warn) J17Blinkcount = 4; |
||
49 | J17Warn = 1; |
||
50 | } |
||
1254 | killagreg | 51 | } |
52 | else |
||
53 | { |
||
1423 | hbuss | 54 | J16Warn = 0; |
55 | J17Warn = 0; |
||
1254 | killagreg | 56 | J16Bitmask = EE_Parameter.J16Bitmask; |
57 | J17Bitmask = EE_Parameter.J17Bitmask; |
||
58 | } |
||
59 | |||
1423 | hbuss | 60 | if(!J16Warn) |
61 | { |
||
1350 | hbuss | 62 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;} |
927 | hbuss | 63 | else |
1377 | hbuss | 64 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;} |
1350 | hbuss | 65 | else |
1756 | - | 66 | //if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing < 10)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} //original |
67 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing < 2)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} //bei <10 reagiert gar nicht mehr, bei mir ist "2" i.o. |
||
1254 | killagreg | 68 | else |
69 | if(!J16Blinkcount--) |
||
927 | hbuss | 70 | { |
71 | J16Blinkcount = Parameter_J16Timing-1; |
||
72 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
||
1254 | killagreg | 73 | if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
74 | } |
||
1423 | hbuss | 75 | } |
76 | else |
||
77 | if(!J16Blinkcount--) |
||
78 | { |
||
79 | J16Blinkcount = 10-1; |
||
80 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
||
81 | if(J16Mask & EE_Parameter.WARN_J16_Bitmask) J16_ON; else J16_OFF; |
||
82 | } |
||
1350 | hbuss | 83 | |
1423 | hbuss | 84 | if(!J17Warn) |
85 | { |
||
1350 | hbuss | 86 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;} |
927 | hbuss | 87 | else |
1570 | holgerb | 88 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing > 220)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;} |
1350 | hbuss | 89 | else |
1377 | hbuss | 90 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing < 10)) {if(J17Bitmask & 128) J17_OFF; else J17_ON;} |
1254 | killagreg | 91 | else |
92 | if(!J17Blinkcount--) |
||
927 | hbuss | 93 | { |
94 | J17Blinkcount = Parameter_J17Timing-1; |
||
95 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
||
1254 | killagreg | 96 | if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
97 | } |
||
927 | hbuss | 98 | } |
1423 | hbuss | 99 | else |
100 | if(!J17Blinkcount--) |
||
101 | { |
||
102 | J17Blinkcount = 10-1; |
||
103 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
||
104 | if(J17Mask & EE_Parameter.WARN_J17_Bitmask) J17_ON; else J17_OFF; |
||
105 | } |
||
106 | } |
||
927 | hbuss | 107 | } |
1423 | hbuss | 108 |