@@ -17,32 +17,65 @@ public Form1()
1717 InitializeComponent ( ) ;
1818
1919 waterfall1 . intensity = 10 ;
20-
21- scottPlotUC1 . plt . Ticks ( displayTicksY : false ) ;
22- scottPlotUC1 . plt . TightenLayout ( 0 ) ;
23- scottPlotUC1 . plt . Grid ( false ) ;
2420 }
2521
2622 private void Form1_Load ( object sender , EventArgs e )
2723 {
2824 waterfall1 . StartListening ( deviceIndex : 0 ) ;
2925 }
3026
31- private void Timer1_Tick ( object sender , EventArgs e )
27+ private void UpdateWaterfallPlot ( )
3228 {
33- if ( ( waterfall1 . spec . fftList == null ) || ( waterfall1 . spec . fftList . Count == 0 ) )
34- return ;
35-
3629 scottPlotUC1 . plt . Clear ( ) ;
3730
3831 var fft = waterfall1 . spec . fftList [ waterfall1 . spec . fftList . Count - 1 ] ;
3932 double [ ] fft2 = new double [ fft . Length ] ;
4033 for ( int i = 0 ; i < fft . Length ; i ++ )
4134 fft2 [ i ] = fft [ i ] ;
4235
43- scottPlotUC1 . plt . PlotSignal ( fft2 , 1.0 / waterfall1 . spec . fftSettings . fftResolution , markerSize : 0 ) ;
44- scottPlotUC1 . plt . AxisAuto ( ) ;
36+ scottPlotUC1 . plt . PlotSignal ( fft2 , 1.0 / waterfall1 . spec . fftSettings . fftResolution ,
37+ markerSize : 0 , color : Color . Black ) ;
38+ scottPlotUC1 . plt . AxisAuto ( 0 , .01 , xExpandOnly : false , yExpandOnly : true ) ;
39+
40+ scottPlotUC1 . plt . Grid ( false ) ;
41+ scottPlotUC1 . plt . Style ( dataBg : SystemColors . Control ) ;
42+ scottPlotUC1 . plt . Frame ( drawFrame : false ) ;
43+ scottPlotUC1 . plt . TightenLayout ( padding : 0 ) ;
44+
4545 scottPlotUC1 . Render ( ) ;
4646 }
47+
48+ private void UpdateSignalPlot ( )
49+ {
50+ scottPlotUC2 . plt . Clear ( ) ;
51+
52+ int pointCount = 1000 ;
53+ var sigList = waterfall1 . spec . signal ;
54+ var lastSamples = sigList . GetRange ( sigList . Count - pointCount , pointCount ) ;
55+
56+ double [ ] pcm = new double [ pointCount ] ;
57+ for ( int i = 0 ; i < pointCount ; i ++ )
58+ pcm [ i ] = lastSamples [ i ] ;
59+
60+ scottPlotUC2 . plt . PlotSignal ( pcm , 1.0 / waterfall1 . spec . fftSettings . fftResolution ,
61+ markerSize : 0 , color : Color . Black ) ;
62+ scottPlotUC1 . plt . AxisAuto ( 0 , .01 , xExpandOnly : false , yExpandOnly : true ) ;
63+
64+ scottPlotUC2 . plt . Grid ( false ) ;
65+ scottPlotUC2 . plt . Style ( dataBg : SystemColors . Control ) ;
66+ scottPlotUC2 . plt . Frame ( drawFrame : false ) ;
67+ scottPlotUC2 . plt . TightenLayout ( padding : 0 ) ;
68+
69+ scottPlotUC2 . Render ( ) ;
70+ }
71+
72+ private void Timer1_Tick ( object sender , EventArgs e )
73+ {
74+ if ( ( waterfall1 . spec . fftList == null ) || ( waterfall1 . spec . fftList . Count == 0 ) )
75+ return ;
76+
77+ UpdateSignalPlot ( ) ;
78+ UpdateWaterfallPlot ( ) ;
79+ }
4780 }
4881}
0 commit comments