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

Pi PICO support #6

Open
julianrendell opened this issue May 19, 2021 · 5 comments
Open

Pi PICO support #6

julianrendell opened this issue May 19, 2021 · 5 comments

Comments

@julianrendell
Copy link

The Pico has configurable SPI pins.

Adafruit has a straight forward explanation: https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/pinouts - scroll down the the i2c section.

Easy hack-fix is to change i2c_pcf8574_interface.py:

        #  self.i2c = busio.I2C(board.SCL, board.SDA)
        # Pi PICO Hack
        self.i2c = busio.I2C(scl=board.GP1, sda=board.GP0)

A better/simple fix is probably to add scl and sda parameters to __init__ with default values of board.SCL and board.SDA respectively.

@dhalbert
Copy link
Owner

dhalbert commented May 19, 2021

I wrote this library for a single project a long time ago. Now I work for Adafruit 🙂, and I'll regularize the constructor. The normal thing we do now is to have you pass in an I2C object to the constructor.

@dhalbert
Copy link
Owner

Changed but not tested:

  • default branch is now main, so pull and checkout main instead of master, or re-clone.
  • Now you must pass in the I2C object to the constructor, e.g.:
i2c = busio.i2c(scl=board.GP1, sda=board.GP0)
interface = I2CPCF8574Interface(i2c, i2c_address)
...

I think I've fixed the brightness issue also, but try it.

Most of my work on this has been on the minimal branch, which removes a number of features to save space. That was when I was trying to get this to fit on a Feather M0.

@dearpowa
Copy link

I wrote this library for a single project a long time ago. Now I work for Adafruit slightly_smiling_face, and I'll regularize the constructor. The normal thing we do now is to have you pass in an I2C object to the constructor.

Now that you work at adafruit, any news if PCF8574 will be supported in the official adafruit cricuitpython libraries for i2c displays?

@harsh-gupta-10
Copy link

harsh-gupta-10 commented Nov 30, 2023

import board,busio

from lcd.lcd import LCD
from lcd.i2c_pcf8574_interface import I2CPCF8574Interface

from lcd.lcd import CursorMode
i2c = busio.i2c(scl=board.GP1, sda=board.GP0)
interface = I2CPCF8574Interface(i2c, i2c_address)

lcd.print("abc ")
lcd.print("This is quite long and will wrap onto the next line automatically.")

lcd.clear()

# Start at the second line, fifth column (numbering from zero).
lcd.set_cursor_pos(1, 4)
lcd.print("Here I am")

# Make the cursor visible as a line.
lcd.set_cursor_mode(CursorMode.LINE)

my code this is giving me an error

soft reboot
Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
AttributeError: 'module' object has no attribute 'i2c'

@dhalbert
Copy link
Owner

It should be busio.I2C, all caps.

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

No branches or pull requests

4 participants