Skip to content

Commit 95cbf3a

Browse files
authored
The min and max heatmap PSD values settings are stored for continous using (#843)
* The min and max heatmap PSD values are stored for using * Improved psd heatmap min max low values initialization * The spectrum plot min,max heatmapvalues initialization are remaded. To prevent wrong spectrum draw bug while draw is disabled
1 parent eb507b3 commit 95cbf3a

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/graph_spectrum.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
GraphSpectrumPlot,
55
SPECTRUM_TYPE,
66
SPECTRUM_OVERDRAW_TYPE,
7-
DEFAULT_MIN_DBM_VALUE,
8-
DEFAULT_MAX_DBM_VALUE,
97
} from "./graph_spectrum_plot";
108
import { PrefStorage } from "./pref_storage";
119
import { SpectrumExporter } from "./spectrum-exporter";
@@ -17,7 +15,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1715
ANALYSER_LARGE_WIDTH_MARGIN = 20;
1816

1917
const that = this,
20-
prefs = new PrefStorage();
18+
prefs = new PrefStorage(),
19+
DEFAULT_PSD_HEATMAP_MIN = -40,
20+
DEFAULT_PSD_HEATMAP_MAX = 10;
2121
let analyserZoomX = 1.0 /* 100% */,
2222
analyserZoomY = 1.0 /* 100% */,
2323
dataReload = false,
@@ -226,12 +226,24 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
226226
})
227227
.val(DEFAULT_ZOOM);
228228

229+
if (userSettings.psdHeatmapMin == undefined) {
230+
userSettings.psdHeatmapMin = DEFAULT_PSD_HEATMAP_MIN;
231+
}
232+
GraphSpectrumPlot.setMinPSD(userSettings.psdHeatmapMin);
233+
GraphSpectrumPlot.setLowLevelPSD(userSettings.psdHeatmapMin);
234+
235+
if (userSettings.psdHeatmapMax == undefined) {
236+
userSettings.psdHeatmapMax = DEFAULT_PSD_HEATMAP_MAX;
237+
}
238+
GraphSpectrumPlot.setMaxPSD(userSettings.psdHeatmapMax);
239+
229240
analyserMinPSD
230241
.on(
231242
"input",
232243
debounce(100, function () {
233244
const min = parseInt(analyserMinPSD.val());
234245
GraphSpectrumPlot.setMinPSD(min);
246+
saveOneUserSetting("psdHeatmapMin", min);
235247
analyserLowLevelPSD.prop("min", min);
236248
analyserMaxPSD.prop("min", min + 5);
237249
if (analyserLowLevelPSD.val() < min) {
@@ -242,17 +254,18 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
242254
)
243255
.dblclick(function (e) {
244256
if (e.ctrlKey) {
245-
$(this).val(DEFAULT_MIN_DBM_VALUE).trigger("input");
257+
$(this).val(userSettings.psdHeatmapMin).trigger("input");
246258
}
247259
})
248-
.val(DEFAULT_MIN_DBM_VALUE);
260+
.val(userSettings.psdHeatmapMin);
249261

250262
analyserMaxPSD
251263
.on(
252264
"input",
253265
debounce(100, function () {
254266
const max = parseInt(analyserMaxPSD.val());
255267
GraphSpectrumPlot.setMaxPSD(max);
268+
saveOneUserSetting("psdHeatmapMax", max);
256269
analyserMinPSD.prop("max", max - 5);
257270
analyserLowLevelPSD.prop("max", max);
258271
if (analyserLowLevelPSD.val() > max) {
@@ -263,10 +276,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
263276
)
264277
.dblclick(function (e) {
265278
if (e.ctrlKey) {
266-
$(this).val(DEFAULT_MAX_DBM_VALUE).trigger("input");
279+
$(this).val(userSettings.psdHeatmapMax).trigger("input");
267280
}
268281
})
269-
.val(DEFAULT_MAX_DBM_VALUE);
282+
.val(userSettings.psdHeatmapMax);
270283

271284
analyserLowLevelPSD
272285
.on(

src/graph_spectrum_plot.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ const BLUR_FILTER_PIXEL = 1,
1414
ZOOM_X_MAX = 5,
1515
MAX_SPECTRUM_LINE_COUNT = 30000;
1616

17-
export const DEFAULT_MIN_DBM_VALUE = -40,
18-
DEFAULT_MAX_DBM_VALUE = 10;
19-
2017
export const SPECTRUM_TYPE = {
2118
FREQUENCY: 0,
2219
FREQ_VS_THROTTLE: 1,
@@ -51,9 +48,10 @@ export const GraphSpectrumPlot = window.GraphSpectrumPlot || {
5148
_sysConfig: null,
5249
_zoomX: 1.0,
5350
_zoomY: 1.0,
54-
_minPSD: DEFAULT_MIN_DBM_VALUE,
55-
_maxPSD: DEFAULT_MAX_DBM_VALUE,
56-
_lowLevelPSD: DEFAULT_MIN_DBM_VALUE,
51+
// _minPSD, _maxPSD, _lowLevelPSD will initialize later in FlightLogAnalyser from stored settings
52+
_minPSD: 0,
53+
_maxPSD: 0,
54+
_lowLevelPSD: 0,
5755
_drawingParams: {
5856
fontSizeFrameLabel: "6",
5957
fontSizeFrameLabelFullscreen: "9",

src/user_settings_dialog.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ export function UserSettingsDialog(dialog, onLoad, onSave) {
214214
eraseBackground: true, // Set to false if you want the graph to draw on top of an existing canvas image
215215
spectrumType: 0, // By default, frequency Spectrum
216216
overdrawSpectrumType: 0, // By default, show all filters
217+
psdHeatmapMin: -40,
218+
psdHeatmapMax: 10,
217219
craft: {
218220
left: "15%", // position from left (as a percentage of width)
219221
top: "48%", // position from top (as a percentage of height)

0 commit comments

Comments
 (0)