Rev 2079 | Rev 2088 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2079 | Rev 2086 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | #define LATCH_TIME 3 |
15 | #define LATCH_TIME 3 |
Line 16... | Line 16... | ||
16 | 16 | ||
17 | int32_t setHeight; |
17 | int32_t setHeight; |
Line 18... | Line 18... | ||
18 | int32_t targetHeight; |
18 | int32_t targetHeight; |
19 | 19 | ||
Line 20... | Line 20... | ||
20 | uint16_t testOscPrescaler = 0; |
20 | uint16_t hc_testOscPrescaler = 0; |
21 | uint8_t testOscTimer = 0; |
21 | uint8_t hc_testOscTimer = 0; |
Line 22... | Line 22... | ||
22 | 22 | ||
23 | int32_t maxHeightThisFlight; |
23 | int32_t maxHeightThisFlight; |
24 | int32_t iHeight; |
24 | int32_t iHeight; |
25 | 25 | ||
26 | void HC_setGround(void) { |
26 | void HC_setGround(void) { |
27 | analog_setGround(); |
27 | analog_setGround(); |
28 | // This should also happen when height control is enabled in-flight. |
28 | // This should also happen when height control is enabled in-flight. |
29 | setHeight = targetHeight = analog_getHeight(); |
29 | setHeight = targetHeight = analog_getHeight(); |
Line 30... | Line 30... | ||
30 | testOscTimer = 0; |
30 | hc_testOscTimer = 0; |
Line 50... | Line 50... | ||
50 | // Switch is ON |
50 | // Switch is ON |
51 | if (setHeightLatch <= LATCH_TIME) { |
51 | if (setHeightLatch <= LATCH_TIME) { |
52 | if (setHeightLatch == LATCH_TIME) { |
52 | if (setHeightLatch == LATCH_TIME) { |
53 | // Freeze the height as target. We want to do this exactly once each time the switch is thrown ON. |
53 | // Freeze the height as target. We want to do this exactly once each time the switch is thrown ON. |
54 | setHeight = height; |
54 | setHeight = height; |
55 | testOscTimer = 0; |
55 | hc_testOscTimer = 0; |
56 | iHeight = 0; |
56 | iHeight = 0; |
57 | } |
57 | } |
58 | // Time not yet reached. |
58 | // Time not yet reached. |
59 | setHeightLatch++; |
59 | setHeightLatch++; |
60 | } |
60 | } |
Line 88... | Line 88... | ||
88 | } |
88 | } |
89 | */ |
89 | */ |
90 | // uint8_t heightControlTestOscPeriod; |
90 | // uint8_t heightControlTestOscPeriod; |
91 | // uint8_t heightControlTestOscAmplitude; |
91 | // uint8_t heightControlTestOscAmplitude; |
Line 92... | Line 92... | ||
92 | 92 | ||
93 | testOscPrescaler++; |
93 | hc_testOscPrescaler++; |
94 | if (testOscPrescaler == 488) { |
94 | if (hc_testOscPrescaler == 488) { |
95 | testOscPrescaler = 0; |
95 | hc_testOscPrescaler = 0; |
96 | testOscTimer++; |
96 | hc_testOscTimer++; |
97 | if (testOscTimer == staticParams.heightControlTestOscPeriod) { |
97 | if (hc_testOscTimer == staticParams.heightControlTestOscPeriod) { |
98 | testOscTimer = 0; |
98 | hc_testOscTimer = 0; |
99 | if (staticParams.heightControlTestOscAmplitude) |
99 | if (staticParams.heightControlTestOscAmplitude) |
100 | iHeight = 0; |
100 | iHeight = 0; |
101 | } else if (testOscTimer == staticParams.heightControlTestOscPeriod/2) { |
101 | } else if (hc_testOscTimer == staticParams.heightControlTestOscPeriod/2) { |
102 | if (staticParams.heightControlTestOscAmplitude) |
102 | if (staticParams.heightControlTestOscAmplitude) |
103 | iHeight = 0; |
103 | iHeight = 0; |
104 | } |
104 | } |
Line 105... | Line 105... | ||
105 | } |
105 | } |
106 | 106 | ||
107 | if (testOscTimer < staticParams.heightControlTestOscPeriod/2) |
107 | if (hc_testOscTimer < staticParams.heightControlTestOscPeriod/2) |
108 | targetHeight = setHeight; |
108 | targetHeight = setHeight; |
Line 109... | Line 109... | ||
109 | else |
109 | else |