Skip to content

Commit c28a468

Browse files
Merge pull request #10948 from sensei-hacker/maintenance-8.x.x
Merge Maintenance 8.x.x to master
2 parents 6ee683a + 188550f commit c28a468

13 files changed

Lines changed: 657 additions & 157 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ else()
5151
endif()
5252
endif()
5353

54+
5455
project(INAV VERSION 9.0.0)
5556

57+
5658
enable_language(ASM)
5759

5860
if(MACOSX AND SITL)

docs/OSD.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Not all OSDs are created equally. This table shows the differences between the d
2626
| DJI O3 Goggles V2 + WTFOS | 53 x 20 | X | | X | YES |
2727
| DJI Goggles 2 and newer | 53 x 20 (HD) | X | | X | YES (no custom fonts) |
2828

29+
2930
## OSD Elements
3031
Here are the OSD Elements provided by INAV.
3132

docs/development/serial_printf_debugging.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ log) by defining USE_BOOTLOG:
147147
Then `make clean` and `make`.
148148

149149
Then in the CLI you can run `bootlog` to see the buffered log.
150+
150151
Note bootlog also requires that a serial port be defined for serial debugging.
152+

src/main/common/lulu.c

Lines changed: 99 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -16,164 +16,108 @@
1616
#endif /* __ARM_ACLE */
1717
#include <fenv.h>
1818

