Rev 2071 | Rev 2088 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2071 | Rev 2073 | ||
---|---|---|---|
Line 121... | Line 121... | ||
121 | uint16_t simpleAirPressure; |
121 | uint16_t simpleAirPressure; |
Line 122... | Line 122... | ||
122 | 122 | ||
123 | // Value of AIRPRESSURE_OVERSAMPLING samples, with range, filtered. |
123 | // Value of AIRPRESSURE_OVERSAMPLING samples, with range, filtered. |
Line 124... | Line 124... | ||
124 | int32_t filteredAirPressure; |
124 | int32_t filteredAirPressure; |
125 | 125 | ||
126 | #define MAX_D_AIRPRESSURE_WINDOW_LENGTH 5 |
126 | #define MAX_D_AIRPRESSURE_WINDOW_LENGTH 32 |
127 | //int32_t lastFilteredAirPressure; |
127 | //int32_t lastFilteredAirPressure; |
Line 128... | Line 128... | ||
128 | int16_t dAirPressureWindow[MAX_D_AIRPRESSURE_WINDOW_LENGTH]; |
128 | int16_t dAirPressureWindow[MAX_D_AIRPRESSURE_WINDOW_LENGTH]; |
129 | uint8_t dWindowPtr; |
129 | uint8_t dWindowPtr = 0; |
130 | 130 | ||
131 | #define MAX_AIRPRESSURE_WINDOW_LENGTH 32 |
131 | #define MAX_AIRPRESSURE_WINDOW_LENGTH 32 |
Line 132... | Line 132... | ||
132 | int16_t airPressureWindow[MAX_AIRPRESSURE_WINDOW_LENGTH]; |
132 | int16_t airPressureWindow[MAX_AIRPRESSURE_WINDOW_LENGTH]; |
133 | int32_t windowedAirPressure; |
133 | int32_t windowedAirPressure; |
Line 134... | Line 134... | ||
134 | uint8_t windowPtr; |
134 | uint8_t windowPtr = 0; |
Line 486... | Line 486... | ||
486 | } else { |
486 | } else { |
487 | // use windowed. |
487 | // use windowed. |
488 | windowedAirPressure += simpleAirPressure; |
488 | windowedAirPressure += simpleAirPressure; |
489 | windowedAirPressure -= airPressureWindow[windowPtr]; |
489 | windowedAirPressure -= airPressureWindow[windowPtr]; |
490 | airPressureWindow[windowPtr++] = simpleAirPressure; |
490 | airPressureWindow[windowPtr++] = simpleAirPressure; |
491 | if (windowPtr == staticParams.airpressureWindowLength) windowPtr = 0; |
491 | if (windowPtr >= staticParams.airpressureWindowLength) windowPtr = 0; |
492 | filteredAirPressure = windowedAirPressure / staticParams.airpressureWindowLength; |
492 | filteredAirPressure = windowedAirPressure / staticParams.airpressureWindowLength; |
493 | } |
493 | } |
Line 494... | Line 494... | ||
494 | 494 | ||
495 | dAirPressureWindow[dWindowPtr++] = (int16_t)(filteredAirPressure - lastFilteredAirPressure); |
495 | dAirPressureWindow[dWindowPtr++] = (int16_t)(filteredAirPressure - lastFilteredAirPressure); |
Line 496... | Line 496... | ||
496 | if (dWindowPtr == staticParams.dAirpressureWindowLength) dWindowPtr = 0; |
496 | if (dWindowPtr >= staticParams.airpressureDWindowLength) dWindowPtr = 0; |
497 | 497 | ||
498 | pressureMeasurementCount = airPressureSum = 0; |
498 | pressureMeasurementCount = airPressureSum = 0; |
499 | } |
499 | } |
Line 622... | Line 622... | ||
622 | return groundPressure - filteredAirPressure; |
622 | return groundPressure - filteredAirPressure; |
623 | } |
623 | } |
Line 624... | Line 624... | ||
624 | 624 | ||
625 | int16_t analog_getDHeight(void) { |
625 | int16_t analog_getDHeight(void) { |
626 | int16_t result = 0; |
626 | int16_t result = 0; |
627 | for (int i=0; i<staticParams.dAirpressureWindowLength; i++) { |
627 | for (int i=0; i<staticParams.airpressureDWindowLength; i++) { |
628 | result += dAirPressureWindow[i]; |
628 | result -= dAirPressureWindow[i]; // minus pressure is plus height. |
Line -... | Line 629... | ||
- | 629 | } |
|
629 | } |
630 | |
630 | 631 | debugOut.analog[30] = result; |
|
631 | // dHeight = -dPressure, so here it is the old pressure minus the current, not opposite. |
632 | // dHeight = -dPressure, so here it is the old pressure minus the current, not opposite. |