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

Support GPIO Extender by adding pigpio #55

Open
Kisty opened this issue Sep 16, 2018 · 2 comments
Open

Support GPIO Extender by adding pigpio #55

Kisty opened this issue Sep 16, 2018 · 2 comments
Labels

Comments

@Kisty
Copy link

Kisty commented Sep 16, 2018

I'd love to be able to run a full python IDE while creating my projects. With the GPIO extender tool, I can do just that! However, I don't think this library uses pigpio which is what the extender uses. Can you point me in the right direction as to how to add support?

@Gadgetoid
Copy link
Member

Try the refactor branch that's currently pending.

See: https://raw.githubusercontent.com/pimoroni/scroll-phat-hd/refactor/examples/hello-pigpiod.py

You should:

git clone https://github.com/pimoroni/scroll-phat-hd -b refactor
cd scroll-phat-hd/library
sudo python setup.py install
cd ../examples
PIGPIO_ADDR=your.pi.ip.addr python hello-pigpiod.py

@Gadgetoid
Copy link
Member

You can make all the examples work by shimming the smbus library.

Create a file smbus.py in the examples folder and stick the following into it:

import pigpio


class SMBus():
    def __init__(self, device):
        self.pi = pigpio.pi()
        self.i2c_handle = self.pi.i2c_open(device, 0x74)

    def write_byte_data(self, address, register, value):
        self.pi.i2c_write_byte_data(self.i2c_handle, register, value)

    def read_byte_data(self, address, register):
        return self.pi.i2c_read_byte_data(self.i2c_handle, register)

    def write_i2c_block_data(self, address, register, values):
        self.pi.i2c_write_i2c_block_data(self.i2c_handle, register, values)

This will replace the default smbus that the library attempts to import when no i2c module is specified, and reroute all i2c traffic via pigpio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants