Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/graph_spectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
GraphSpectrumPlot,
SPECTRUM_TYPE,
SPECTRUM_OVERDRAW_TYPE,
DEFAULT_MIN_DBM_VALUE,
DEFAULT_MAX_DBM_VALUE,
} from "./graph_spectrum_plot";
import { PrefStorage } from "./pref_storage";
import { SpectrumExporter } from "./spectrum-exporter";
Expand All @@ -17,7 +15,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
ANALYSER_LARGE_WIDTH_MARGIN = 20;

const that = this,
prefs = new PrefStorage();
prefs = new PrefStorage(),
DEFAULT_PSD_HEATMAP_MIN = -40,
DEFAULT_PSD_HEATMAP_MAX = 10;
let analyserZoomX = 1.0 /* 100% */,
analyserZoomY = 1.0 /* 100% */,
dataReload = false,
Expand Down Expand Up @@ -226,12 +226,24 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
})
.val(DEFAULT_ZOOM);

if (userSettings.psdHeatmapMin == undefined) {
userSettings.psdHeatmapMin = DEFAULT_PSD_HEATMAP_MIN;
}
GraphSpectrumPlot.setMinPSD(userSettings.psdHeatmapMin);
GraphSpectrumPlot.setLowLevelPSD(userSettings.psdHeatmapMin);

if (userSettings.psdHeatmapMax == undefined) {
userSettings.psdHeatmapMax = DEFAULT_PSD_HEATMAP_MAX;
}
GraphSpectrumPlot.setMaxPSD(userSettings.psdHeatmapMax);

analyserMinPSD
.on(
"input",
debounce(100, function () {
const min = parseInt(analyserMinPSD.val());
GraphSpectrumPlot.setMinPSD(min);
saveOneUserSetting("psdHeatmapMin", min);
analyserLowLevelPSD.prop("min", min);
analyserMaxPSD.prop("min", min + 5);
if (analyserLowLevelPSD.val() < min) {
Expand All @@ -242,17 +254,18 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
)
.dblclick(function (e) {
if (e.ctrlKey) {
$(this).val(DEFAULT_MIN_DBM_VALUE).trigger("input");
$(this).val(userSettings.psdHeatmapMin).trigger("input");
}
})
.val(DEFAULT_MIN_DBM_VALUE);
.val(userSettings.psdHeatmapMin);

analyserMaxPSD
.on(
"input",
debounce(100, function () {
const max = parseInt(analyserMaxPSD.val());
GraphSpectrumPlot.setMaxPSD(max);
saveOneUserSetting("psdHeatmapMax", max);
analyserMinPSD.prop("max", max - 5);
analyserLowLevelPSD.prop("max", max);
if (analyserLowLevelPSD.val() > max) {
Expand All @@ -263,10 +276,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
)
.dblclick(function (e) {
if (e.ctrlKey) {
$(this).val(DEFAULT_MAX_DBM_VALUE).trigger("input");
$(this).val(userSettings.psdHeatmapMax).trigger("input");
}
})
.val(DEFAULT_MAX_DBM_VALUE);
.val(userSettings.psdHeatmapMax);

analyserLowLevelPSD
.on(
Expand Down
10 changes: 4 additions & 6 deletions src/graph_spectrum_plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const BLUR_FILTER_PIXEL = 1,
ZOOM_X_MAX = 5,
MAX_SPECTRUM_LINE_COUNT = 30000;

export const DEFAULT_MIN_DBM_VALUE = -40,
DEFAULT_MAX_DBM_VALUE = 10;

export const SPECTRUM_TYPE = {
FREQUENCY: 0,
FREQ_VS_THROTTLE: 1,
Expand Down Expand Up @@ -51,9 +48,10 @@ export const GraphSpectrumPlot = window.GraphSpectrumPlot || {
_sysConfig: null,
_zoomX: 1.0,
_zoomY: 1.0,
_minPSD: DEFAULT_MIN_DBM_VALUE,
_maxPSD: DEFAULT_MAX_DBM_VALUE,
_lowLevelPSD: DEFAULT_MIN_DBM_VALUE,
// _minPSD, _maxPSD, _lowLevelPSD will initialize later in FlightLogAnalyser from stored settings
_minPSD: 0,
_maxPSD: 0,
_lowLevelPSD: 0,
_drawingParams: {
fontSizeFrameLabel: "6",
fontSizeFrameLabelFullscreen: "9",
Expand Down
2 changes: 2 additions & 0 deletions src/user_settings_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export function UserSettingsDialog(dialog, onLoad, onSave) {
eraseBackground: true, // Set to false if you want the graph to draw on top of an existing canvas image
spectrumType: 0, // By default, frequency Spectrum
overdrawSpectrumType: 0, // By default, show all filters
psdHeatmapMin: -40,
psdHeatmapMax: 10,
craft: {
left: "15%", // position from left (as a percentage of width)
top: "48%", // position from top (as a percentage of height)
Expand Down