Skip to content

Commit 36a4163

Browse files
committed
Added separated own vertical slider for PSD ranges shift
1 parent 6b496cf commit 36a4163

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ <h4>Workspace</h4>
493493
/>
494494
<input id="analyserZoomY" class="onlyFullScreen" type="range" name="analyserZoomY" value="100" min="10" max="1000" step="10" list="analyserZoomYTicks"
495495
/>
496+
<input id="analyserShiftPSD" class="onlyFullScreen" type="range" name="analyserShiftPSD" value="0" min="-50" max="50" step="5"
497+
/>
498+
496499
<datalist id="analyserZoomXTicks">
497500
<option>100</option>
498501
<option>200</option>

src/css/main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ html.has-analyser-fullscreen.has-analyser
670670
top: 10px;
671671
float: right;
672672
}
673+
673674
.analyser input#analyserZoomY {
674675
width: 10px;
675676
height: 100px;
@@ -678,6 +679,14 @@ html.has-analyser-fullscreen.has-analyser
678679
top: 30px;
679680
}
680681

682+
.analyser input#analyserShiftPSD {
683+
width: 10px;
684+
height: 100px;
685+
-webkit-appearance: slider-vertical;
686+
left: 0px;
687+
top: 30px;
688+
}
689+
681690
.analyser input.onlyFullScreen {
682691
display: none;
683692
padding: 3px;

src/graph_spectrum.js

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

4041
let spectrumToolbarElem = $("#spectrumToolbar");
4142
let spectrumTypeElem = $("#spectrumTypeSelect");
@@ -90,10 +91,13 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
9091
top: newSize.top, // (canvas.height * getSize().top ) + "px"
9192
});
9293
// place the sliders.
93-
$("input:first-of-type", parentElem).css({
94+
$("#analyserZoomX", parentElem).css({
9495
left: `${newSize.width - 130}px`,
9596
});
96-
$("input:last-of-type", parentElem).css({
97+
$("#analyserZoomY", parentElem).css({
98+
left: `${newSize.width - 20}px`,
99+
});
100+
$("#analyserShiftPSD", parentElem).css({
97101
left: `${newSize.width - 20}px`,
98102
});
99103
$("#analyserResize", parentElem).css({
@@ -209,6 +213,20 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
209213
})
210214
.val(DEFAULT_ZOOM);
211215

216+
analyserShiftPSDElem
217+
.on(
218+
"input",
219+
debounce(100, function () {
220+
const shift = -parseInt(analyserShiftPSDElem.val());
221+
GraphSpectrumPlot.setShiftPSD(shift);
222+
that.refresh();
223+
})
224+
)
225+
.dblclick(function () {
226+
$(this).val(0).trigger("input");
227+
})
228+
.val(0);
229+
212230
// Spectrum type to show
213231
userSettings.spectrumType =
214232
userSettings.spectrumType || SPECTRUM_TYPE.FREQUENCY;
@@ -234,10 +252,17 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
234252
// Hide overdraw and zoomY if needed
235253
const pidErrorVsSetpointSelected =
236254
optionSelected === SPECTRUM_TYPE.PIDERROR_VS_SETPOINT;
255+
const psdHeatMapSelected =
256+
optionSelected === SPECTRUM_TYPE.PSD_VS_THROTTLE ||
257+
optionSelected === SPECTRUM_TYPE.PSD_VS_RPM;
237258
overdrawSpectrumTypeElem.toggle(!pidErrorVsSetpointSelected);
238259
analyserZoomYElem.toggleClass(
239260
"onlyFullScreenException",
240-
pidErrorVsSetpointSelected
261+
pidErrorVsSetpointSelected || psdHeatMapSelected
262+
);
263+
analyserShiftPSDElem.toggleClass(
264+
"onlyFullScreenException",
265+
!psdHeatMapSelected
241266
);
242267

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

src/graph_spectrum_plot.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const GraphSpectrumPlot = window.GraphSpectrumPlot || {
5050
_sysConfig: null,
5151
_zoomX: 1.0,
5252
_zoomY: 1.0,
53+
_shiftPSD: 0,
5354
_drawingParams: {
5455
fontSizeFrameLabel: "6",
5556
fontSizeFrameLabelFullscreen: "9",
@@ -79,6 +80,15 @@ GraphSpectrumPlot.setZoom = function (zoomX, zoomY) {
7980
}
8081
};
8182

83+
GraphSpectrumPlot.setShiftPSD = function (shift) {
84+
const modifiedShift = this._shiftPSD !== shift;
85+
if (modifiedShift) {
86+
this._shiftPSD = shift;
87+
this._invalidateCache();
88+
this._invalidateDataCache();
89+
}
90+
};
91+
8292
GraphSpectrumPlot.setSize = function (width, height) {
8393
this._canvasCtx.canvas.width = width;
8494
this._canvasCtx.canvas.height = height;
@@ -509,15 +519,8 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
509519

510520
const fftColorScale = 100 / (this._zoomY * SCALE_HEATMAP);
511521

512-
//Compute the dbm range shift from zoomY as[-30, -20, -10, 0, +10, +20]
513-
let dBmRangeShift = 0;
514-
if (this._zoomY <= 1) { // [10 ... 0.1]
515-
dBmRangeShift = -10 * Math.round((1 / this._zoomY - 1) / 3); //0, -10, -20, -30
516-
} else {
517-
dBmRangeShift = 10 * Math.round((this._zoomY - 1) / 9 * 2); // 0, 10, 20
518-
}
519-
const dBmValueMin = MIN_DBM_VALUE + dBmRangeShift,
520-
dBmValueMax = MAX_DBM_VALUE + dBmRangeShift;
522+
const dBmValueMin = MIN_DBM_VALUE + this._shiftPSD,
523+
dBmValueMax = MAX_DBM_VALUE + this._shiftPSD;
521524
// Loop for throttle
522525
for (let j = 0; j < THROTTLE_VALUES_SIZE; j++) {
523526
// Loop for frequency

0 commit comments

Comments
 (0)