A Virtual Oscilloscope with GTK+

 

EE 5340/7340 Biomedical Instrumentation

Electrical Engineering Dept, SMU

 

Objectives: In this module, we will design a virtual oscilloscope using the gtkdatabox widget and GTK+ under cygwin. This “scope” will ultimately be used to read ECG data from the serial port of the PC.

 

  1. You will want to familiarize yourself with radio buttons (and as a consequence, with toggle buttons), see the GTK+-2.0 Tutorial.
  2. Take a look at the GTK+-2.0 Tutorial section on frames.
  3. Look at the gtkdatabox site as well as some of the gtkdatabox examples. Additional documentation on gtkdatabox can be found in gtkdatabox.h, located in /usr/local/include in the cygwin filesystem.

 

This module involves writing your own C code that implements a virtual “scope” having the following appearance:

 

 

Download and run the executable program. You will see that the program brings up an X window which, after pressing the “start” button will display a 1 Hz sinusoidal signal. The sampling rate can be adjusted by picking one of the sampling rate radio buttons. In terms of behavior, your program should be as close to the above virtual scope as possible and should:

 

gcc -Wall -g scope.c -o scope -L/usr/local/lib -lgtkdatabox `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`

 

            the “-L” option indicates the directory for local library files and the “-l” option indicates the name of the gtkdatabox library.

 

Answer the following questions:

 

  1. Sketch a diagram indicating the relative location of the various widgets, including packing boxes. Label each widget in the order that it was inserted into the main window.

 

  1. For each widget described in 1, show the program code that was used to create the widget and to insert it into the GUI.

 

  1. Indicate how the program mimics periodic reads from the serial port at the sampling rate.

 

  1. What do the callback functions for the “start” and “pause” buttons do?

 

  1. Describe what happens when, during pause mode, a new sampling rate is selected.