Go to most recent revision | Details | 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; |
1933 | holgerb | 27 | if(!delay--) // 20ms Intervall |
1254 | killagreg | 28 | { |
1933 | holgerb | 29 | delay = 9; |
1769 | holgerb | 30 | if(FC_StatusFlags & (FC_STATUS_LOWBAT | FC_STATUS_EMERGENCY_LANDING) || (VersionInfo.HardwareError[1] & FC_ERROR1_I2C)) |
1254 | killagreg | 31 | { |
1765 | killagreg | 32 | if(EE_Parameter.WARN_J16_Bitmask) |
1423 | hbuss | 33 | { |
34 | if(!J16Warn) J16Blinkcount = 4; |
||
35 | J16Warn = 1; |
||
1765 | killagreg | 36 | } |
37 | if(EE_Parameter.WARN_J17_Bitmask) |
||
1423 | hbuss | 38 | { |
39 | if(!J17Warn) J17Blinkcount = 4; |
||
40 | J17Warn = 1; |
||
1765 | killagreg | 41 | } |
1254 | killagreg | 42 | } |
43 | else |
||
44 | { |
||
1423 | hbuss | 45 | J16Warn = 0; |
46 | J17Warn = 0; |
||
1254 | killagreg | 47 | J16Bitmask = EE_Parameter.J16Bitmask; |
48 | J17Bitmask = EE_Parameter.J17Bitmask; |
||
49 | } |
||
50 | |||
1423 | hbuss | 51 | if(!J16Warn) |
52 | { |
||
1350 | hbuss | 53 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED1) J16_ON; else J16_OFF;} |
927 | hbuss | 54 | else |
1377 | hbuss | 55 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing > 220)) {if(J16Bitmask & 128) J16_ON; else J16_OFF;} |
1350 | hbuss | 56 | else |
1933 | holgerb | 57 | if((EE_Parameter.J16Timing > 247) && (Parameter_J16Timing == 5)) {if(J16Bitmask & 128) J16_OFF; else J16_ON;} |
1254 | killagreg | 58 | else |
59 | if(!J16Blinkcount--) |
||
927 | hbuss | 60 | { |
1933 | holgerb | 61 | J16Blinkcount = Parameter_J16Timing / 2; |
927 | hbuss | 62 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
1254 | killagreg | 63 | if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
64 | } |
||
1423 | hbuss | 65 | } |
1765 | killagreg | 66 | else |
1423 | hbuss | 67 | if(!J16Blinkcount--) |
68 | { |
||
69 | J16Blinkcount = 10-1; |
||
70 | if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
||
71 | if(J16Mask & EE_Parameter.WARN_J16_Bitmask) J16_ON; else J16_OFF; |
||
72 | } |
||
1350 | hbuss | 73 | |
1423 | hbuss | 74 | if(!J17Warn) |
75 | { |
||
1350 | hbuss | 76 | if((EE_Parameter.BitConfig & CFG_MOTOR_BLINK) && !MotorenEin) {if(EE_Parameter.BitConfig & CFG_MOTOR_OFF_LED2) J17_ON; else J17_OFF;} |
927 | hbuss | 77 | else |
1570 | holgerb | 78 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing > 220)) {if(J17Bitmask & 128) J17_ON; else J17_OFF;} |
1350 | hbuss | 79 | else |
1933 | holgerb | 80 | if((EE_Parameter.J17Timing > 247) && (Parameter_J17Timing == 5)) {if(J17Bitmask & 128) J17_OFF; else J17_ON;} |
1254 | killagreg | 81 | else |
82 | if(!J17Blinkcount--) |
||
927 | hbuss | 83 | { |
1933 | holgerb | 84 | J17Blinkcount = Parameter_J17Timing / 2; |
927 | hbuss | 85 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
1254 | killagreg | 86 | if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
87 | } |
||
927 | hbuss | 88 | } |
1765 | killagreg | 89 | else |
1423 | hbuss | 90 | if(!J17Blinkcount--) |
91 | { |
||
92 | J17Blinkcount = 10-1; |
||
93 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
||
94 | if(J17Mask & EE_Parameter.WARN_J17_Bitmask) J17_ON; else J17_OFF; |
||
95 | } |
||
96 | } |
||
927 | hbuss | 97 | } |
1423 | hbuss | 98 |