public MainPage() { this.InitializeComponent(); this.Loaded += MainPage_Loaded; this.NavigationCacheMode = NavigationCacheMode.Required; // Create our LineGraph and hook the up to their respective images graphScope1 = new VisualizationTools.LineGraph((int)LineGraphScope1.Width, (int)LineGraphScope1.Height); LineGraphScope1.Source = graphScope1; // Initialize the helper functions for the scope user interface (UI) uihelper = new ScopeUIHelper(); uihelper.CRTMargin_Vert = 20; uihelper.CRTMargin_Horz = 20; vcHelper = new VerticalControlHelper(); hcHelper = new HorizontalControlHelper(); hcHelper.iDivisionCount = ScopeGrid.ColumnDefinitions.Count; tHelper = new TriggerHelper(); tHelper.fTriggerLevel_V = 1.0f; tHelper.bTriggerSet = false; tHelper.bAcquiring = false; // The sampling frequency here must match that configured in the Arduino firmware hcHelper.fSamplingFreq_Hz = 625; // Initialize the data bus mbus = new MinSegBus(); // Initialize the buffers that recieve the data from the Arduino bCollectData = false; iChannelCount = 2; iStreamSampleCount = 2; iShortCount = iChannelCount * iStreamSampleCount; iFrameSize = mbus.iGetFrameCount_Short(iShortCount); idxData = 0; iStreamBuffLength = 128; idxData = 0; idxData_MinCount = 0; idxCharCount = 0; byteAddress = 0; iUnsignedShortArray = new UInt16[iShortCount]; // Data buffers dataScope1 = new float[hcHelper.iScopeDataLength]; dataScope2 = new float[hcHelper.iScopeDataLength]; dataNull = new float[hcHelper.iScopeDataLength]; for (int idx = 0; idx < hcHelper.iScopeDataLength; idx++) { dataScope1[idx] = Convert.ToSingle(1.0 + Math.Sin(Convert.ToDouble(idx) * (2.0 * Math.PI / Convert.ToDouble(hcHelper.iGetCRTDataLength())))); dataScope2[idx] = Convert.ToSingle(1.0 - Math.Sin(Convert.ToDouble(idx) * (2.0 * Math.PI / Convert.ToDouble(hcHelper.iGetCRTDataLength())))); dataNull[idx] = -100.0f; } // Scale factors fScope1ScaleADC = 5.0f / 1024.0f; fScope2ScaleADC = 5.0f / 1024.0f; // Default scope parameters bTrace1Active = true; bTrace2Active = true; // Update scope UpdateTraces(); graphScope1.setMarkIndex(Convert.ToInt32(hcHelper.iScopeDataLength / 2)); }