|
Emakefun Matrix Keyboard Arduino Lib 1.0.1
|
MatrixKeyboard is a driver class for the Matrix Keyboard module. More...
#include <matrix_keyboard.h>
Public Types | |
| enum class | ErrorCode : uint32_t { kOK = 0 , kI2cDataTooLongToFitInTransmitBuffer = 1 , kI2cReceivedNackOnTransmitOfAddress = 2 , kI2cReceivedNackOnTransmitOfData = 3 , kI2cOtherError = 4 , kI2cTimeout = 5 , kInvalidParameter = 6 , kUnknownError = 7 } |
| Error codes. More... | |
| enum | Key : uint16_t { kKeyNone = static_cast<Key>(0) , kKey0 = static_cast<Key>(1) << 7 , kKey1 = static_cast<Key>(1) << 0 , kKey2 = static_cast<Key>(1) << 4 , kKey3 = static_cast<Key>(1) << 8 , kKey4 = static_cast<Key>(1) << 1 , kKey5 = static_cast<Key>(1) << 5 , kKey6 = static_cast<Key>(1) << 9 , kKey7 = static_cast<Key>(1) << 2 , kKey8 = static_cast<Key>(1) << 6 , kKey9 = static_cast<Key>(1) << 10 , kKeyA = static_cast<Key>(1) << 12 , kKeyB = static_cast<Key>(1) << 13 , kKeyC = static_cast<Key>(1) << 14 , kKeyD = static_cast<Key>(1) << 15 , kKeyAsterisk = static_cast<Key>(1) << 3 , kKeyNumberSign = static_cast<Key>(1) << 11 } |
| Key values. More... | |
| enum class | KeyState : uint8_t { kKeyStateIdle , kKeyStatePressed , kKeyStatePressing , kKeyStateReleased } |
| Key state. More... | |
Public Member Functions | |
| MatrixKeyboard (TwoWire &wire, const uint8_t i2c_address) | |
| 构造函数 | |
| ErrorCode | Initialize () |
| Initialize. | |
| void | Tick () |
| Scan keys, call this function in the loop function, and then query the key state each time the loop is executed. | |
| bool | Pressed (const Key key) const |
| Check whether the button is pressed. | |
| bool | Pressing (const Key key) const |
| Check whether the key is held down. | |
| bool | Released (const Key key) const |
| Check whether the key has been released. | |
| bool | Idle (const Key key) const |
| Check whether the key is idle. | |
| KeyState | GetKeyState (const Key key) const |
| Query key state. | |
| char | GetCurrentPressedKey () const |
| Get the currently pressed key. | |
Static Public Attributes | |
| static constexpr uint8_t | kDefaultI2cAddress = 0x65 |
| Default I2C address. | |
MatrixKeyboard is a driver class for the Matrix Keyboard module.
Definition at line 27 of file matrix_keyboard.h.
|
strong |
Error codes.
Definition at line 49 of file matrix_keyboard.h.
| enum emakefun::MatrixKeyboard::Key : uint16_t |
Key values.
| Enumerator | ||
|---|---|---|
| kKeyNone | static_cast<Key>(0) | No Key. |
| kKey0 | static_cast<Key>(1) << 7 | Key 0. |
| kKey1 | static_cast<Key>(1) << 0 | Key 1. |
| kKey2 | static_cast<Key>(1) << 4 | Key 2. |
| kKey3 | static_cast<Key>(1) << 8 | Key 3. |
| kKey4 | static_cast<Key>(1) << 1 | Key 4. |
| kKey5 | static_cast<Key>(1) << 5 | Key 5. |
| kKey6 | static_cast<Key>(1) << 9 | Key 6. |
| kKey7 | static_cast<Key>(1) << 2 | Key 7. |
| kKey8 | static_cast<Key>(1) << 6 | Key 8. |
| kKey9 | static_cast<Key>(1) << 10 | Key 9. |
| kKeyA | static_cast<Key>(1) << 12 | Key A. |
| kKeyB | static_cast<Key>(1) << 13 | Key B. |
| kKeyC | static_cast<Key>(1) << 14 | Key C. |
| kKeyD | static_cast<Key>(1) << 15 | Key D. |
| kKeyAsterisk | static_cast<Key>(1) << 3 | Key asterisk. |
| kKeyNumberSign | static_cast<Key>(1) << 11 | Key number sign. |
Definition at line 134 of file matrix_keyboard.h.
|
strong |
|
explicit |
构造函数
| [in] | wire | TwoWire object reference. |
| [in] | i2c_address | I2C address. |
Definition at line 5 of file matrix_keyboard.cpp.
| char emakefun::MatrixKeyboard::GetCurrentPressedKey | ( | ) | const |
Get the currently pressed key.
Definition at line 53 of file matrix_keyboard.cpp.
| MatrixKeyboard::KeyState emakefun::MatrixKeyboard::GetKeyState | ( | const Key | key | ) | const |
| bool emakefun::MatrixKeyboard::Idle | ( | const Key | key | ) | const |
Check whether the key is idle.
Definition at line 37 of file matrix_keyboard.cpp.
| MatrixKeyboard::ErrorCode emakefun::MatrixKeyboard::Initialize | ( | ) |
Initialize.
Definition at line 8 of file matrix_keyboard.cpp.
| bool emakefun::MatrixKeyboard::Pressed | ( | const Key | key | ) | const |
Check whether the button is pressed.
Definition at line 25 of file matrix_keyboard.cpp.
| bool emakefun::MatrixKeyboard::Pressing | ( | const Key | key | ) | const |
Check whether the key is held down.
Definition at line 29 of file matrix_keyboard.cpp.
| bool emakefun::MatrixKeyboard::Released | ( | const Key | key | ) | const |
Check whether the key has been released.
Definition at line 33 of file matrix_keyboard.cpp.
| void emakefun::MatrixKeyboard::Tick | ( | ) |
Scan keys, call this function in the loop function, and then query the key state each time the loop is executed.
Definition at line 20 of file matrix_keyboard.cpp.
|
staticconstexpr |
Default I2C address.
Definition at line 37 of file matrix_keyboard.h.