NetBurner 3.5.8
PDF Version
Toggle main menu visibility
SparkFun_Qwiic_Keypad_Arduino_Library.h
1
/*
2
This is a library written for the SparkFun Qwiic Keypad
3
SparkFun sells these at its website: www.sparkfun.com
4
Do you like this library? Help support SparkFun. Buy a board!
5
https://www.sparkfun.com/products/15168
6
7
Written by Pete Lewis @ SparkFun Electronics, 3/12/2019
8
Much of the code originally came from SparkX version,
9
Located here: https://github.com/sparkfunX/Qwiic_Keypad
10
11
The Qwiic Keypad is a I2C controlled 12 button keypad
12
13
https://github.com/sparkfun/SparkFun_Qwiic_Keypad_Arduino_Library
14
15
Development environment specifics:
16
Arduino IDE 1.8.8
17
18
This program is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with this program. If not, see <http://www.gnu.org/licenses/>.
25
*/
26
27
#ifndef _SPARKFUN_QWIIC_KEYPAD_ARDUINO_LIBRARY_H
28
#define _SPARKFUN_QWIIC_KEYPAD_ARDUINO_LIBRARY_H
29
#include "Arduino.h"
30
#include "Wire.h"
31
32
#define QWIIC_KEYPAD_ADDR 0x4B
//7-bit unshifted default I2C Address
33
34
//Map to the various registers on the Keypad
35
enum
keypadRegisters {
36
KEYPAD_ID = 0x00,
37
KEYPAD_VERSION1,
// 0x01
38
KEYPAD_VERSION2,
// 0x02
39
KEYPAD_BUTTON,
// 0x03
40
KEYPAD_TIME_MSB,
// 0x04
41
KEYPAD_TIME_LSB,
// 0x05
42
KEYPAD_UPDATE_FIFO,
// 0x06
43
KEYPAD_CHANGE_ADDRESS,
// 0x07
44
};
45
46
class
KEYPAD {
47
public
:
48
KEYPAD();
49
50
boolean
begin(TwoWire &wirePort =
Wire
, uint8_t deviceAddress = QWIIC_KEYPAD_ADDR);
51
boolean
isConnected();
//Checks if sensor ack's the I2C request
52
String getVersion();
//Returns a two byte Major/Minor version number
53
54
uint8_t getButton();
//Returns the button at the top of the stack (aka the oldest button)
55
uint16_t getTimeSincePressed();
//Returns the 16 bit number of time since button pressed
56
void
updateFIFO();
// "commands" keypad to plug in the next button into the registerMap
57
// note, this actually sets the bit0 on the updateFIFO register
58
59
void
setI2CAddress(uint8_t newAddress);
//Change the I2C address to newAddress (Prints new address over serial)
60
61
private
:
62
TwoWire *_i2cPort;
63
uint8_t _deviceAddress;
64
boolean
writeRegister(uint8_t addr, uint8_t val);
65
uint8_t readRegister(uint8_t addr);
66
67
};
68
69
#endif
Wire
class TwoWire Wire
Pre-declared global TwoWire instance using platform default pins.
Definition
I2C/Wire/DocExamples/src/main.cpp:24
examples
I2C
Wire
SparkFunQwiic
KeyPad
src
SparkFun_Qwiic_Keypad_Arduino_Library.h
Generated by
1.18.0