Skip to content

Commit 7392d55

Browse files
committed
MCP23009
1 parent 5f4b746 commit 7392d55

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

doc/hardware_installation.md

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ This is essential for displays without buttons, like MIP displays.
180180

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

184186
### Battery
185187

doc/software_installation.md

+6
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ $ sudo pip3 install magnetic-field-calculator
198198
$ sudo apt install python3-buttonshim
199199
```
200200

201+
#### IO Expander (with MCP230009 and some buttons)
202+
203+
```
204+
$ sudo apt install adafruit-circuitpython-mcp230xx
205+
```
206+
201207
#### PiJuice HAT
202208

203209
Follow [official setup guide](https://github.com/PiSupply/PiJuice/tree/master/Software) of PiSupply/PiJuice

modules/sensor/i2c/MCP23009.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
from .base.button_io_expander import ButtonIOExpander
2-
from adafruit_mcp230xx.mcp23008 import MCP23008 as MCP
31
import board
42
import busio
3+
from adafruit_mcp230xx.mcp23008 import MCP23008 as MCP
4+
5+
from .base.button_io_expander import ButtonIOExpander
6+
57

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

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

modules/sensor/i2c/base/button_io_expander.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from digitalio import Direction, Pull
21
import time
32
from threading import Thread
4-
from logger import app_logger
53

4+
from digitalio import Direction, Pull
5+
6+
from logger import app_logger
67

78
try:
89
# run from top directory (pizero_bikecomputer)

0 commit comments

Comments
 (0)