can also utilize AGI plotting routines inside of the setup()
segment if you want to show a splash screen or plot static
unchanging background graphics.
Mainline Loop - Here is where the bulk of your code
will likely go. Take a look at the CRT_SCOPE sample code
mainline loop and use it as a baseline to get started writing
your own AGI programs.
Let’s Get Plotting!
With the setup and preliminaries out of the way, let’s
give the graphics library a try. A list of the available AGI
routines is shown in Table 1. These high level routines
make using the AGI easy and fun. While the table provides
a brief overview of each routine, I suggest that you
examine the sample program CRT_SCOPE to check out a
working example of the format and usage for each library
POINTS, LINES, CIRCLES, ELLIPSES – In addition
to the plotPoint(x,y) routine already discussed, a number
of other graphics plotting functions are also provided.
plotLine(x0,y0,x1,y1), for example, is used for drawing
vectors to the screen from coordinate (x0,y0) to (x1,y1).
Similarly, plotCircle(xc,yx,r) draws a circle centered at
coordinate (xc,yc) of radius r.
TEXT CHARACTERS – Characters are formed by
combining lines, circles, ellipses, and arcs together. A
structured data table was created to define a vector font for
the AGI so text can be easily ‘printed’ to the CRT screen.
This font is fully scalable with many routines that make it
easy to plot text and numbers of varying size to the CRT.
As shown in Figure 5, the font can be set to use MONO or
PROPORTIONAL spacing. At startup, the spacing defaults
to MONO mode.
BRIGHTNESS – Any single graphic point plotted to the
CRT will be either full on or full off. At first blush, it appears
that we have no intensity or display brightness control.
However, since lines, text, arcs, circles, and ellipses are
simply made up of closely spaced individual points, we
can vary display brightness by changing the density and
spacing of the individual points making up each feature.
Closely packing the points — that is putting very little space
between them — will cause a feature to appear very bright.
Similarly, putting more space between adjacent points will
cause the feature to dim.
Two routines — setGraphIntensity(…) and
set TextIntensity(…) — are used to independently set the
point-to-point spacing values of graphics and text entities.
This effect is shown in Figure 6 where each of the “hour
digits” have been plotted at intensities starting at 20% on
up to 250%. Individual dots can be seen in the dimmer
characters (i.e., 1 o’clock).
SCREEN SAVER – Prolonged tracing of an unchanging
pattern onto the face of a cathode ray tube can
permanently burn that pattern into the phosphor. That’s
why screen saver programs were first invented. I have
included the setScreenSaveSecs(ScreenOnTime) routine in
the library to provide this protection. This routine measures
the time since the last plotPoint(…) routine call, and blanks
the CRT when the specified ScreenOnTime seconds have
elapsed. The screen saver can be disabled by setting the
ScreenOnTime = 0.
The Sample Program
Sample program CRT_SCOPE is included as part of the
XYscope library download. You can quickly get started by
opening CRT_SCOPE, compiling, and uploading the code
into your Due. Once you’ve got the code running, open
the serial monitor (baud rate=115000, format=NONE), and
you will see and interact with the option menu shown in
HARDWARE SETUP - By using CRT_SCOPE, you
can run several test patterns to help get the hardware
debugged and set up. For example, Option 7 will display
a circular test image to the screen that you can use to
make the AGI gain and offset adjustments. To do this, just
monitor the X and Y AGI outputs using your oscilloscope
(as a regular scope!), and adjust gain and position pots
on the AGI board for a 1.0 to 4.0V P-P amplitude sine
FIGURE 5. The AGI font can be used in Mono (left) or Proportional (right) spacing
FIGURE 6. Variable brightness
March 2018 49