19-
void luluFilterInit(luluFilter_t *filter, int N)
20-
{
21-
filter->N = constrain(N, 1, 15);
22-
filter->windowSize = filter->N * 2 + 1;
23-
filter->windowBufIndex = 0;
24-
25-
memset(filter->luluInterim, 0, sizeof(float) * (filter->windowSize));
26-
memset(filter->luluInterimB, 0, sizeof(float) * (filter->windowSize));
27-
}
19+
void luluFilterInit(luluFilter_t *filter, int N) {
20+
filter->N = constrain(N, 1, 15);
21+
filter->windowSize = filter->N * 2 + 1;
22+
filter->windowBufIndex = 0;
2823

29-
FAST_CODE float fixRoad(float *series, float *seriesB, int index, int filterN, int windowSize)
30-
{
31-
float curVal = 0;
32-
float curValB = 0;
33-
for (int N = 1; N <= filterN; N++)
34-
{
35-
int indexNeg = (index + windowSize - 2 * N) % windowSize;
36-
int curIndex = (indexNeg + 1) % windowSize;
37-
float prevVal = series[indexNeg];
38-
float prevValB = seriesB[indexNeg];
39-
int indexPos = (curIndex + N) % windowSize;
40-
41-
for (int i = windowSize - 2 * N; i < windowSize - N; i++)
42-
{
43-
if (indexPos >= windowSize)
44-
{
45-
indexPos = 0;
46-
}
47-
if (curIndex >= windowSize)
48-
{
49-
curIndex = 0;
50-
}
51-
// curIndex = (2 - 1) % 3 = 1
52-
curVal = series[curIndex];
53-
curValB = seriesB[curIndex];
54-
float nextVal = series[indexPos];
55-
float nextValB = seriesB[indexPos];
56-
// onbump (s, 1, 1, 3)
57-
// if(onBump(series, curIndex, N, windowSize))
58-
if (prevVal < curVal && curVal > nextVal)
59-
{
60-
float maxValue = MAX(prevVal, nextVal);
61-
62-
series[curIndex] = maxValue;
63-
int k = curIndex;
64-
for (int j = 1; j < N; j++)
65-
{
66-
if (++k >= windowSize)
67-
{
68-
k = 0;
69-
}
70-
series[k] = maxValue;
71-
}
72-
}
73-
74-
if (prevValB < curValB && curValB > nextValB)
75-
{
76-
float maxValue = MAX(prevValB, nextValB);
77-
78-
curVal = maxValue;
79-
seriesB[curIndex] = maxValue;
80-
int k = curIndex;
81-
for (int j = 1; j < N; j++)
82-
{
83-
if (++k >= windowSize)
84-
{
85-
k = 0;
86-
}
87-
seriesB[k] = maxValue;
88-
}
89-
}
90-
prevVal = curVal;
91-
prevValB = curValB;
92-
curIndex++;
93-
indexPos++;
94-
}
95-
96-
curIndex = (indexNeg + 1) % windowSize;
97-
prevVal = series[indexNeg];
98-
prevValB = seriesB[indexNeg];
99-
indexPos = (curIndex + N) % windowSize;
100-
for (int i = windowSize - 2 * N; i < windowSize - N; i++)
101-
{
102-
if (indexPos >= windowSize)
103-
{
104-
indexPos = 0;
105-
}
106-
if (curIndex >= windowSize)
107-
{
108-
curIndex = 0;
109-
}
110-
// curIndex = (2 - 1) % 3 = 1
111-
curVal = series[curIndex];
112-
curValB = seriesB[curIndex];
113-
float nextVal = series[indexPos];
114-
float nextValB = seriesB[indexPos];
115-
116-
if (prevVal > curVal && curVal < nextVal)
117-
{
118-
float minValue = MIN(prevVal, nextVal);
119-
120-
curVal = minValue;
121-
series[curIndex] = minValue;
122-
int k = curIndex;
123-
for (int j = 1; j < N; j++)
124-
{
125-
if (++k >= windowSize)
126-
{
127-
k = 0;
128-
}
129-
series[k] = minValue;
130-
}
131-
}
132-
133-
if (prevValB > curValB && curValB < nextValB)
134-
{
135-
float minValue = MIN(prevValB, nextValB);
136-
curValB = minValue;
137-
seriesB[curIndex] = minValue;
138-
int k = curIndex;
139-
for (int j = 1; j < N; j++)
140-
{
141-
if (++k >= windowSize)
142-
{
143-
k = 0;
144-
}
145-
seriesB[k] = minValue;
146-
}
147-
}
148-
prevVal = curVal;
149-
prevValB = curValB;
150-
curIndex++;
151-
indexPos++;
152-
}
153-
}
154-
return (curVal - curValB) / 2;
24+
memset(filter->luluInterim, 0, sizeof(float) * (filter->windowSize));
25+
memset(filter->luluInterimB, 0, sizeof(float) * (filter->windowSize));
15526
}
15627

157-
FAST_CODE float luluFilterPartialApply(luluFilter_t *filter, float input)
158-
{
159-
// This is the value N of the LULU filter.
160-
int filterN = filter->N;
161-
// This is the total window size for the rolling buffer
162-
int filterWindow = filter->windowSize;
163-
164-
int windowIndex = filter->windowBufIndex;
165-
float inputVal = input;
166-
int newIndex = (windowIndex + 1) % filterWindow;
167-
filter->windowBufIndex = newIndex;
168-
filter->luluInterim[windowIndex] = inputVal;
169-
filter->luluInterimB[windowIndex] = -inputVal;
170-
return fixRoad(filter->luluInterim, filter->luluInterimB, windowIndex, filterN, filterWindow);
28+
FAST_CODE float fixRoad(float *series, float *seriesB, int index, int filterN, int windowSize) {
29+
float curVal = 0;
30+
float curValB = 0;
31+
for (int N = 1; N <= filterN; N++) {
32+
int indexNeg = (index + windowSize - 2 * N) % windowSize;
33+
int curIndex = (indexNeg + 1) % windowSize;
34+
float prevVal = series[indexNeg];
35+
float prevValB = seriesB[indexNeg];
36+
int indexPos = (curIndex + N) % windowSize;
37+
for (int i = windowSize - 2 * N; i < windowSize - N; i++) {
38+
if (indexPos >= windowSize) {
39+
indexPos = 0;
40+
}
41+
if (curIndex >= windowSize) {
42+
curIndex = 0;
43+
}
44+
45+
curVal = series[curIndex];
46+
curValB = seriesB[curIndex];
47+
float nextVal = series[indexPos];
48+
float nextValB = seriesB[indexPos];
49+
50+
if (prevVal < curVal && curVal > nextVal) {
51+
float maxValue = MAX(prevVal, nextVal);
52+
series[curIndex] = maxValue;
53+
}
54+
55+
if (prevValB < curValB && curValB > nextValB) {
56+
float maxValue = MAX(prevValB, nextValB);
57+
seriesB[curIndex] = maxValue;
58+
}
59+
prevVal = curVal;
60+
prevValB = curValB;
61+
curIndex++;
62+
indexPos++;
63+
}
64+
65+
curIndex = (indexNeg + 1) % windowSize;
66+
prevVal = series[indexNeg];
67+
prevValB = seriesB[indexNeg];
68+
indexPos = (curIndex + N) % windowSize;
69+
for (int i = windowSize - 2 * N; i < windowSize - N; i++) {
70+
if (indexPos >= windowSize) {
71+
indexPos = 0;
72+
}
73+
if (curIndex >= windowSize) {
74+
curIndex = 0;
75+
}
76+
77+
curVal = series[curIndex];
78+
curValB = seriesB[curIndex];
79+
float nextVal = series[indexPos];
80+
float nextValB = seriesB[indexPos];
81+
82+
if (prevVal > curVal && curVal < nextVal) {
83+
float minValue = MIN(prevVal, nextVal);
84+
series[curIndex] = minValue;
85+
}
86+
87+
if (prevValB > curValB && curValB < nextValB) {
88+
float minValue = MIN(prevValB, nextValB);
89+
seriesB[curIndex] = minValue;
90+
}
91+
prevVal = curVal;
92+
prevValB = curValB;
93+
curIndex++;
94+
indexPos++;
95+
}
96+
}
97+
int finalIndex = (index + windowSize - filterN) % windowSize;
98+
curVal = series[finalIndex];
99+
curValB = seriesB[finalIndex];
100+
return (curVal - curValB) / 2;
171101
}
172102

173-
FAST_CODE float luluFilterApply(luluFilter_t *filter, float input)
174-
{
175-
// This is the UL filter
176-
float resultA = luluFilterPartialApply(filter, input);
177-
// We use the median interpretation of this filter to remove bias in the output
178-
return resultA;
103+
FAST_CODE float luluFilterPartialApply(luluFilter_t *filter, float input) {
104+
// This is the value N of the LULU filter.
105+
int filterN = filter->N;
106+
// This is the total window size for the rolling buffer
107+
int filterWindow = filter->windowSize;
108+
109+
int windowIndex = filter->windowBufIndex;
110+
float inputVal = input;
111+
int newIndex = (windowIndex + 1) % filterWindow;
112+
filter->windowBufIndex = newIndex;
113+
filter->luluInterim[windowIndex] = inputVal;
114+
filter->luluInterimB[windowIndex] = -inputVal;
115+
return fixRoad(filter->luluInterim, filter->luluInterimB, windowIndex, filterN, filterWindow);
179116
}
117+
118+
FAST_CODE float luluFilterApply(luluFilter_t *filter, float input) {
119+
// This is the UL filter
120+
float resultA = luluFilterPartialApply(filter, input);
121+
// We use the median interpretation of this filter to remove bias in the output
122+
return resultA;
123+
}

src/main/common/lulu.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22

33
// Max N = 15
4-
typedef struct
5-
{
4+
typedef struct {
65
int windowSize;
76
int windowBufIndex;
87
int N;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target_stm32h743xi(TBS_LUCID_H7_WING)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of INAV Project.
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
6+
* You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*
8+
* Alternatively, the contents of this file may be used under the terms
9+
* of the GNU General Public License Version 3, as described below:
10+
*
11+
* This file is free software: you may copy, redistribute and/or modify
12+
* it under the terms of the GNU General Public License as published by the
13+
* Free Software Foundation, either version 3 of the License, or (at your
14+
* option) any later version.
15+
*
16+
* This file is distributed in the hope that it will be useful, but
17+
* WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19+
* Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see http://www.gnu.org/licenses/.
23+
*/
24+
25+
#include "fc/config.h"
26+
27+
#include <stdint.h>
28+
29+
#include "fc/fc_msp_box.h"
30+
#include "io/piniobox.h"
31+
#include "platform.h"
32+
33+
void targetConfiguration(void)
34+
{
35+
pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1;
36+
pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2;
37+
}

0 commit comments

Comments
 (0)