PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/firmware/src/shared/ButtonArray.hh

http://github.com/makerbot/G3Firmware
C++ Header | 48 lines | 25 code | 9 blank | 14 comment | 0 complexity | 76711a354fe2e4897a4a2f13ea158626 MD5 | raw file
 1#ifndef BUTTONARRAY_HH
 2#define BUTTONARRAY_HH
 3
 4#include <util/atomic.h>
 5#include "Types.hh"
 6
 7// TODO: Make this an interface?
 8
 9/// The button array modules manages an array of buttons, and maintains
10/// a buffer of the last pressed button. It has two entry points: a fast
11/// #scanButtons, which is a fast button scanning routine that should be
12/// called from an interrupt, and #getButton, which should be called by a
13/// slow loop that has time to respond to the button.
14///
15/// Porting Notes:
16/// This modules uses low-level port registers, and must be re-written for
17/// each board archetecture. This should be done by adding a ButtonArray.cc
18/// definition in the board directory.
19/// \ingroup HardwareLibraries
20class ButtonArray {
21private:
22        uint8_t buttonPress;
23        bool buttonPressWaiting;
24
25public:
26        /// Representation of the different buttons available on the keypad
27        enum ButtonName {
28                ZERO            = 1,
29                ZMINUS          = 2,
30                ZPLUS           = 3,
31                YMINUS          = 4,
32                YPLUS           = 5,
33                XMINUS          = 6,
34                XPLUS           = 7,
35                CANCEL          = 11,
36                OK              = 12
37        };
38
39        void init();
40
41        // Returns true if any of the button states have changed.
42        void scanButtons();
43
44        bool getButton(ButtonName& button);
45};
46
47
48#endif // BUTTONARRAY_HH