In our last article, we showed you how to build a custom Interface called My_Interface.spm using meters, switches, buttons, and textboxes that consist of
“graphics only” controls at this point. Without Event
Codes, these controls can’t do anything. For example, if
you click on a button, nothing will happen. This article will
fill in the blanks with Event Codes for each of the controls
so they will actually work and — more importantly — to
instruct you how to do it when you create your own
Interfaces. If you already have MakerPlot installed, you can
follow along. If you haven’t already done so, you can
download a free 30 day trial copy of MakerPlot from
www.makerplot.com. If you like what you see and what it
does, you can order it from the NV Webstore at a
discounted price. Let’s get going.
Event Code Basics
MakerPlot Event Codes are the instructions for
programming the controls that populate any Interface. The
best way to learn any programming language (IMHO) is to
see what others have done with it. Following our own
advice, we want to begin our Event Code lesson by
showing you some fundamental uses of it to make meters,
switches, and buttons do things.
To begin, load the My_Interface.spm and right-click on
the Reset Plot button to bring up the Object Editor.
Figure 1 displays the Event Code for this button. As you
can see, it’s simply one instruction (!RSET), and comments
are prefaced by a single quote as in ‘Reset Plot above the
instruction. When the Reset Plot button is clicked, the
!RSET instruction is executed which clears the plot area
and sets the plot to time zero.
What’s most important to realize is that you have to
enter Event Codes into each control; they don’t appear by
themselves. Another important point is the exclamation
point (!) prefix to each instruction. This tells MakerPlot
that what follows is one of its instructions. Figure 2 is
MakerPlot –
The DIY Software Kit
Part 9
By John Gavlik
and Martin Hebel
Post comments on this article and find any associated files
and/or downloads at www.nutsvolts.com/
index.php?/magazine/article/june2014_MakerPlot.
This MakerPlot article is about
Event Codes. Event Codes are the
instructions that make every
switch, button, and textbox control
an Interface to do what you want
it to do. Event Codes get executed
whenever you click on a control
(an external event) or when an
internal event happens to cause
an action by the control — like an
alarm going off when an analog
value is above or below the set
levels. Event Codes consist of one
or more MakerPlot instructions,
and every control that reacts to
internal or external stimulus has to
have some form of Event Code.
50 June 2014
Figure 1. Reset Plot Button Event Code.