adafruit / adafruit/Adafruit_CircuitPython_PCF8575
Combine with adafruit_pcf8574 into a single implementation
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
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:
```diff
- 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:
```python3
# 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](https://elixir.bootlin.com/u-boot/latest/source/doc/device-tree-bindings/gpio/gpio-pcf857x.txt).
Contributor guide
No contributing guide indexed for this repository
Research direction
Compare the existing adafruit_pcf8574 and adafruit_pcf8575 implementations, including the differences called out in #3 and #4. Review the proposed adafruit_pcf857x base module and the backwards-compatible stubs, then verify that both 8-bit and 16-bit expanders retain their public behavior while shared fixes apply to both.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100