Skip to content

Commit 28126fb

Browse files
committed
Added separated own vertical slider for PSD ranges shift
1 parent 7d90504 commit 28126fb

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({
@@ -212,6 +216,20 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
212216
})
213217
.val(DEFAULT_ZOOM);
214218

219+
analyserShiftPSDElem
220+
.on(
221+
"input",
222+
debounce(100, function () {
223+
const shift = -parseInt(analyserShiftPSDElem.val());
224+
GraphSpectrumPlot.setShiftPSD(shift);
225+
that.refresh();
226+
})
227+
)
228+
.dblclick(function () {
229+
$(this).val(0).trigger("input");
230+
})
231+
.val(0);
232+
215233
// Spectrum type to show
216234
userSettings.spectrumType =
217235
userSettings.spectrumType || SPECTRUM_TYPE.FREQUENCY;
@@ -237,10 +255,17 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
237255
// Hide overdraw and zoomY if needed
238256
const pidErrorVsSetpointSelected =
239257
optionSelected === SPECTRUM_TYPE.PIDERROR_VS_SETPOINT;
258+
const psdHeatMapSelected =
259+
optionSelected === SPECTRUM_TYPE.PSD_VS_THROTTLE ||
260+
optionSelected === SPECTRUM_TYPE.PSD_VS_RPM;
240261
overdrawSpectrumTypeElem.toggle(!pidErrorVsSetpointSelected);
241262
analyserZoomYElem.toggleClass(
242263
"onlyFullScreenException",
243-
pidErrorVsSetpointSelected
264+
pidErrorVsSetpointSelected || psdHeatMapSelected
265+
);
266+
analyserShiftPSDElem.toggleClass(
267+
"onlyFullScreenException",
268+
!psdHeatMapSelected
244269
);
245270

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