BUTTONS
Description
Three buttons are used as part of the user interface for navigating through the menu and
recipe files. The first is an "up" button. This moves the cursor towards the top of the list
in Menu mode or retrieves the previous page in Edit mode. The second button is a "select"
button. It toggles the mode between Menu and Edit. The file that opens in Edit mode depends
on the cursor position in Menu mode. For example, if the cursor is on line 4 and the select
button is pressed then the fourth file is opened. The last button is the "down" button.
Similar to the up button it will move the cursor towards the bottom of the list in Menu mode
or retrieve the next page in Edit mode.
Circuit
Pins 5, 6, and 7 of PortD are used for button inputs. The inputs are normally tied to Vcc
through 10k resistors. When the buttons are pushed the inputs become connected to ground
and Vcc is dropped across the resistors.
Driver
The driver for the buttons is actually the function main(). It continually scans for a low
input on pins 5, 6, or 7 of PortD. The buttons are debounced in software by reading the
value of PortD, waiting a short while for debouncing, and then re-reading the value of PortD.
If the two values match they are considered valid. If one of the buttons are pressed then the
function continues, taking different actions depending on which button was pressed and which
mode the Digital Cookbook is in (Menu or Edit).