Rev 1805 | Rev 1845 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1805 | Rev 1821 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | // To access the DebugOut struct. |
55 | // To access the DebugOut struct. |
56 | #include "uart0.h" |
56 | #include "uart0.h" |
57 | uint8_t flashCnt[2], flashMask[2]; |
57 | uint8_t flashCnt[2], flashMask[2]; |
58 | // initializes the LED control outputs J16, J17 |
58 | // initializes the LED control outputs J16, J17 |
59 | void output_init(void) { |
59 | void output_init(void) { |
60 | // set PC2 & PC3 as output (control of J16 & J17) |
60 | // set PC2 & PC3 as output (control of J16 & J17) |
61 | DDRC |= (1<<DDC2)|(1<<DDC3); |
61 | DDRC |= (1 << DDC2) | (1 << DDC3); |
- | 62 | OUTPUT_SET(0,0); |
|
62 | OUTPUT_SET(0,0); OUTPUT_SET(1,0); |
63 | OUTPUT_SET(1,0); |
63 | flashCnt[0] = flashCnt[1] = 0; |
64 | flashCnt[0] = flashCnt[1] = 0; |
64 | flashMask[0] = flashMask[1] = 128; |
65 | flashMask[0] = flashMask[1] = 128; |
65 | } |
66 | } |
Line 66... | Line 67... | ||
66 | 67 | ||
- | 68 | void flashingLight(uint8_t port, uint8_t timing, uint8_t bitmask, |
|
67 | void flashingLight(uint8_t port, uint8_t timing, uint8_t bitmask, uint8_t manual) { |
69 | uint8_t manual) { |
68 | if (timing > 250 && manual > 230) { |
70 | if (timing > 250 && manual > 230) { |
69 | // "timing" is set to "manual" and the value is very high --> Set to the value in bitmask bit 7. |
71 | // "timing" is set to "manual" and the value is very high --> Set to the value in bitmask bit 7. |
70 | OUTPUT_SET(port, bitmask & 128); |
72 | OUTPUT_SET(port, bitmask & 128); |
71 | } else if (timing > 250 && manual < 10) { |
73 | } else if (timing > 250 && manual < 10) { |
72 | // "timing" is set to "manual" and the value is very low --> Set to the negated value in bitmask bit 7. |
74 | // "timing" is set to "manual" and the value is very low --> Set to the negated value in bitmask bit 7. |
73 | OUTPUT_SET(port, !(bitmask & 128)); |
75 | OUTPUT_SET(port, !(bitmask & 128)); |
74 | } else if(!flashCnt[port]--) { |
76 | } else if (!flashCnt[port]--) { |
75 | // rotating mask over bitmask... |
77 | // rotating mask over bitmask... |
76 | flashCnt[port] = timing - 1; |
78 | flashCnt[port] = timing - 1; |
- | 79 | if (flashMask[port] == 1) |
|
- | 80 | flashMask[port] = 128; |
|
- | 81 | else |
|
77 | if(flashMask[port] == 1) flashMask[port] = 128; else flashMask[port] >>= 1; |
82 | flashMask[port] >>= 1; |
78 | OUTPUT_SET(port, flashMask[port] & bitmask); |
83 | OUTPUT_SET(port, flashMask[port] & bitmask); |
79 | } |
84 | } |
Line 80... | Line 85... | ||
80 | } |
85 | } |
81 | 86 | ||
82 | void flashingLights(void) { |
87 | void flashingLights(void) { |
83 | static int8_t delay = 0; |
88 | static int8_t delay = 0; |
84 | if(!delay--) { // 10 ms intervals |
89 | if (!delay--) { // 10 ms intervals |
- | 90 | delay = 4; |
|
85 | delay = 4; |
91 | flashingLight(0, staticParams.J16Timing, staticParams.J16Bitmask, |
- | 92 | dynamicParams.J16Timing); |
|
86 | flashingLight(0, staticParams.J16Timing, staticParams.J16Bitmask, dynamicParams.J16Timing); |
93 | flashingLight(1, staticParams.J17Timing, staticParams.J17Bitmask, |
87 | flashingLight(1, staticParams.J17Timing, staticParams.J17Bitmask, dynamicParams.J17Timing); |
94 | dynamicParams.J17Timing); |
Line 88... | Line 95... | ||
88 | } |
95 | } |
89 | } |
96 | } |
90 | 97 | ||
91 | /* |
98 | /* |
92 | * Set to 0 for using outputs as the usual flashing lights. |
99 | * Set to 0 for using outputs as the usual flashing lights. |
Line 93... | Line 100... | ||
93 | * Set to one of the DEBUG_... constants in output.h for using the outputs as debug lights. |
100 | * Set to one of the DEBUG_... constants in output.h for using the outputs as debug lights. |
94 | */ |
101 | */ |
95 | #define DIGITAL_DEBUG_MASK DEBUG_MK3MAG |
102 | #define DIGITAL_DEBUG_MASK DEBUG_MK3MAG |
96 | 103 | ||
97 | void output_update(void) { |
104 | void output_update(void) { |
98 | uint8_t output0, output1; |
105 | uint8_t output0, output1; |
99 | if (!DIGITAL_DEBUG_MASK) |
106 | if (!DIGITAL_DEBUG_MASK) |
100 | flashingLights(); |
107 | flashingLights(); |
101 | else { |
108 | else { |