Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
886 | killagreg | 1 | #include <inttypes.h> |
2 | #include "led.h" |
||
3 | #include "fc.h" |
||
936 | killagreg | 4 | #include "eeprom.h" |
886 | killagreg | 5 | |
936 | killagreg | 6 | uint8_t J16Blinkcount = 0, J16Mask = 1; |
7 | uint8_t J17Blinkcount = 0, J17Mask = 1; |
||
886 | killagreg | 8 | |
9 | // initializes the LED control outputs J16, J17 |
||
10 | void LED_Init(void) |
||
11 | { |
||
12 | // set PC2 & PC3 as output (control of J16 & J17) |
||
13 | DDRC |= (1<<DDC2)|(1<<DDC3); |
||
14 | J16_OFF; |
||
15 | J17_OFF; |
||
936 | killagreg | 16 | J16Blinkcount = 0; J16Mask = 128; |
17 | J17Blinkcount = 0; J17Mask = 128; |
||
886 | killagreg | 18 | } |
19 | |||
20 | |||
936 | killagreg | 21 | // called in main loop every 2ms |
886 | killagreg | 22 | void LED_Update(void) |
23 | { |
||
936 | killagreg | 24 | static int8_t delay = 0; |
886 | killagreg | 25 | |
936 | killagreg | 26 | if(!delay--) // 10 ms intervall |
886 | killagreg | 27 | { |
936 | killagreg | 28 | delay = 4; |
886 | killagreg | 29 | |
936 | killagreg | 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 | { |
||
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; |
||
46 | } |
||
47 | |||
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; |
||
57 | } |
||
58 | else if(!J17Blinkcount--) |
||
59 | { |
||
60 | J17Blinkcount = FCParam.J17Timing - 1; |
||
61 | if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
||
62 | if(J17Mask & ParamSet.J17Bitmask) J17_ON; else J17_OFF; |
||
63 | } |
||
886 | killagreg | 64 | } |
65 | } |