2021-01-29 06:31:58 -05:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: I2CKeyPad.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2021-05-08 03:52:18 -04:00
|
|
|
// VERSION: 0.2.1
|
2021-01-29 06:31:58 -05:00
|
|
|
// PURPOSE: Arduino libray for 4x4 KeyPad connected to an I2C PCF8574
|
|
|
|
// URL: https://github.com/RobTillaart/I2CKeyPad
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "Wire.h"
|
|
|
|
|
2021-05-08 03:52:18 -04:00
|
|
|
#define I2C_KEYPAD_LIB_VERSION (F("0.2.1"))
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
#define I2C_KEYPAD_NOKEY 16
|
|
|
|
#define I2C_KEYPAD_FAIL 17
|
|
|
|
|
|
|
|
class I2CKeyPad
|
|
|
|
{
|
|
|
|
public:
|
2021-05-08 03:52:18 -04:00
|
|
|
I2CKeyPad(const uint8_t deviceAddress, TwoWire *wire = &Wire);
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
#if defined(ESP8266) || defined(ESP32)
|
2021-05-08 03:52:18 -04:00
|
|
|
bool begin(uint8_t sda, uint8_t scl);
|
2021-01-29 06:31:58 -05:00
|
|
|
#endif
|
2021-05-08 03:52:18 -04:00
|
|
|
bool begin();
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
uint8_t getKey();
|
|
|
|
uint8_t getLastKey() { return _lastKey; };
|
|
|
|
bool isPressed();
|
|
|
|
bool isConnected();
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t _address;
|
|
|
|
uint8_t _lastKey;
|
|
|
|
uint8_t _read(uint8_t mask);
|
2021-05-08 03:52:18 -04:00
|
|
|
|
|
|
|
TwoWire* _wire;
|
2021-01-29 06:31:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// -- END OF FILE --
|