Coder Social home page Coder Social logo

adafruit_circuitpython_pcf8575's Introduction

Introduction

Documentation Status Discord Build Status Code Style: Black

CircuitPython library for Adafruit PCF8575 GPIO expander

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Purchase one from the Adafruit shop

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-pcf8575

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-pcf8575

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-pcf8575

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install adafruit_pcf8575

Or the following command to update an existing version:

circup update

Usage Example

See the examples/ folder for usage examples.

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_pcf8575's People

Contributors

evaherrada avatar foamyguy avatar ladyada avatar rgov avatar tannewt avatar tekktrik avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

foamyguy

adafruit_circuitpython_pcf8575's Issues

🧹🧹🧹

this is almost identical to the PCF8574 - but for simplicity and memory-savings i just made em two libraries

read_pin does not return a boolean

The implementation of the adafruit_pcf8575.PCF8575.read_pin() is:

    def read_pin(self, pin: int) -> bool:
        return (self.read_gpio() >> pin) & 0x1

The result of the calculation is an int. A bool should be constructed from the result before being passed back to the caller. (Aside: Doesn't mypy catch this?)

Consequently the adafruit_pcf8575.DigitalInOut.value does not adhere to the digitalio.DigitalInOut interface.

This also applies to the PCF8574 implementation.

Combine with adafruit_pcf8574 into a single implementation

In #4 I showed that it's a very simple code change to support the PCF8574 and other 8-bit expanders in the same module.

Therefore, it doesn't seem necessary to maintain two separate repos when the functionality is effectively identical. Fixes and improvements need to be submitted to both, for example #3 also applies to the Adafruit_CircuitPython_PCF8574 repo.

I can see from comparing the two that there are a lot of (mostly minor) differences between them, including inconsistent copyright/license, and at least one bug:

-    def pull(self, val: digitalio.Pull.UP) -> None:
+    def pull(self, val: digitalio.Pull) -> None:

Unifying these into adafruit_pcf857x module with backwards-compatible stubs for adafruit_pcf8574 and adafruit_pcf8575 would reduce the maintenance burden and likely result in a minor decrease in size for the CircuitPython library bundle. For example:

# in adafruit_pcf8574.py
class PCF8574(PCF857x):
    def __init__(
        self, i2c_bus: busio.I2C, address: int = PCF8574_I2CADDR_DEFAULT
    ) -> None:
        super().__init__(i2c_bus, address, gpios=8)

# in adafruit_pcf8575.py
class PCF8575(PCF857x):
    def __init__(
        self, i2c_bus: busio.I2C, address: int = PCF8575_I2CADDR_DEFAULT
    ) -> None:
        super().__init__(i2c_bus, address, gpios=16)

# in adafruit_pcf857x.py
class PCF857x:
    # As in #4. Maybe remove default values for constructor args.
    pass  

pcf857x is/was the name used in the Linux kernel to cover a lot of devices, listed in this document.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.