0.2.0 I2CKeyPad8x8

This commit is contained in:
Rob Tillaart 2023-11-11 17:09:31 +01:00
parent 8cf136ecad
commit 82e0c516c3
8 changed files with 68 additions and 51 deletions

View File

@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.0] - 2023-11-09
- simplify begin()
- update readme.md
- minor edits.
## [0.1.1] - 2022-11-12
- Add RP2040 support to build-CI.
- Add CHANGELOG.md

View File

@ -1,11 +1,9 @@
//
// FILE: I2CKeyPad8x8.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Arduino library for 8x8 or smaller KeyPad connected to an I2C PCF8575.
// URL: https://github.com/RobTillaart/I2CKeyPad8x8
//
// HISTORY: see changelog.md
#include "I2CKeyPad8x8.h"
@ -19,23 +17,18 @@ I2CKeyPad8x8::I2CKeyPad8x8(const uint8_t deviceAddress, TwoWire *wire)
}
#if defined(ESP8266) || defined(ESP32)
bool I2CKeyPad8x8::begin(uint8_t sda, uint8_t scl)
bool I2CKeyPad8x8::begin()
{
_wire->begin(sda, scl);
// enable interrupts
_read(0xFF00);
return isConnected();
}
#endif
bool I2CKeyPad8x8::begin()
bool I2CKeyPad8x8::isConnected()
{
_wire->begin();
// enable interrupts
_read(0xFF00);
return isConnected();
_wire->beginTransmission(_address);
return (_wire->endTransmission() == 0);
}
@ -79,8 +72,8 @@ uint8_t I2CKeyPad8x8::getKey()
}
uint8_t I2CKeyPad8x8::getLastKey()
{
uint8_t I2CKeyPad8x8::getLastKey()
{
return _lastKey;
};
@ -94,22 +87,15 @@ bool I2CKeyPad8x8::isPressed()
}
bool I2CKeyPad8x8::isConnected()
{
_wire->beginTransmission(_address);
return (_wire->endTransmission() == 0);
}
uint8_t I2CKeyPad8x8::getChar()
{
return _keyMap[getKey()];
{
return _keyMap[getKey()];
};
uint8_t I2CKeyPad8x8::getLastChar()
{
return _keyMap[_lastKey];
{
return _keyMap[_lastKey];
};
@ -143,5 +129,5 @@ uint16_t I2CKeyPad8x8::_read(uint16_t mask)
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: I2CKeyPad8x8.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Arduino library for 8x8 or smaller KeyPad connected to an I2C PCF8575.
// URL: https://github.com/RobTillaart/I2CKeyPad
@ -11,7 +11,7 @@
#include "Wire.h"
#define I2C_KEYPAD8x8_LIB_VERSION (F("0.1.1"))
#define I2C_KEYPAD8x8_LIB_VERSION (F("0.2.0"))
#define I2C_KEYPAD8x8_NOKEY 64
#define I2C_KEYPAD8x8_FAIL 65
@ -22,17 +22,14 @@ class I2CKeyPad8x8
public:
I2CKeyPad8x8(const uint8_t deviceAddress, TwoWire *wire = &Wire);
#if defined(ESP8266) || defined(ESP32)
bool begin(uint8_t sda, uint8_t scl);
#endif
bool begin();
bool isConnected();
// get raw key's 0..65
uint8_t getKey();
uint8_t getLastKey();
bool isPressed();
bool isConnected();
// get 'translated' keys
// user must load KeyMap, there is no check.
@ -52,5 +49,5 @@ protected:
};
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/I2CKeyPad8x8/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/I2CKeyPad8x8/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/I2CKeyPad8x8/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/I2CKeyPad8x8/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/I2CKeyPad8x8/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/I2CKeyPad8x8.svg)](https://github.com/RobTillaart/I2CKeyPad8x8/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/I2CKeyPad8x8/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/I2CKeyPad8x8.svg?maxAge=3600)](https://github.com/RobTillaart/I2CKeyPad8x8/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/I2CKeyPad8x8.svg)](https://registry.platformio.org/libraries/robtillaart/I2CKeyPad8x8)
# I2CKeyPad8x8
@ -18,13 +21,19 @@ EXPERIMENTAL (first tests ==> OK)
The I2CKeyPad8x8 library implements the reading of a 8x8 keypad by means of a PCF8575.
Smaller keypads, meaning less columns or rows (e.g. 5x4) can be read with it too.
Relates to https://github.com/RobTillaart/I2CKeyPad. which is an version using PCF8574.
#### Related
Relates strongly to https://github.com/RobTillaart/I2CKeyPad. which is an 8x8 version using **PCF8574**.
- https://github.com/RobTillaart/AnalogKeypad
- https://github.com/RobTillaart/I2CKeyPad8x8
## Connection
The PCF8575 is connected between the processor and the (default) 8x8 keypad.
See the conceptual schema below.
It might take some trying to get the correct pins connected.
```
PROC PCF8575 KEYPAD
@ -45,12 +54,18 @@ See the conceptual schema below.
## Interface
```cpp
#include "I2CKeyPad8x8.h"
```
#### Base
- **I2CKeyPad8x8(const uint8_t deviceAddress, TwoWire \*wire = &Wire)**
The constructor sets the device address and optionally
allows to selects the I2C bus to use.
- **bool begin()** The return value shows if the PCF8575 with the given address is connected properly.
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32.
The return value shows if the PCF8575 with the given address is connected properly.
Call wire.begin() first!
- **bool isConnected()** returns false if the PCF8575 cannot be connected to.
- **uint8_t getKey()** Returns default 0..63 for regular keys,
Returns 64 if no key is pressed and 65 in case of an error.
@ -81,7 +96,7 @@ The length is **NOT** checked upon loading (as it may contain a NULL char).
#### Basic working
After the **keypad.begin()** the sketch calls the **keyPad.getKey()** to read values from the keypad.
- If no key is pressed **I2CKeyPad8x8_NOKEY** code (16) is returned.
- If no key is pressed **I2C_KEYPAD8x8_NOKEY** code (16) is returned.
- If the read value is not valid, e.g. two keys pressed, **I2CKeyPad8x8_FAIL** code (17) is returned.
- Otherwise a number 0..63 is returned.
@ -107,16 +122,29 @@ See examples
## Future
#### must
- update documentation
#### Must
- update documentation
- keep in sync with **I2CKeyPad** as much as possible.
#### Should
#### should
- test extensively
- basic working (OK)
- interrupts
- keymapping
- performance
- keep in sync with **I2CKeyPad** as much as possible.
#### would
#### Could
#### Wont
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,

View File

@ -57,4 +57,4 @@ void loop()
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -6,14 +6,15 @@ I2CKeyPad8x8 KEYWORD1
# Methods and Functions (KEYWORD2)
begin KEYWORD2
isConnected() KEYWORD2
getKey KEYWORD2
getLastKey KEYWORD2
isPressed KEYWORD2
isConnected() KEYWORD2
loadKeyMap KEYWORD2
getChar KEYWORD2
getLastChar KEYWORD2
loadKeyMap KEYWORD2
# Instances (KEYWORD2)
@ -21,8 +22,7 @@ getLastChar KEYWORD2
# Constants (LITERAL1)
I2C_KEYPAD8x8_LIB_VERSION LITERAL1
I2C_KEYPAD8x8_NOKEY LITERAL1
I2C_KEYPAD8x8_FAIL LITERAL1
I2C_KEYPAD8x8_NOKEY LITERAL1
I2C_KEYPAD8x8_FAIL LITERAL1

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/I2CKeyPad8x8.git"
},
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "I2CKeyPad8x8.h"
}

View File

@ -1,5 +1,5 @@
name=I2CKeyPad8x8
version=0.1.1
version=0.2.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for a KeyPad connected to a PCF8575.