diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db1ea1..1f9cb1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.3.8] - 2023-02-04 +- update readme.md +- update GitHub actions +- update license 2023 + + ## [0.3.7] - 2022-11-16 - fix #40 - add interrupt section to readme.md diff --git a/PCF8574.cpp b/PCF8574.cpp index eb1c0ac..2cc3e3f 100644 --- a/PCF8574.cpp +++ b/PCF8574.cpp @@ -2,13 +2,11 @@ // FILE: PCF8574.cpp // AUTHOR: Rob Tillaart // DATE: 02-febr-2013 -// VERSION: 0.3.7 +// VERSION: 0.3.8 // PURPOSE: Arduino library for PCF8574 - 8 channel I2C IO expander // URL: https://github.com/RobTillaart/PCF8574 // http://forum.arduino.cc/index.php?topic=184800 -// -// HISTORY: See CHANGELOG.md -// + #include "PCF8574.h" @@ -186,7 +184,7 @@ void PCF8574::rotateLeft(const uint8_t n) } -void PCF8574::reverse() // quite fast: 14 shifts, 3 or, 3 assignment. +void PCF8574::reverse() // quite fast: 4 and, 14 shifts, 3 or, 3 assignment. { uint8_t x = _dataOut; x = (((x & 0xAA) >> 1) | ((x & 0x55) << 1)); @@ -240,6 +238,5 @@ void PCF8574::selectN(const uint8_t pin) }; - -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/PCF8574.h b/PCF8574.h index 750fef6..4b19ba8 100644 --- a/PCF8574.h +++ b/PCF8574.h @@ -3,18 +3,17 @@ // FILE: PCF8574.h // AUTHOR: Rob Tillaart // DATE: 02-febr-2013 -// VERSION: 0.3.7 +// VERSION: 0.3.8 // PURPOSE: Arduino library for PCF8574 - 8 channel I2C IO expander // URL: https://github.com/RobTillaart/PCF8574 // http://forum.arduino.cc/index.php?topic=184800 -// #include "Arduino.h" #include "Wire.h" -#define PCF8574_LIB_VERSION (F("0.3.7")) +#define PCF8574_LIB_VERSION (F("0.3.8")) #ifndef PCF8574_INITIAL_VALUE #define PCF8574_INITIAL_VALUE 0xFF @@ -40,7 +39,7 @@ class PCF8574 // note: setting the address corrupt internal buffer values // a read8() / write8() call updates them. bool setAddress(const uint8_t deviceAddress); - uint8_t getAddress(); + uint8_t getAddress(); uint8_t read8(); @@ -63,7 +62,8 @@ class PCF8574 // rotate, shift, toggle, reverse expect all lines are output void toggle(const uint8_t pin); - void toggleMask(const uint8_t mask = 0xFF); // default 0xFF ==> invertAll() + // default 0xFF ==> invertAll() + void toggleMask(const uint8_t mask = 0xFF); void shiftRight(const uint8_t n = 1); void shiftLeft(const uint8_t n = 1); void rotateRight(const uint8_t n = 1); @@ -91,5 +91,5 @@ class PCF8574 }; -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/README.md b/README.md index e1f307f..aeae609 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ Related to the PCF8575 16 channel IO expander library https://github.com/RobTil This library gives easy control over the 8 pins of a PCF8574 and PCF8574A chip. These chips are identical in behaviour although there are two distinct address ranges. -| TYPE | ADDRESS-RANGE | notes | -|:---------|:-------------:|:------------------------:| -|PCF8574 | 0x20 to 0x27 | same range as PCF8575 !! | -|PCF8574A | 0x38 to 0x3F | | +| type | address-range | notes | +|:-----------|:---------------:|:-------------------------:| +| PCF8574 | 0x20 to 0x27 | same range as PCF8575 ! | +| PCF8574A | 0x38 to 0x3F | + So you can connect up to 16 PCF8574 on one I2C bus, giving access to 16 x 8 = 128 IO lines. To maximize IO lines combine 8 x PCF8575 + 8 x PCF8574A giving @@ -45,24 +46,44 @@ There are two examples to show how interrupts can be used: - PCF8574_rotaryEncoder.ino +#### Related + +16 bit port expanders + +- https://github.com/RobTillaart/MCP23017_RT +- https://github.com/RobTillaart/MCP23S17 +- https://github.com/RobTillaart/PCF8575 + + +8 bit port expanders + +- https://github.com/RobTillaart/MCP23008 +- https://github.com/RobTillaart/MCP23S08 +- https://github.com/RobTillaart/PCF8574 + + ## I2C Clock Tested on UNO with **PCF8574_performance** showed that the PCF8574 still works at 500 KHz and failed at 600 KHz. These values are outside the specs of the datasheet so they are not recommended. However when performance is needed you can try to overclock the chip. -| clock speed | Read | Write | Notes | -|:-----------:|:------:|:-------:|:------------------| -| 100000 | 236 | 240 | spec datasheet | +| clock speed | Read | Write | Notes | +|:-----------:|:------:|:-------:|:--------------------| +| 100000 | 236 | 240 | spec datasheet | | 200000 | 132 | 140 | | 300000 | 104 | 108 | -| 400000 | 96 | 96 | max advised speed | -| 500000 | 92 | 92 | not recommended | +| 400000 | 96 | 96 | max advised speed | +| 500000 | 92 | 92 | not recommended | | 600000 | crash | crash | ## Interface +```cpp +#include "PCF8574.h" +``` + **PCF8574_INITIAL_VALUE** is a define that can be set compile time or before the include of "pcf8574.h" to overrule the default value used with the **begin()** call. @@ -144,11 +165,11 @@ This can typical be used to implement a VU meter. ## Error codes -| name | value | description | -|:-------------------|:-----:|:------------------------| -| PCF8574_OK | 0x00 | no error | -| PCF8574_PIN_ERROR | 0x81 | pin number out of range | -| PCF8574_I2C_ERROR | 0x82 | I2C communication error | +| name | value | description | +|:--------------------|:-------:|:--------------------------| +| PCF8574_OK | 0x00 | no error | +| PCF8574_PIN_ERROR | 0x81 | pin number out of range | +| PCF8574_I2C_ERROR | 0x82 | I2C communication error | ## Operation @@ -160,6 +181,17 @@ It is advised to use pull-up or pull-down resistors so the lines have a defined ## Future -- +#### Must + +- keep in sync with PCF8575 + +#### Should + + +#### Could + +- move code to .cpp + +#### Wont diff --git a/library.json b/library.json index 712755b..6e9ce08 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/PCF8574.git" }, - "version": "0.3.7", + "version": "0.3.8", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/library.properties b/library.properties index c5b4043..105f334 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=PCF8574 -version=0.3.7 +version=0.3.8 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for PCF8574 - 8 channel I2C IO expander diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index af58a29..0aee909 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -105,4 +105,5 @@ unittest(test_address) unittest_main() -// -------- +// -- END OF FILE -- +