Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
matrix.hpp
1 /*
2  Title --- keypad/matrix.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_KEYPAD_MATRIX_HPP_
23 #define _RPI_HW_KEYPAD_MATRIX_HPP_
24 
25 #include <rpi-hw/types.hpp>
26 #include <rpi-hw/exception.hpp>
27 #include <rpi-hw/utils.hpp>
28 #include <rpi-hw/time.hpp>
29 
30 #include <rpi-hw/iface/base.hpp>
31 #include <rpi-hw/iface/output.hpp>
32 #include <rpi-hw/iface/input.hpp>
33 
34 #include <rpi-hw/keypad/base.hpp>
35 
36 namespace rpihw { // Begin main namespace
37 
38 namespace keypad { // Begin keypads namespace
39 
40 /*!
41  @class matrix
42  @brief Matrix keypad controller.
43 
44  @example keypad/12keys0.cpp
45  @example keypad/12keys1.cpp
46  @example keypad/16keys0.cpp
47  @example keypad/16keys1.cpp
48  @example keypad/16keys2.cpp
49 */
50 class matrix : public keypad::base {
51 
52 public:
53 
54  /*!
55  @brief Constructor method.
56  @param[in] cols Sequence of `uint8_t` containing the column GPIOs.
57  @param[in] rows Sequence of `uint8_t` containing the rows GPIOs.
58  */
59  matrix( std::initializer_list< uint8_t > cols, std::initializer_list< uint8_t > rows );
60 
61  /*!
62  @brief Constructor method.
63  @param[in] cols Sequence of `uint8_t` containing the column GPIOs.
64  @param[in] rows Sequence of `uint8_t` containing the rows GPIOs.
65  @param[in] keymap The keymap vector.
66  */
67  matrix( std::initializer_list< uint8_t > cols, std::initializer_list< uint8_t > rows, const std::vector< uint8_t > &keymap );
68 
69  //! Destructor method.
70  virtual ~matrix();
71 
72 protected:
73 
74  //! Columns output interface.
76 
77  //! Updates the state of buttons.
78  virtual void update();
79 };
80 
81 } // End of keypads namespace
82 
83 } // End of main namespace
84 
85 
86 // Include inline methods
87 #include <rpi-hw/keypad/matrix-inl.hpp>
88 
89 #endif /* _RPI_HW_KEYPAD_MATRIX_HPP_ */
Output interface.
Definition: output.hpp:43
Matrix keypad controller.
Definition: matrix.hpp:50
iface::output * m_output
Columns output interface.
Definition: matrix.hpp:75
Generic keypad controller.
Definition: base.hpp:59
matrix(std::initializer_list< uint8_t > cols, std::initializer_list< uint8_t > rows)
Constructor method.
virtual void update()
Updates the state of buttons.
virtual ~matrix()
Destructor method.