Rev 1887 | Rev 1960 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1887 | Rev 1908 | ||
---|---|---|---|
1 | #ifndef _OUTPUT_H |
1 | #ifndef _OUTPUT_H |
2 | #define _OUTPUT_H |
2 | #define _OUTPUT_H |
3 | 3 | ||
4 | #include <avr/io.h> |
4 | #include <avr/io.h> |
5 | 5 | ||
6 | #define J3HIGH PORTD |= (1<<PORTD5) |
6 | #define J3HIGH PORTD |= (1<<PORTD5) |
7 | #define J3LOW PORTD &= ~(1<<PORTD5) |
7 | #define J3LOW PORTD &= ~(1<<PORTD5) |
8 | #define J3TOGGLE PORTD ^= (1<<PORTD5) |
8 | #define J3TOGGLE PORTD ^= (1<<PORTD5) |
9 | 9 | ||
10 | #define J4HIGH PORTD |= (1<<PORTD4) |
10 | #define J4HIGH PORTD |= (1<<PORTD4) |
11 | #define J4LOW PORTD &= ~(1<<PORTD4) |
11 | #define J4LOW PORTD &= ~(1<<PORTD4) |
12 | #define J4TOGGLE PORTD ^= (1<<PORTD4) |
12 | #define J4TOGGLE PORTD ^= (1<<PORTD4) |
13 | 13 | ||
14 | #define J5HIGH PORTD |= (1<<PORTD3) |
14 | #define J5HIGH PORTD |= (1<<PORTD3) |
15 | #define J5LOW PORTD &= ~(1<<PORTD3) |
15 | #define J5LOW PORTD &= ~(1<<PORTD3) |
16 | #define J5TOGGLE PORTD ^= (1<<PORTD3) |
16 | #define J5TOGGLE PORTD ^= (1<<PORTD3) |
17 | 17 | ||
18 | // invert means: An "1" bit in digital debug data make a LOW on the output. |
18 | // invert means: An "1" bit in digital debug data make a LOW on the output. |
19 | #define DIGITAL_DEBUG_INVERT 0 |
19 | #define DIGITAL_DEBUG_INVERT 0 |
20 | 20 | ||
21 | #define OUTPUT_HIGH(num) {PORTC |= (4 << (num));} |
21 | #define OUTPUT_HIGH(num) {PORTC |= (4 << (num));} |
22 | #define OUTPUT_LOW(num) {PORTC &= ~(4 << (num));} |
22 | #define OUTPUT_LOW(num) {PORTC &= ~(4 << (num));} |
23 | #define OUTPUT_SET(num, state) {if (DIGITAL_DEBUG_INVERT){if(state) OUTPUT_LOW(num) else OUTPUT_HIGH(num)} else {if(state) OUTPUT_HIGH(num) else OUTPUT_LOW(num)}} |
23 | #define OUTPUT_SET(num, state) {if (DIGITAL_DEBUG_INVERT){if(state) OUTPUT_LOW(num) else OUTPUT_HIGH(num)} else {if(state) OUTPUT_HIGH(num) else OUTPUT_LOW(num)}} |
24 | #define OUTPUT_TOGGLE(num) ( {PORTC ^= (4 << (num));} |
24 | #define OUTPUT_TOGGLE(num) ( {PORTC ^= (4 << (num));} |
25 | 25 | ||
26 | /* |
26 | /* |
27 | * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs, |
27 | * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs, |
28 | * turned on and off depending on some condtions given in the code. |
28 | * turned on and off depending on some condtions given in the code. |
29 | * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value |
29 | * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value |
30 | * of the debug. |
30 | * of the debug. |
31 | * In the code one can do like: |
31 | * In the code one can do like: |
32 | * if (whatever_condition) { |
32 | * if (whatever_condition) { |
33 | * DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER; |
33 | * DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER; |
34 | * } else { |
34 | * } else { |
35 | * DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER; |
35 | * DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER; |
36 | * } |
36 | * } |
37 | * ... |
37 | * ... |
38 | * if (whatever_other_condition) { |
38 | * if (whatever_other_condition) { |
39 | * DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER; |
39 | * DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER; |
40 | * } else { |
40 | * } else { |
41 | * DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER; |
41 | * DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER; |
42 | * } |
42 | * } |
43 | * |
43 | * |
44 | * Digital debugs may be added as desired, and removed when the mystery |
44 | * Digital debugs may be added as desired, and removed when the mystery |
45 | * at hand is resolved. |
45 | * at hand is resolved. |
46 | */ |
46 | */ |
- | 47 | ||
47 | 48 | // Both on |
|
- | 49 | #define DEBUG_LEDTEST_ON 1000 |
|
- | 50 | ||
48 | #define DEBUG_LEDTEST_ON 1000 |
51 | // Both off |
- | 52 | #define DEBUG_LEDTEST_OFF 1001 |
|
- | 53 | ||
49 | #define DEBUG_LEDTEST_OFF 1001 |
54 | // #0 on |
- | 55 | #define DEBUG_LEDTEST_0 1002 |
|
- | 56 | ||
50 | #define DEBUG_LEDTEST_0 1002 |
57 | // #1 on |
51 | #define DEBUG_LEDTEST_1 1003 |
58 | #define DEBUG_LEDTEST_1 1003 |
52 | 59 | ||
53 | #define DEBUG_MAINLOOP_TIMER 1 |
60 | #define DEBUG_MAINLOOP_TIMER 1 |
54 | #define DEBUG_HEIGHT_DIFF 2 |
61 | #define DEBUG_HEIGHT_DIFF 2 |
55 | #define DEBUG_HOVERTHROTTLE 4 |
62 | #define DEBUG_HOVERTHROTTLE 4 |
56 | #define DEBUG_ACC0THORDER 8 |
63 | #define DEBUG_ACC0THORDER 8 |
57 | #define DEBUG_COMMANDREPEATED 16 |
64 | #define DEBUG_COMMANDREPEATED 16 |
58 | #define DEBUG_PRESSURERANGE 32 |
65 | #define DEBUG_PRESSURERANGE 32 |
59 | #define DEBUG_CLIP 64 |
66 | #define DEBUG_CLIP 64 |
60 | #define DEBUG_SENSORLIMIT 128 |
67 | #define DEBUG_SENSORLIMIT 128 |
61 | 68 | ||
62 | /* |
69 | /* |
63 | * Set to 0 for using outputs as the usual flashing lights. |
70 | * Set to 0 for using outputs as the usual flashing lights. |
64 | * Set to one of the DEBUG_... defines h for using the outputs as debug lights. |
71 | * Set to one of the DEBUG_... defines h for using the outputs as debug lights. |
65 | */ |
72 | */ |
66 | #define DIGITAL_DEBUG_MASK DEBUG_CLIP |
73 | #define DIGITAL_DEBUG_MASK DEBUG_ACC0THORDER |
67 | 74 | ||
68 | void output_init(void); |
75 | void output_init(void); |
69 | void output_update(void); |
76 | void output_update(void); |
70 | void beep(uint16_t millis); |
77 | void beep(uint16_t millis); |
71 | void beepNumber(uint8_t numbeeps); |
78 | void beepNumber(uint8_t numbeeps); |
72 | void beepRCAlarm(void); |
79 | void beepRCAlarm(void); |
73 | void beepI2CAlarm(void); |
80 | void beepI2CAlarm(void); |
74 | void beepBatteryAlarm(void); |
81 | void beepBatteryAlarm(void); |
75 | 82 | ||
76 | #endif //_output_H |
83 | #endif //_output_H |
77 | 84 |