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 readme and make the installer enable I2C #28

Open
wants to merge 4 commits into
base: main
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
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,62 @@ This library is also used to power our other Nuvoton-based boards and breakouts!
* Weather HAT: https://shop.pimoroni.com/products/weather-hat-only
* Inventor HAT Mini: https://shop.pimoroni.com/products/inventor-hat-mini


### Breakouts

* IO Expander Breakout: https://shop.pimoroni.com/products/io-expander
* RGB Potentiometer Breakout: https://shop.pimoroni.com/products/rgb-potentiometer-breakout
* RGB Encoder Breakout: https://shop.pimoroni.com/products/rgb-encoder-breakout
* MICS6814 3-in-1 Gas Sensor Breakout: https://shop.pimoroni.com/products/mics6814-gas-sensor-breakout

## Installing

# Getting the Library
We'd recommend using this library with Raspberry Pi OS Bookworm or later. It requires Python ≥3.7.

**Stable library only (no examples) from PyPi:**
### Full install (recommended):

* Just run `python3 -m pip install pimoroni-ioexpander`
We've created an easy installation script that will install all pre-requisites and get your IO Expander-based breakout
up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal
on your Raspberry Pi desktop, as illustrated below:

In some cases you may need to install pip with: `sudo apt install python3-pip`
![Finding the terminal](http://get.pimoroni.com/resources/github-repo-terminal.png)

**Stable library, with latest examples from GitHub:**
In the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:

* `git clone https://github.com/pimoroni/ioe-python`
* `cd ioe-python`
* `./install.sh`
```bash
git clone https://github.com/pimoroni/ioe-python
cd ioe-python
./install.sh
```

**Latest/development library and examples from GitHub:**
**Note** Libraries will be installed in the "pimoroni" virtual environment, you will need to activate it to run examples:

* `git clone https://github.com/pimoroni/ioe-python`
* `cd ioe-python`
* `./install.sh --unstable`
```
source ~/.virtualenvs/pimoroni/bin/activate
```

### Development:

# Configuring your Raspberry Pi
If you want to contribute, or like living on the edge of your seat by having the latest code, you can install the development version like so:

## Enable I2C
```bash
git clone https://github.com/pimoroni/ioe-python
cd ioe-python
./install.sh --unstable
```

In order to use the IO Expander, you need to enable the I2C interface of your Raspberry Pi. This can be done in the terminal by running:
## Install stable library from PyPi and configure manually

* `sudo raspi-config nonint do_i2c 0`
* Set up a virtual environment: `python3 -m venv --system-site-packages $HOME/.virtualenvs/pimoroni`
* Switch to the virtual environment: `source ~/.virtualenvs/pimoroni/bin/activate`
* Install the library: `pip install pimoroni-ioexpander`

Alternatively, you can enable the I2C interface by:
* running `sudo raspi-config` and enabling the option under **Interfacing Options**.
* opening the graphical **Raspberry Pi Configuration** application from the **Preferences** menu.
In some cases you may need to us `sudo` or install pip with: `sudo apt install python3-pip`.

You may need to reboot after enabling I2C for the change to take effect.
This will not make any configuration changes, so you may also need to enable:

* i2c: `sudo raspi-config nonint do_i2c 0`

You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.

## Note for Raspberry Pi 1

Expand All @@ -71,12 +84,11 @@ There are various examples to get you started with your IO Expander. With the li

To take IO Expander further, the full API is described in the [library reference](/REFERENCE.md), with additional feature specific information found in the [docs folder](/docs).


# Removing the Library

To uninstall the library only (keeping all examples):

* Just run `python3 -m pip uninstall pimoroni-ioexpander`
* Just run `pip uninstall pimoroni-ioexpander`

Or if you have grabbed the library from Github:

Expand Down
4 changes: 3 additions & 1 deletion examples/rotary.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
BRIGHTNESS = 0.5 # Effectively the maximum fraction of the period that the LED will be on
PERIOD = int(255 / BRIGHTNESS) # Add a period large enough to get 0-255 steps at the desired brightness

ioe = io.IOE(i2c_addr=I2C_ADDR, interrupt_pin=4)
ioe = io.IOE(i2c_addr=I2C_ADDR, interrupt_pin=None)
# If you'd like to use the hardware interrupt pin on your encoder breakout, you can use the following instead:
# ioe = io.IOE(i2c_addr=I2C_ADDR, interrupt_pin=4)

# Swap the interrupt pin for the Rotary Encoder breakout
if I2C_ADDR == 0x0F:
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ ignore = [
[tool.pimoroni]
apt_packages = []
configtxt = []
commands = []
commands = [
"printf \"Setting up i2c..\\n\"",
"sudo raspi-config nonint do_i2c 0",
]
Loading