we will display the starting time. For the purposes of this
program, all values are stored as bytes. These means that
we have to use a bit of compression because we cannot
store 1440 (minutes in a day) into a byte. For stand-alone
sprinkler timers, watering start times do not require a lot
of resolution, so the time is expressed in 15 minute
increments (we could use 10, but I decided 15 was fine).
Here’s where we get special: At the top of the loop —
where the LCD is updated — we check to see if the start
time index is 96; when this is the case, we will display
“OFF.” Otherwise, we will calculate and show the starting
time formatted as HH:MM. The bottom of the loop is
similar to other editors, using get_input() to modify the
start time index value in the allowable range.
When the green Set/Enter button is pressed, the index
for the start time is saved to the Start_Times element and
copied to the EEPROM. As you scan through the example
code, you’ll see that the sprinkler run times are handled in
a similar fashion.
Okay. That was a bit of work, wasn’t it? Yes, in fact it
was — and some will continue to wonder why I use so
many layers in a simple program. When it comes to
programs, I like to apply George Lucas’ thought on
movies: They’re never done, they’re simply abandoned.
This example is small, but within it we’ve built the tools to
create a much more complex system. The laser tag
project, for example, has nearly 60 elements (x4 user-selected weapon types) that can be set by the field
operator; this requires about 2000 lines of Spin code to
accomplish — and that’s with the common code elements
to handle the variety of menus in that system, and not
counting attached child objects.
Big project or small, take your time when it comes to
the user interface, and design a system that is sensible and
easy to use. Apple built its entire brand on user interface.
Final story: About five years ago, I designed a camera
pan/tilt controller that uses an LCD and six-button
interface. One of the testers was on location in a cave
when rocks fell and damaged the LCD. Because my client
and I had spent a lot of time designing the flow of the
interface, the person using the controller was able to
remember the sequence of button presses and finish the
shoot! To me, that was a big success.
Happy New Year, friends! Until next time, keep
Spinning and winning with the Propeller! NV
January 2017 53
Jon "JonnyMac" McPhalen