Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update library description #55

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: DOXYGEN

on: [push, pull_request]
jobs:
doxygen:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: mattnotmitt/[email protected]
with:
working-directory: '.'
doxyfile-path: 'Doxyfile'
- run: |
ls -alR
2,432 changes: 2,432 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

51 changes: 7 additions & 44 deletions PCF8574.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
//
// FILE: PCF8574.cpp
// AUTHOR: Rob Tillaart
// DATE: 02-febr-2013
// VERSION: 0.4.1
// 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 "PCF8574.h"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lost the header of the cpp file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image


PCF8574::PCF8574(const uint8_t deviceAddress, TwoWire *wire)
: _address {deviceAddress}, _wire {wire}
{}


bool PCF8574::begin(uint8_t value)
{
if (! isConnected()) return false;
PCF8574::write8(value);
return true;
}


bool PCF8574::isConnected()
{
_wire->beginTransmission(_address);
Expand All @@ -36,11 +23,6 @@ bool PCF8574::setAddress(const uint8_t deviceAddress)
return isConnected();
}

// removed _wire->beginTransmission(_address);
// with @100 KHz -> 265 micros()
// without @100 KHz -> 132 micros()
// without @400 KHz -> 52 micros()
// TODO @800 KHz -> ??
uint8_t PCF8574::read8()
{
if (_wire->requestFrom(_address, (uint8_t)1) != 1)
Expand All @@ -52,16 +34,6 @@ uint8_t PCF8574::read8()
return _dataIn;
}


void PCF8574::write8(const uint8_t value)
{
_dataOut = value;
_wire->beginTransmission(_address);
_wire->write(_dataOut);
_error = _wire->endTransmission();
}


uint8_t PCF8574::read(const uint8_t pin)
{
if (pin > 7)
Expand All @@ -73,6 +45,13 @@ uint8_t PCF8574::read(const uint8_t pin)
return (_dataIn & (1 << pin)) > 0;
}

void PCF8574::write8(const uint8_t value)
{
_dataOut = value;
_wire->beginTransmission(_address);
_wire->write(_dataOut);
_error = _wire->endTransmission();
}

void PCF8574::write(const uint8_t pin, const uint8_t value)
{
Expand All @@ -92,7 +71,6 @@ void PCF8574::write(const uint8_t pin, const uint8_t value)
write8(_dataOut);
}


void PCF8574::toggle(const uint8_t pin)
{
if (pin > 7)
Expand All @@ -103,14 +81,12 @@ void PCF8574::toggle(const uint8_t pin)
toggleMask(1 << pin);
}


void PCF8574::toggleMask(const uint8_t mask)
{
_dataOut ^= mask;
PCF8574::write8(_dataOut);
}


void PCF8574::shiftRight(const uint8_t n)
{
if ((n == 0) || (_dataOut == 0)) return;
Expand All @@ -119,7 +95,6 @@ void PCF8574::shiftRight(const uint8_t n)
PCF8574::write8(_dataOut);
}


void PCF8574::shiftLeft(const uint8_t n)
{
if ((n == 0) || (_dataOut == 0)) return;
Expand All @@ -128,15 +103,13 @@ void PCF8574::shiftLeft(const uint8_t n)
PCF8574::write8(_dataOut);
}


int PCF8574::lastError()
{
int e = _error;
_error = PCF8574_OK; // reset error after read, is this wise?
return e;
}


void PCF8574::rotateRight(const uint8_t n)
{
uint8_t r = n & 7;
Expand All @@ -145,13 +118,11 @@ void PCF8574::rotateRight(const uint8_t n)
PCF8574::write8(_dataOut);
}


void PCF8574::rotateLeft(const uint8_t n)
{
rotateRight(8 - (n & 7));
}


void PCF8574::reverse() // quite fast: 4 and, 14 shifts, 3 or, 3 assignment.
{
uint8_t x = _dataOut;
Expand All @@ -161,8 +132,6 @@ void PCF8574::reverse() // quite fast: 4 and, 14 shifts, 3 or, 3 assignment.
PCF8574::write8(x);
}


// added 0.1.07/08 Septillion
uint8_t PCF8574::readButton8(const uint8_t mask)
{
uint8_t temp = _dataOut;
Expand All @@ -172,8 +141,6 @@ uint8_t PCF8574::readButton8(const uint8_t mask)
return _dataIn;
}


// added 0.1.07 Septillion
uint8_t PCF8574::readButton(const uint8_t pin)
{
if (pin > 7)
Expand All @@ -189,22 +156,18 @@ uint8_t PCF8574::readButton(const uint8_t pin)
return value;
}


void PCF8574::select(const uint8_t pin)
{
uint8_t n = 0x00;
if (pin < 8) n = 1 << pin;
write8(n);
};


void PCF8574::selectN(const uint8_t pin)
{
uint8_t n = 0xFF;
if (pin < 8) n = (2 << pin) - 1;
write8(n);
};


// -- END OF FILE --

Loading
Loading