(milliseconds). The next step removes the sign
and extracts the seconds from it. Now, the
key: We take the modulus of 1,000 from the
milliseconds register and if not 0, we bump
the value in now. If now differs from last
Item Source
Electronic Convention Badge Parallax #20100 (staff), #20000
(guest)
BOM
MMA7660FC PCB www.seeedstudio.com
(both are global variables), we update the
time display and then copy now into last.
www.madscientisthut.com
emartee.com/product/42141
Finally, we check the value of now to see if
the timer has expired; if it has, the program state is
changed to S_HOLD and the timer is put on hold.
If a button was pressed (I favor
active-high inputs), then we send
that value to process_buttons and
change the btimer milliseconds to
the negative value of
Before closing, let me share another trick I do with
the timer — again, I used this with Brian's zombie escape
room and the paratrooper training device. Each of them
has buttons that need to be read frequently, and after a
button is pressed, we need a hold-off period to prevent a
quick back-and-forth state or value changes. For those
programs, I did something like this:
pub check buttons | btns
if (btimer.millis < 0)
return
else
btimer.set(-BTN SCAN)
btns : read buttons
if (btns <> %000000)
process buttons(btns)
btimer.set(-BTN
HOLDOFF)
For the buttons, I create a
separate timer object called btimer.
The check_buttons routine gets
called without delays from the main
loop. When the milliseconds value
of btimer is zero or positive, it is
okay to scan the buttons. When this
is the case, we set the next available
scan time using BTN_SCAN (a
constant I tend to set around 25).
Now, we scan the buttons.
RESO
U
RCE
S
October 2015 15
Jon "JonnyMac" McPhalen
jon@jonmcphalen.com
Parallax, Inc.
Propeller boards, chips,
and programming tools
www.parallax.com