Skip to content

Commit ea0e023

Browse files
authored
Merge branch 'master' into psd_impromement
2 parents 24aee4a + fea0dc0 commit ea0e023

11 files changed

+389
-188
lines changed

index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,6 +2994,29 @@ <h4 class="modal-title">Advanced User Settings</h4>
29942994
<p>%</p>
29952995
</td>
29962996
</tr>
2997+
<tr>
2998+
<td>
2999+
<label>Legend</label>
3000+
</td>
3001+
<td class="position">
3002+
<label>Top</label>
3003+
<input name="analyser-legend-top" type="number" step="1" min="0"
3004+
max="100" />
3005+
<p>%</p>
3006+
</td>
3007+
<td class="position">
3008+
<label>Left</label>
3009+
<input name="analyser-legend-left" type="number" step="1" min="0"
3010+
max="100" />
3011+
<p>%</p>
3012+
</td>
3013+
<td class="position">
3014+
<label>Width</label>
3015+
<input name="analyser-legend-width" type="number" step="1" min="0"
3016+
max="100" />
3017+
<p>%</p>
3018+
</td>
3019+
</tr>
29973020
</table>
29983021
</div>
29993022
</div>

public/js/webworkers/spectrum-export-worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
onmessage = function(event) {
22
const columnDelimiter = event.data.opts.columnDelimiter;
33
const fftOutput = event.data.fftOutput;
4-
const spectrumDataLength = fftOutput.length / 2;
4+
const spectrumDataLength = fftOutput.length;
55
const frequencyStep = 0.5 * event.data.blackBoxRate / spectrumDataLength;
66

7-
let outText = "freq" + columnDelimiter + "value" + "\n";
8-
for (let index = 0; index < spectrumDataLength; index += 10) {
7+
let outText = "x" + columnDelimiter + "y" + "\n";
8+
for (let index = 0; index < spectrumDataLength; index++) {
99
const frequency = frequencyStep * index;
1010
outText += frequency.toString() + columnDelimiter + fftOutput[index].toString() + "\n";
1111
}

src/flightlog_fielddefs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@ export function adjustFieldDefsList(firmwareType, firmwareVersion) {
550550
DEBUG_MODE.push('WING_SETPOINT');
551551
DEBUG_MODE.push('AUTOPILOT_POSITION');
552552
}
553+
if (semver.gte(firmwareVersion, "4.6.0")) {
554+
//rename DUAL_GYRO_ to MULTI_GYRO
555+
DEBUG_MODE.splice(DEBUG_MODE.indexOf("DUAL_GYRO_RAW"), 1, "MULTI_GYRO_RAW");
556+
DEBUG_MODE.splice(DEBUG_MODE.indexOf("DUAL_GYRO_DIFF"), 1, "MULTI_GYRO_DIFF");
557+
DEBUG_MODE.splice(DEBUG_MODE.indexOf("DUAL_GYRO_SCALED"), 1, "MULTI_GYRO_SCALED");
558+
}
553559

554560
ACC_HARDWARE = makeReadOnly(ACC_HARDWARE);
555561
DEBUG_MODE = makeReadOnly(DEBUG_MODE);

src/flightlog_fields_presenter.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,39 @@ FlightLogFieldPresenter.adjustDebugDefsList = function (
13971397
'debug[4]': 'Processed flow rates Y',
13981398
'debug[5]': 'Delta time',
13991399
};
1400+
DEBUG_FRIENDLY_FIELD_NAMES.MULTI_GYRO_RAW = {
1401+
'debug[all]': 'Debug Multi Gyro Raw',
1402+
'debug[0]': 'Gyro 1 Raw [roll]',
1403+
'debug[1]': 'Gyro 1 Raw [pitch]',
1404+
'debug[2]': 'Gyro 2 Raw [roll]',
1405+
'debug[3]': 'Gyro 2 Raw [pitch]',
1406+
'debug[4]': 'Gyro 3 Raw [roll]',
1407+
'debug[5]': 'Gyro 3 Raw [pitch]',
1408+
'debug[6]': 'Gyro 4 Raw [roll]',
1409+
'debug[7]': 'Gyro 4 Raw [pitch]',
1410+
};
1411+
DEBUG_FRIENDLY_FIELD_NAMES.MULTI_GYRO_DIFF = {
1412+
'debug[all]': 'Debug Multi Gyro Diff',
1413+
'debug[0]': 'Gyro 1 Diff [roll]',
1414+
'debug[1]': 'Gyro 1 Diff [pitch]',
1415+
'debug[2]': 'Gyro 2 Diff [roll]',
1416+
'debug[3]': 'Gyro 2 Diff [pitch]',
1417+
'debug[4]': 'Gyro 3 Diff [roll]',
1418+
'debug[5]': 'Gyro 3 Diff [pitch]',
1419+
'debug[6]': 'Gyro 4 Diff [roll]',
1420+
'debug[7]': 'Gyro 4 Diff [pitch]',
1421+
};
1422+
DEBUG_FRIENDLY_FIELD_NAMES.MULTI_GYRO_SCALED = {
1423+
'debug[all]': 'Multi Gyro Scaled',
1424+
'debug[0]': 'Gyro 1 [roll]',
1425+
'debug[1]': 'Gyro 1 [pitch]',
1426+
'debug[2]': 'Gyro 2 [roll]',
1427+
'debug[3]': 'Gyro 2 [pitch]',
1428+
'debug[4]': 'Gyro 3 [roll]',
1429+
'debug[5]': 'Gyro 3 [pitch]',
1430+
'debug[6]': 'Gyro 4 [roll]',
1431+
'debug[7]': 'Gyro 4 [pitch]',
1432+
};
14001433
DEBUG_FRIENDLY_FIELD_NAMES.AUTOPILOT_POSITION = {
14011434
'debug[all]': 'Autopilot Position',
14021435
'debug[0]': 'Distance',
@@ -1840,6 +1873,9 @@ FlightLogFieldPresenter.decodeDebugFieldToFriendly = function (
18401873
case "DUAL_GYRO_COMBINED":
18411874
case "DUAL_GYRO_DIFF":
18421875
case "DUAL_GYRO_RAW":
1876+
case "MULTI_GYRO_DIFF":
1877+
case "MULTI_GYRO_RAW":
1878+
case "MULTI_GYRO_SCALED":
18431879
case "NOTCH":
18441880
case "GYRO_SAMPLE":
18451881
return `${Math.round(flightLog.gyroRawToDegreesPerSecond(value))} °/s`;
@@ -2538,6 +2574,9 @@ FlightLogFieldPresenter.ConvertDebugFieldValue = function (
25382574
case "DUAL_GYRO_COMBINED":
25392575
case "DUAL_GYRO_DIFF":
25402576
case "DUAL_GYRO_RAW":
2577+
case "MULTI_GYRO_DIFF":
2578+
case "MULTI_GYRO_RAW":
2579+
case "MULTI_GYRO_SCALED":
25412580
case "NOTCH":
25422581
case "GYRO_SAMPLE":
25432582
return toFriendly

src/flightlog_parser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ export function FlightLogParser(logData) {
446446
chirp_frequency_start_deci_hz : "chirp_frequency_start_deci_hz",
447447
chirp_frequency_end_deci_hz : "chirp_frequency_end_deci_hz",
448448
chirp_time_seconds : "chirp_time_seconds",
449+
// MULTI_GYRO to DUAL_GYRO debug mode aliases
450+
multi_gyro: "dual_gyro",
451+
multi_gyro_raw: "dual_gyro_raw",
452+
multi_gyro_combined: "dual_gyro_combined",
453+
multi_gyro_diff: "dual_gyro_diff",
454+
multi_gyro_scaled: "dual_gyro_scaled",
449455
},
450456
frameTypes,
451457
// Blackbox state:

src/graph_imported_curves.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
export function ImportedCurves(curvesChanged) {
2+
const maxImportCount = 5;
3+
this._curvesData = [];
4+
const _that = this;
5+
this.minX = Number.MAX_VALUE;
6+
this.maxX = -Number.MAX_VALUE;
7+
this.minY = Number.MAX_VALUE;
8+
this.maxY = -Number.MAX_VALUE;
9+
10+
this.curvesCount = function() {
11+
return this._curvesData.length;
12+
};
13+
14+
this.importCurvesFromCSV = function(files) {
15+
let importsLeft = maxImportCount - this._curvesData.length;
16+
17+
for (const file of files) {
18+
if (importsLeft-- == 0) {
19+
break;
20+
}
21+
const reader = new FileReader();
22+
reader.onload = function (e) {
23+
try {
24+
const stringRows = e.target.result.split("\n");
25+
26+
const header = stringRows[0].split(",");
27+
if (header.length != 2 || header[0] != "x" || header[1] != "y") {
28+
throw new SyntaxError("Wrong curves CSV data format");
29+
}
30+
31+
stringRows.shift();
32+
//remove bad last row
33+
if (stringRows.at(-1) == "") {
34+
stringRows.pop();
35+
}
36+
37+
const curvesData = stringRows.map( function(row) {
38+
const data = row.split(","),
39+
x = parseFloat(data[0]),
40+
y = parseFloat(data[1]);
41+
_that.minX = Math.min(x, _that.minX);
42+
_that.maxX = Math.max(x, _that.maxX);
43+
_that.minY = Math.min(y, _that.minY);
44+
_that.maxY = Math.max(y, _that.maxY);
45+
return {
46+
x: x,
47+
y: y,
48+
};
49+
});
50+
51+
const curve = {
52+
name: file.name.split('.')[0],
53+
points: curvesData,
54+
};
55+
_that._curvesData.push(curve);
56+
curvesChanged();
57+
} catch (e) {
58+
alert('Curves data import error: ' + e.message);
59+
return;
60+
}
61+
};
62+
63+
reader.readAsText(file);
64+
}
65+
};
66+
67+
this.removeCurves = function() {
68+
this._curvesData.length = 0;
69+
this.minX = Number.MAX_VALUE;
70+
this.maxX = -Number.MAX_VALUE;
71+
this.minY = Number.MAX_VALUE;
72+
this.maxY = -Number.MAX_VALUE;
73+
curvesChanged();
74+
};
75+
}

src/graph_spectrum.js

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
399399
!psdCurveSelected,
400400
);
401401

402-
$("#spectrumComparison").css("visibility", (optionSelected == 0 ? "visible" : "hidden"));
402+
403+
const showSpectrumsComparisonPanel = optionSelected === SPECTRUM_TYPE.FREQUENCY || optionSelected === SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY;
404+
$("#spectrumComparison").css("visibility", (showSpectrumsComparisonPanel ? "visible" : "hidden"));
403405
})
404406
.change();
405407

@@ -464,48 +466,27 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
464466
};
465467

466468
this.importSpectrumFromCSV = function(files) {
467-
const maxImportCount = 5;
468-
let importsLeft = maxImportCount - GraphSpectrumPlot.getImportedSpectrumCount();
469+
GraphSpectrumPlot.importCurvesFromCSV(files);
470+
};
469471

470-
for (const file of files) {
471-
if (importsLeft-- == 0) {
472-
break;
473-
}
474-
const reader = new FileReader();
475-
reader.onload = function (e) {
476-
try {
477-
const stringRows = e.target.result.split("\n");
478-
479-
const header = stringRows[0].split(",");
480-
if (header.length != 2 || header[0] != "freq" || header[1] != "value") {
481-
throw new SyntaxError("Wrong spectrum CSV data format");
482-
}
483-
484-
stringRows.shift();
485-
const spectrumData = stringRows.map( function(row) {
486-
const data = row.split(",");
487-
return {
488-
freq: parseFloat(data[0]),
489-
value: parseFloat(data[1]),
490-
};
491-
});
492-
493-
GraphSpectrumPlot.addImportedSpectrumData(spectrumData, file.name);
494-
} catch (e) {
495-
alert('Spectrum data import error: ' + e.message);
496-
return;
497-
}
498-
};
472+
this.removeImportedSpectrums = function() {
473+
GraphSpectrumPlot.removeImportedCurves();
474+
};
499475

500-
reader.readAsText(file);
476+
this.getExportedFileName = function() {
477+
let fileName = $(".log-filename").text().split(".")[0];
478+
switch (userSettings.spectrumType) {
479+
case SPECTRUM_TYPE.FREQUENCY:
480+
fileName = fileName + "_sp";
481+
break;
482+
case SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY:
483+
fileName = fileName + "_psd";
484+
break;
501485
}
486+
return fileName;
502487
};
503488

504489
} catch (e) {
505490
console.error(`Failed to create analyser... error: ${e}`);
506491
}
507-
508-
this.clearImportedSpectrums = function() {
509-
GraphSpectrumPlot.clearImportedSpectrums();
510-
};
511492
}

src/graph_spectrum_calc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ GraphSpectrumCalc.dataLoadPSD = function(analyserZoomY) {
133133
const psdData = {
134134
fieldIndex : this._dataBuffer.fieldIndex,
135135
fieldName : this._dataBuffer.fieldName,
136-
psdLength : psd.psdOutput.length,
137-
psdOutput : psd.psdOutput,
136+
fftLength : psd.psdOutput.length,
137+
fftOutput : psd.psdOutput,
138138
blackBoxRate : this._blackBoxRate,
139139
minimum: psd.min,
140140
maximum: psd.max,

0 commit comments

Comments
 (0)