Skip to content
Merged
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
31 changes: 14 additions & 17 deletions src/graph_spectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
let that = this,
analyserZoomX = 1.0 /* 100% */,
analyserZoomY = 1.0 /* 100% */,
dataBuffer = {
fieldIndex: 0,
curve: 0,
fieldName: null,
},
dataReload = false,
fftData = null,
prefs = new PrefStorage();

this.dataBuffer = {
fieldIndex: 0,
curve: 0,
fieldName: null,
};

try {
let isFullscreen = false;

Expand Down Expand Up @@ -100,9 +101,8 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
});
};

let dataLoad = function () {
GraphSpectrumCalc.setDataBuffer(dataBuffer);

const dataLoad = function () {
GraphSpectrumCalc.setDataBuffer(that.dataBuffer);
switch (userSettings.spectrumType) {
case SPECTRUM_TYPE.FREQ_VS_THROTTLE:
fftData = GraphSpectrumCalc.dataLoadFrequencyVsThrottle();
Expand All @@ -128,19 +128,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
analyser on screen*/
this.plotSpectrum = function (fieldIndex, curve, fieldName) {
// Store the data pointers
dataBuffer = {
fieldIndex: fieldIndex,
curve: curve,
fieldName: fieldName,
};

that.dataBuffer.fieldIndex = fieldIndex;
that.dataBuffer.curve = curve;
that.dataBuffer.fieldName = fieldName;
// Detect change of selected field.... reload and redraw required.
if (fftData == null || fieldIndex != fftData.fieldIndex || dataReload) {
dataReload = false;
dataLoad();
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
}

that.draw(); // draw the analyser on the canvas....
};

Expand Down Expand Up @@ -211,9 +208,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
// Recalculate the data, for the same curve than now, and draw it
dataReload = true;
that.plotSpectrum(
dataBuffer.fieldIndex,
dataBuffer.curve,
dataBuffer.fieldName
that.dataBuffer.fieldIndex,
that.dataBuffer.curve,
that.dataBuffer.fieldName,
);
}

Expand Down