@@ -17,7 +17,8 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1717 const that = this ,
1818 prefs = new PrefStorage ( ) ,
1919 DEFAULT_PSD_HEATMAP_MIN = - 40 ,
20- DEFAULT_PSD_HEATMAP_MAX = 10 ;
20+ DEFAULT_PSD_HEATMAP_MAX = 10 ,
21+ DEFAULT_PSD_SEGMENT_LENGTH_POWER = 9 ;
2122 let analyserZoomX = 1.0 /* 100% */ ,
2223 analyserZoomY = 1.0 /* 100% */ ,
2324 dataReload = false ,
@@ -36,6 +37,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
3637 const analyserMinPSD = $ ( "#analyserMinPSD" ) ;
3738 const analyserMaxPSD = $ ( "#analyserMaxPSD" ) ;
3839 const analyserLowLevelPSD = $ ( "#analyserLowLevelPSD" ) ;
40+ const analyserSegmentLengthPowerAt2 = $ ( "#analyserSegmentLengthPowerAt2" ) ;
3941
4042
4143 const spectrumToolbarElem = $ ( "#spectrumToolbar" ) ;
@@ -124,6 +126,12 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
124126 $ ( "#analyserLowLevelPSDLabel" , parentElem ) . css ( {
125127 left : `${ newSize . width - 155 } px` ,
126128 } ) ;
129+ $ ( "#analyserSegmentLengthPowerAt2" , parentElem ) . css ( {
130+ left : `${ newSize . width - 57 } px` ,
131+ } ) ;
132+ $ ( "#analyserSegmentLengthPowerAt2Label" , parentElem ) . css ( {
133+ left : `${ newSize . width - 135 } px` ,
134+ } ) ;
127135 } ;
128136
129137 const dataLoad = function ( fieldIndex , curve , fieldName ) {
@@ -154,6 +162,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
154162
155163 case SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY :
156164 fftData = GraphSpectrumCalc . dataLoadPSD ( analyserZoomY ) ;
165+ if ( fftData . maximalSegmentsLength > 0 ) {
166+ analyserSegmentLengthPowerAt2 . prop ( "max" , Math . ceil ( Math . log2 ( fftData . maximalSegmentsLength ) ) ) ;
167+ }
157168 break ;
158169
159170 case SPECTRUM_TYPE . FREQUENCY :
@@ -241,11 +252,6 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
241252 debounce ( 100 , function ( ) {
242253 analyserZoomY = 1 / ( analyserZoomYElem . val ( ) / 100 ) ;
243254 GraphSpectrumPlot . setZoom ( analyserZoomX , analyserZoomY ) ;
244- // Recalculate PSD with updated samples per segment count
245- if ( userSettings . spectrumType == SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY ) {
246- dataLoad ( ) ;
247- GraphSpectrumPlot . setData ( fftData , userSettings . spectrumType ) ;
248- }
249255 that . refresh ( ) ;
250256 } ) ,
251257 )
@@ -325,6 +331,25 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
325331 } )
326332 . val ( analyserMinPSD . val ( ) ) ;
327333
334+ GraphSpectrumCalc . setPointsPerSegmentPSD ( 2 ** DEFAULT_PSD_SEGMENT_LENGTH_POWER ) ;
335+ analyserSegmentLengthPowerAt2
336+ . on (
337+ "input" ,
338+ debounce ( 100 , function ( ) {
339+ // Recalculate PSD with updated samples per segment count
340+ GraphSpectrumCalc . setPointsPerSegmentPSD ( 2 ** Number . parseInt ( $ ( this ) . val ( ) ) ) ;
341+ dataLoad ( ) ;
342+ GraphSpectrumPlot . setData ( fftData , userSettings . spectrumType ) ;
343+ that . refresh ( ) ;
344+ } ) ,
345+ )
346+ . dblclick ( function ( e ) {
347+ if ( e . ctrlKey ) {
348+ $ ( this ) . val ( DEFAULT_PSD_SEGMENT_LENGTH_POWER ) . trigger ( "input" ) ;
349+ }
350+ } )
351+ . val ( DEFAULT_PSD_SEGMENT_LENGTH_POWER ) ;
352+
328353 // Spectrum type to show
329354 userSettings . spectrumType =
330355 userSettings . spectrumType || SPECTRUM_TYPE . FREQUENCY ;
@@ -349,10 +374,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
349374 const psdHeatMapSelected =
350375 optionSelected === SPECTRUM_TYPE . PSD_VS_THROTTLE ||
351376 optionSelected === SPECTRUM_TYPE . PSD_VS_RPM ;
377+ const psdCurveSelected =
378+ optionSelected === SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY ;
352379 overdrawSpectrumTypeElem . toggle ( ! pidErrorVsSetpointSelected ) ;
353380 analyserZoomYElem . toggleClass (
354381 "onlyFullScreenException" ,
355- pidErrorVsSetpointSelected || psdHeatMapSelected ,
382+ pidErrorVsSetpointSelected || psdHeatMapSelected || psdCurveSelected ,
383+ ) ;
384+ analyserSegmentLengthPowerAt2 . toggleClass (
385+ "onlyFullScreenException" ,
386+ ! psdCurveSelected ,
356387 ) ;
357388 analyserLowLevelPSD . toggleClass (
358389 "onlyFullScreenException" ,
@@ -378,6 +409,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
378409 "onlyFullScreenException" ,
379410 ! psdHeatMapSelected ,
380411 ) ;
412+ $ ( "#analyserSegmentLengthPowerAt2Label" ) . toggleClass (
413+ "onlyFullScreenException" ,
414+ ! psdCurveSelected ,
415+ ) ;
381416
382417
383418 const showSpectrumsComparisonPanel = optionSelected === SPECTRUM_TYPE . FREQUENCY || optionSelected === SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY ;
0 commit comments