-
-
Notifications
You must be signed in to change notification settings - Fork 155
Power spectral density curves settings improvement #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
demvlad
wants to merge
35
commits into
betaflight:master
Choose a base branch
from
demvlad:psd_impromement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
6db3827
Added graph_imported_curves module for import curves
demvlad ddf5d63
Spectrum export/import code refactoring
demvlad 79b5c83
Added export/import PSD curves data
demvlad 1647d06
Added drawing of imported PSD curves
demvlad 6b580c6
Resolved code issues
demvlad c96f430
Resolved code issues
demvlad 48444a1
Code style improvement
demvlad 10364a2
Resolved issue wrong frequency definition in exported file
demvlad 622177f
Code improvement
demvlad 340a7b6
The legend is moved to right-up corner
demvlad cc01fee
The exported spectrums .csv file name is log name with _sp, _psd postfix
demvlad d26c67e
Resolved issue of imported curves frequency scaling
demvlad c3c1df2
Code refactoring: PLOTTED_BLACKBOX_RATE is replace to MAXIMAL_PLOTTED…
demvlad 5f255ac
Analyser legend position is added in user settings
demvlad 62aa2ac
Added check of valid userSetting in _drawLegend method
demvlad 4e81572
Added warning for specrum type what have not spectrum import
demvlad 0cc128c
Added newline on EOF in src/graph_imported_curves.js
demvlad 2caf5de
Changed mouse cursor info for single and multiple PSD curves
demvlad 8812bae
Code style improvement
demvlad d25b398
The mouse position cursor improvement for PSD curves
demvlad a98744b
Code style improvement
demvlad 82125da
Code style improvement
demvlad 2595258
Code style improvement
demvlad bc30951
Resolved const issue
demvlad bde5775
The PSD heatmap low(cut) level is set like min value after min change
demvlad a6ceec0
The input number element is added at html and css instead of slider f…
demvlad 0208d5e
The input number element for psd segment length input is placed at fo…
demvlad ec62b9d
Added update events handler to multiple/divide by 2 the PSD segment l…
demvlad 2476e1d
Added points per segment count change from html input
demvlad 88a00b0
Edited html input element
demvlad 32b7eb0
Added computing of maximal points per segment PSD values
demvlad 93eb8aa
Thde labels color is changed
demvlad 5ee8dfb
Added missing comma
demvlad c0089f8
The segmentLenghtPSD variables name is changed to segmentLengthPSD
demvlad 5513d86
The PSD segment length input elements are replaced
demvlad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
export function ImportedCurves(curvesChanged) { | ||
const maxImportCount = 5; | ||
this._curvesData = []; | ||
const _that = this; | ||
this.minX = Number.MAX_VALUE; | ||
this.maxX = -Number.MAX_VALUE; | ||
this.minY = Number.MAX_VALUE; | ||
this.maxY = -Number.MAX_VALUE; | ||
|
||
this.curvesCount = function() { | ||
return this._curvesData.length; | ||
}; | ||
|
||
this.importCurvesFromCSV = function(files) { | ||
let importsLeft = maxImportCount - this._curvesData.length; | ||
|
||
for (const file of files) { | ||
if (importsLeft-- == 0) { | ||
break; | ||
} | ||
const reader = new FileReader(); | ||
reader.onload = function (e) { | ||
try { | ||
const stringRows = e.target.result.split("\n"); | ||
|
||
const header = stringRows[0].split(","); | ||
if (header.length != 2 || header[0] != "x" || header[1] != "y") { | ||
throw new SyntaxError("Wrong curves CSV data format"); | ||
} | ||
|
||
stringRows.shift(); | ||
//remove bad last row | ||
if (stringRows.at(-1) == "") { | ||
stringRows.pop(); | ||
} | ||
|
||
const curvesData = stringRows.map( function(row) { | ||
const data = row.split(","), | ||
x = parseFloat(data[0]), | ||
y = parseFloat(data[1]); | ||
_that.minX = Math.min(x, _that.minX); | ||
_that.maxX = Math.max(x, _that.maxX); | ||
_that.minY = Math.min(y, _that.minY); | ||
_that.maxY = Math.max(y, _that.maxY); | ||
return { | ||
x: x, | ||
y: y, | ||
}; | ||
}); | ||
|
||
const curve = { | ||
name: file.name.split('.')[0], | ||
points: curvesData, | ||
}; | ||
_that._curvesData.push(curve); | ||
curvesChanged(); | ||
} catch (e) { | ||
alert('Curves data import error: ' + e.message); | ||
return; | ||
} | ||
}; | ||
|
||
reader.readAsText(file); | ||
} | ||
}; | ||
|
||
this.removeCurves = function() { | ||
this._curvesData.length = 0; | ||
this.minX = Number.MAX_VALUE; | ||
this.maxX = -Number.MAX_VALUE; | ||
this.minY = Number.MAX_VALUE; | ||
this.maxY = -Number.MAX_VALUE; | ||
curvesChanged(); | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance CSV validation and error handling.
The CSV parsing logic has several areas for improvement:
Additionally, consider adding validation for the parsed numeric values:
🤖 Prompt for AI Agents