Skip to content

Commit 2d34405

Browse files
committed
Added separated own vertical slider for PSD ranges shift
1 parent 514eb9b commit 2d34405

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
@@ -35,6 +35,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
3535
GraphSpectrumPlot.setLogRateWarningInfo(logRateInfo);
3636
let analyserZoomXElem = $("#analyserZoomX");
3737
let analyserZoomYElem = $("#analyserZoomY");
38+
const analyserShiftPSDElem = $("#analyserShiftPSD");
3839

3940
let spectrumToolbarElem = $("#spectrumToolbar");
4041
let spectrumTypeElem = $("#spectrumTypeSelect");
@@ -89,10 +90,13 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
8990
top: newSize.top, // (canvas.height * getSize().top ) + "px"
9091
});
9192
// place the sliders.
92-
$("input:first-of-type", parentElem).css({
93+
$("#analyserZoomX", parentElem).css({
9394
left: `${newSize.width - 130}px`,
9495
});
95-
$("input:last-of-type", parentElem).css({
96+
$("#analyserZoomY", parentElem).css({
97+
left: `${newSize.width - 20}px`,
98+
});
99+
$("#analyserShiftPSD", parentElem).css({
96100
left: `${newSize.width - 20}px`,
97101
});
98102
$("#analyserResize", parentElem).css({
@@ -210,6 +214,20 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
210214
})
211215
.val(DEFAULT_ZOOM);
212216

217+
analyserShiftPSDElem
218+
.on(
219+
"input",
220+
debounce(100, function () {
221+
const shift = -parseInt(analyserShiftPSDElem.val());
222+
GraphSpectrumPlot.setShiftPSD(shift);
223+
that.refresh();
224+
})
225+
)
226+
.dblclick(function () {
227+
$(this).val(0).trigger("input");
228+
})
229+
.val(0);
230+
213231
// Spectrum type to show
214232
userSettings.spectrumType =
215233
userSettings.spectrumType || SPECTRUM_TYPE.FREQUENCY;
@@ -242,10 +260,17 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
242260
// Hide overdraw and zoomY if needed
243261
const pidErrorVsSetpointSelected =
244262
optionSelected === SPECTRUM_TYPE.PIDERROR_VS_SETPOINT;
263+
const psdHeatMapSelected =
264+
optionSelected === SPECTRUM_TYPE.PSD_VS_THROTTLE ||
265+
optionSelected === SPECTRUM_TYPE.PSD_VS_RPM;
245266
overdrawSpectrumTypeElem.toggle(!pidErrorVsSetpointSelected);
246267
analyserZoomYElem.toggleClass(
247268
"onlyFullScreenException",
248-
pidErrorVsSetpointSelected
269+
pidErrorVsSetpointSelected || psdHeatMapSelected
270+
);
271+
analyserShiftPSDElem.toggleClass(
272+
"onlyFullScreenException",
273+
!psdHeatMapSelected
249274
);
250275

251276
$("#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)