Skip to content

Commit

Permalink
update readme.md (#41)
Browse files Browse the repository at this point in the history
- update readme.md
- update GitHub actions
- update license 2023
  • Loading branch information
RobTillaart authored Feb 4, 2023
1 parent 45d61ea commit ba65689
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 4 additions & 7 deletions PCF8574.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -240,6 +238,5 @@ void PCF8574::selectN(const uint8_t pin)
};



// -- END OF FILE --
// -- END OF FILE --

12 changes: 6 additions & 6 deletions PCF8574.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -91,5 +91,5 @@ class PCF8574
};


// -- END OF FILE --
// -- END OF FILE --

62 changes: 47 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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


2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PCF8574
version=0.3.7
version=0.3.8
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for PCF8574 - 8 channel I2C IO expander
Expand Down
3 changes: 2 additions & 1 deletion test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ unittest(test_address)
unittest_main()


// --------
// -- END OF FILE --

0 comments on commit ba65689

Please sign in to comment.