Skip to content

Commit 066b0e3

Browse files
committed
Added vertical slider to control drawing PSD low level
1 parent 2d34405 commit 066b0e3

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ <h4>Workspace</h4>
495495
/>
496496
<input id="analyserShiftPSD" class="onlyFullScreen" type="range" name="analyserShiftPSD" value="0" min="-50" max="50" step="5"
497497
/>
498+
<input id="analyserLowLevelPSD" class="onlyFullScreen" type="range" name="analyserLowLevelPSD" value="0" min="0" max="100" step="5"
499+
/>
498500

499501
<datalist id="analyserZoomXTicks">
500502
<option>100</option>

src/css/main.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,14 @@ html.has-analyser-fullscreen.has-analyser
687687
top: 30px;
688688
}
689689

690+
.analyser input#analyserLowLevelPSD {
691+
width: 10px;
692+
height: 100px;
693+
-webkit-appearance: slider-vertical;
694+
left: 0px;
695+
top: 30px;
696+
}
697+
690698
.analyser input.onlyFullScreen {
691699
display: none;
692700
padding: 3px;

src/graph_spectrum.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
3636
let analyserZoomXElem = $("#analyserZoomX");
3737
let analyserZoomYElem = $("#analyserZoomY");
3838
const analyserShiftPSDElem = $("#analyserShiftPSD");
39+
const analyserLowLevelPSDElem = $("#analyserLowLevelPSD");
3940

4041
let spectrumToolbarElem = $("#spectrumToolbar");
4142
let spectrumTypeElem = $("#spectrumTypeSelect");
@@ -99,6 +100,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
99100
$("#analyserShiftPSD", parentElem).css({
100101
left: `${newSize.width - 20}px`,
101102
});
103+
$("#analyserLowLevelPSD", parentElem).css({
104+
left: `${newSize.width - 130}px`,
105+
});
102106
$("#analyserResize", parentElem).css({
103107
left: `${newSize.width - 20}px`,
104108
});
@@ -220,6 +224,21 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
220224
debounce(100, function () {
221225
const shift = -parseInt(analyserShiftPSDElem.val());
222226
GraphSpectrumPlot.setShiftPSD(shift);
227+
analyserLowLevelPSDElem.val(0).trigger("input");
228+
that.refresh();
229+
})
230+
)
231+
.dblclick(function () {
232+
$(this).val(0).trigger("input");
233+
})
234+
.val(0);
235+
236+
analyserLowLevelPSDElem
237+
.on(
238+
"input",
239+
debounce(100, function () {
240+
const lowLevel = analyserLowLevelPSDElem.val() / 100;
241+
GraphSpectrumPlot.setLowLevelPSD(lowLevel);
223242
that.refresh();
224243
})
225244
)
@@ -272,6 +291,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
272291
"onlyFullScreenException",
273292
!psdHeatMapSelected
274293
);
294+
analyserLowLevelPSDElem.toggleClass(
295+
"onlyFullScreenException",
296+
!psdHeatMapSelected
297+
);
275298

276299
$("#spectrumComparison").css("visibility", (optionSelected == 0 ? "visible" : "hidden"));
277300
})

src/graph_spectrum_plot.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const GraphSpectrumPlot = window.GraphSpectrumPlot || {
5151
_zoomX: 1.0,
5252
_zoomY: 1.0,
5353
_shiftPSD: 0,
54+
_lowLevelPSD: 0,
5455
_drawingParams: {
5556
fontSizeFrameLabel: "6",
5657
fontSizeFrameLabelFullscreen: "9",
@@ -89,6 +90,15 @@ GraphSpectrumPlot.setShiftPSD = function (shift) {
8990
}
9091
};
9192

93+
GraphSpectrumPlot.setLowLevelPSD = function (lowLevel) {
94+
const modifiedLevel = this._lowLevelPSD !== lowLevel;
95+
if (modifiedLevel) {
96+
this._lowLevelPSD = lowLevel;
97+
this._invalidateCache();
98+
this._invalidateDataCache();
99+
}
100+
};
101+
92102
GraphSpectrumPlot.setSize = function (width, height) {
93103
this._canvasCtx.canvas.width = width;
94104
this._canvasCtx.canvas.height = height;
@@ -520,19 +530,24 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
520530
const fftColorScale = 100 / (this._zoomY * SCALE_HEATMAP);
521531

522532
const dBmValueMin = MIN_DBM_VALUE + this._shiftPSD,
523-
dBmValueMax = MAX_DBM_VALUE + this._shiftPSD;
533+
dBmValueMax = MAX_DBM_VALUE + this._shiftPSD,
534+
lowLevel = dBmValueMin + (dBmValueMax - dBmValueMin) * this._lowLevelPSD;
524535
// Loop for throttle
525536
for (let j = 0; j < THROTTLE_VALUES_SIZE; j++) {
526537
// Loop for frequency
527538
for (let i = 0; i < this._fftData.fftLength; i++) {
528-
let valuePlot;
539+
let valuePlot = this._fftData.fftOutput[j][i];
529540
if (drawPSD) {
530-
valuePlot = Math.max(this._fftData.fftOutput[j][i], dBmValueMin);
541+
if (valuePlot < lowLevel) {
542+
valuePlot = dBmValueMin; // Filter low values
543+
} else {
544+
valuePlot = Math.max(valuePlot, dBmValueMin);
545+
}
531546
valuePlot = Math.min(valuePlot, dBmValueMax);
532547
valuePlot = Math.round((valuePlot - dBmValueMin) * 100 / (dBmValueMax - dBmValueMin));
533548
} else {
534549
valuePlot = Math.round(
535-
Math.min(this._fftData.fftOutput[j][i] * fftColorScale, 100)
550+
Math.min(valuePlot * fftColorScale, 100)
536551
);
537552
}
538553

0 commit comments

Comments
 (0)