CircuitPython_LCD icon indicating copy to clipboard operation
CircuitPython_LCD copied to clipboard

Pi PICO support

Open julianrendell opened this issue 4 years ago • 5 comments

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.

julianrendell avatar May 19 '21 06:05 julianrendell

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.

dhalbert avatar May 19 '21 12:05 dhalbert

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.

dhalbert avatar May 19 '21 13:05 dhalbert

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?

dearpowa avatar Aug 13 '21 21:08 dearpowa

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'

harsh-gupta-10 avatar Nov 30 '23 12:11 harsh-gupta-10

It should be busio.I2C, all caps.

dhalbert avatar Nov 30 '23 14:11 dhalbert