Skip to content

Commit

Permalink
MCP23009
Browse files Browse the repository at this point in the history
  • Loading branch information
hishizuka committed Jun 3, 2024
1 parent 5f4b746 commit 7392d55
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doc/hardware_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ This is essential for displays without buttons, like MIP displays.

- [Button SHIM](https://shop.pimoroni.com/products/button-shim)
- <img src="https://user-images.githubusercontent.com/12926652/91799330-cfc50580-ec61-11ea-9045-e1991aed205c.png" width=240 />
- IO Expander (with MCP230009 and some buttons)
- <img src="https://github.com/hishizuka/pizero_bikecomputer/assets/12926652/0477aac3-96a2-40f9-bae9-efd3d77ed46f" width=480 />

### Battery

Expand Down
6 changes: 6 additions & 0 deletions doc/software_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ $ sudo pip3 install magnetic-field-calculator
$ sudo apt install python3-buttonshim
```

#### IO Expander (with MCP230009 and some buttons)

```
$ sudo apt install adafruit-circuitpython-mcp230xx
```

#### PiJuice HAT

Follow [official setup guide](https://github.com/PiSupply/PiJuice/tree/master/Software) of PiSupply/PiJuice
Expand Down
7 changes: 4 additions & 3 deletions modules/sensor/i2c/MCP23009.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from .base.button_io_expander import ButtonIOExpander
from adafruit_mcp230xx.mcp23008 import MCP23008 as MCP
import board
import busio
from adafruit_mcp230xx.mcp23008 import MCP23008 as MCP

from .base.button_io_expander import ButtonIOExpander


# https://www.microchip.com/en-us/product/mcp23009
# https://ww1.microchip.com/downloads/en/DeviceDoc/20002121C.pdf


# NOTE: no need to set TEST and RESET address and value, due to adafruit_mcp230xx library handling it.
class MCP23009(ButtonIOExpander):

Expand Down
5 changes: 3 additions & 2 deletions modules/sensor/i2c/base/button_io_expander.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from digitalio import Direction, Pull
import time
from threading import Thread
from logger import app_logger

from digitalio import Direction, Pull

from logger import app_logger

try:
# run from top directory (pizero_bikecomputer)
Expand Down

0 comments on commit 7392d55

Please sign in to comment.