If we have a new seconds value that is copied to
lastsecs for net time, the seconds value is broken into
hours, minutes, and seconds for formatting. The timestr
array is, in fact, a z-string in a DAT block. This allows us to
build just the digits as shown, and that string is available to
other aspects of the program. In our case, we're going to
move the cursor and output the updated time to the
terminal. The check_tag() method does that. It looks to
see if the reader has captured a valid tag:
forward to the next tag in the database by adding 11 ( 10
tag bytes plus the terminating 0) to its pointer.
Okay, then. Let's put this to use in an updated demo.
To reinforce the use of the timer, we're going to create a
little program that displays a running clock which will be
the time from start-up or when the last valid tag was
presented to the system (unknown tags are ignored).
Figure 3 shows the output when a valid tag is presented.
A very simple loop maintains the running clock
display and checks for valid tags. The clock comes from
the timer object with includes a seconds() method:
pub check_tag | state, tidx, t1
state := rfid.check
We start by grabbing the seconds value and
comparing it to the last time we checked. If they match,
we immediately return.