Rev 1994 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1994 | Rev 1995 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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; /// MartinW: removed because of switching during calibration, not useful for activate fireworks |
|
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 | // called in UpdateMotors() every 2ms |
20 | // called in UpdateMotors() every 2ms |
21 | void LED_Update(void) |
21 | void LED_Update(void) |
22 | { |
22 | { |
23 | static char delay = 0; |
23 | static char delay = 0; |
24 | static unsigned char J16Bitmask = 0; |
24 | static unsigned char J16Bitmask = 0; |
25 | static unsigned char J17Bitmask = 0; |
25 | static unsigned char J17Bitmask = 0; |
26 | static unsigned char J16Warn = 0, J17Warn = 0; |
26 | static unsigned char J16Warn = 0, J17Warn = 0; |
27 | if(!delay--) // 20ms Intervall |
27 | if(!delay--) // 20ms Intervall |
28 | { |
28 | { |
29 | delay = 9; |
29 | delay = 9; |
30 | if(FC_StatusFlags & (FC_STATUS_LOWBAT | FC_STATUS_EMERGENCY_LANDING) || (VersionInfo.HardwareError[1] & FC_ERROR1_I2C)) |
30 | if(FC_StatusFlags & (FC_STATUS_LOWBAT | FC_STATUS_EMERGENCY_LANDING) || (VersionInfo.HardwareError[1] & FC_ERROR1_I2C)) |
31 | { |
31 | { |
32 | if(EE_Parameter.WARN_J16_Bitmask) |
32 | if(EE_Parameter.WARN_J16_Bitmask) |
33 | { |
33 | { |
34 | if(!J16Warn) J16Blinkcount = 4; |
34 | if(!J16Warn) J16Blinkcount = 4; |
35 | J16Warn = 1; |
35 | J16Warn = 1; |
36 | } |
36 | } |
37 | if(EE_Parameter.WARN_J17_Bitmask) |
37 | if(EE_Parameter.WARN_J17_Bitmask) |
38 | { |
38 | { |
39 | if(!J17Warn) J17Blinkcount = 4; |
39 | if(!J17Warn) J17Blinkcount = 4; |
40 | J17Warn = 1; |
40 | J17Warn = 1; |
41 | } |
41 | } |
42 | } |
42 | } |
43 | else |
43 | else |
44 | { |
44 | { |
45 | J16Warn = 0; |
45 | J16Warn = 0; |
46 | J17Warn = 0; |
46 | J17Warn = 0; |
47 | J16Bitmask = EE_Parameter.J16Bitmask; |
47 | J16Bitmask = EE_Parameter.J16Bitmask; |
48 | J17Bitmask = EE_Parameter.J17Bitmask; |
48 | J17Bitmask = EE_Parameter.J17Bitmask; |
49 | } |
49 | } |
50 | 50 | ||
51 | if(!J16Warn) |
51 | if(!J16Warn) |
52 | { |
52 | { |
53 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK1) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;} |
53 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK1) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;} |
54 | else |
54 | else |
55 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;} |
55 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;} |
56 | else |
56 | else |
57 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing == 5)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} |
57 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing == 5)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} |
58 | else |
58 | else |
59 | if(!J16Blinkcount--) |
59 | if(!J16Blinkcount--) |
60 | { |
60 | { |
61 | J16Blinkcount = Parameter_J16Timing / 2; |
61 | J16Blinkcount = Parameter_J16Timing / 2; |
62 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
62 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
63 | if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
63 | if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
64 | } |
64 | } |
65 | } |
65 | } |
66 | else |
66 | else |
67 | if(!J16Blinkcount--) |
67 | if(!J16Blinkcount--) |
68 | { |
68 | { |
69 | J16Blinkcount = 10-1; |
69 | J16Blinkcount = 10-1; |
70 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
70 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
71 | if(J16Mask & EE_Parameter.WARN_J16_Bitmask) J16_ON; else J16_OFF; |
71 | if(J16Mask & EE_Parameter.WARN_J16_Bitmask) J16_ON; else J16_OFF; |
72 | } |
72 | } |
73 | 73 | ||
74 | if(!J17Warn) |
74 | if(!J17Warn) |
75 | { |
75 | { |
76 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK2) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;} |
76 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK2) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;} |
77 | else |
77 | else |
78 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing > 220)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;} |
78 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing > 220)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;} |
79 | else |
79 | else |
80 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing == 5)) {if(J17Bitmask & 128) J17_OFF; else J17_ON;} |
80 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing == 5)) {if(J17Bitmask & 128) J17_OFF; else J17_ON;} |
81 | else |
81 | else |
82 | if(!J17Blinkcount--) |
82 | if(!J17Blinkcount--) |
83 | { |
83 | { |
84 | J17Blinkcount = Parameter_J17Timing / 2; |
84 | J17Blinkcount = Parameter_J17Timing / 2; |
85 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
85 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
86 | if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
86 | if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
87 | } |
87 | } |
88 | } |
88 | } |
89 | else |
89 | else |
90 | if(!J17Blinkcount--) |
90 | if(!J17Blinkcount--) |
91 | { |
91 | { |
92 | J17Blinkcount = 10-1; |
92 | J17Blinkcount = 10-1; |
93 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
93 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
94 | if(J17Mask & EE_Parameter.WARN_J17_Bitmask) J17_ON; else J17_OFF; |
94 | if(J17Mask & EE_Parameter.WARN_J17_Bitmask) J17_ON; else J17_OFF; |
95 | } |
95 | } |
96 | } |
96 | } |
97 | } |
97 | } |
98 | 98 |