Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 23rd, 2004, 06:28 AM
Registered User
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to johol545
Default Visualize data in Compact Framework

I'm receiving a stream of data captured from some ECG-equipment via Bluetooth. I save the data in an array but I'd also like to show the data in "real time".

What is the best approach? Now I use a bitmap in witch i draw lines like
bmpGraphics.DrawLine(blackpen, oldX, lastPlottedValue, oldX++, newValue)
but that's too slow. I call
for every 10:th value plotted.

I have to plot at at least 400Hz. Any suggestions? Any nice (free) component that can help me? Any nice methods to use?

Example code:
private void port_DataReceived() 
            while(port.InBufferCount > 1) 
                // Read two bytes from port and save them as a short in the array
                dataStorage[recievedValues++] = BitConverter.ToInt16(port.Input, 0);

                // Update the GUI every 10th reception
                if(recievedValues % 20 == 0) 
                        this.Invoke(new EventHandler(updateGUI));
                    catch(Exception e) 

        private void updateGUI(object o, EventArgs e) 
            // Update the recieved values label.
            label2.Text = recievedValues.ToString();
            // Draw the graph

        private void hScrollBar1_ValueChanged_1(object sender, System.EventArgs e)
            this.graph_panel.Left = -this.hScrollBar1.Value;

        private void drawGraph() 
            // Do this as many times as there's unplotted values.
            for(int i = 0; i < recievedValues - plottedValues; i++) 
                // Calculate new y-value to plot
                int y2 = (int)((dataStorage[plottedValues + 1] - short.MinValue) / yscale);

                // Draw a line from last plotted point to the one calculated above
                bmpGraphics.DrawLine(blackpen, plottedValues, lastPlottedValue, plottedValues + 1, y2);

                // Increase plotted values counter

                // Save the plotted value to use as starting point for next line
                lastPlottedValue = y2;

                // Set the scroll bar into right position
                hScrollBar1.Maximum = plottedValues - hScrollBar1.Width; // Should be width of something else, but it didn't work =(
                hScrollBar1.Value = hScrollBar1.Maximum;


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFileDialog on .NET Compact Framework yukijocelyn C# 2005 0 July 4th, 2008 11:35 PM
Any one known VB 2005 compact framework sjar Visual Basic 2005 Basics 0 July 2nd, 2007 01:34 PM
compact framework - device emulator badgolfer .NET Framework 2.0 0 February 20th, 2007 06:45 PM
How use framework components in compact framework? r_bazghaleh C# 0 February 19th, 2006 05:05 AM
.Net Compact Framework Forum? Rissa Forum and Wrox.com Feedback 0 March 17th, 2004 05:28 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.