circuitpython: RP2040: charlcd demo fails - mcp230xx error
As reported by a Discord User, accessing a Character LCD fails on a Raspberry Pi Pico
The same example runs normally on a metro-esp32s2
For this example I used SCL on GP1 SDA on GP0
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-28; Raspberry Pi Pico with rp2040
>>>
>>> import charlcd_i2c_rgb_simpletest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "charlcd_i2c_rgb_simpletest.py", line 18, in <module>
File "adafruit_character_lcd/character_lcd_rgb_i2c.py", line 75, in __init__
File "adafruit_mcp230xx/mcp23017.py", line 52, in __init__
File "adafruit_mcp230xx/mcp23017.py", line 102, in iodir
File "adafruit_mcp230xx/mcp230xx.py", line 49, in _write_u16le
File "adafruit_mcp230xx/mcp230xx.py", line 49, in _write_u16le
OSError: [Errno 19] Unsupported operation
>>>
it fails at the line
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
Note - the original issue was for a non-rgb test and it uses the mcp23008 and failed on a read attempt https://discord.com/channels/327254708534116352/537365702651150357/8062596030453514
code run
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Simple test for I2C RGB character LCD shield kit"""
import time
import board
import busio
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
# Modify this if you have a different sized Character LCD
lcd_columns = 16
lcd_rows = 2
# Initialise I2C bus.
i2c = busio.I2C(board.GP1, board.GP0)
# Initialise the LCD class
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
lcd.clear()
# Set LCD color to red
lcd.color = [100, 0, 0]
time.sleep(1)
# Print two line message
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
# Set LCD color to blue
lcd.color = [0, 100, 0]
time.sleep(1)
# Set LCD color to green
lcd.color = [0, 0, 100]
time.sleep(1)
# Set LCD color to purple
lcd.color = [50, 0, 50]
time.sleep(1)
lcd.clear()
# Print two line message right to left
lcd.text_direction = lcd.RIGHT_TO_LEFT
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
# Return text direction to left to right
lcd.text_direction = lcd.LEFT_TO_RIGHT
# Display cursor
lcd.clear()
lcd.cursor = True
lcd.message = "Cursor! "
# Wait 5s
time.sleep(5)
# Display blinking cursor
lcd.clear()
lcd.blink = True
lcd.message = "Blinky Cursor!"
# Wait 5s
time.sleep(5)
lcd.blink = False
lcd.clear()
# Create message to scroll
scroll_msg = "<-- Scroll"
lcd.message = scroll_msg
# Scroll to the left
for i in range(len(scroll_msg)):
time.sleep(0.5)
lcd.move_left()
lcd.clear()
time.sleep(1)
lcd.message = "Going to sleep\nCya later!"
time.sleep(5)
# Turn off LCD backlights and clear text
lcd.color = [0, 0, 0]
lcd.clear()
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (1 by maintainers)
The 74hc595 library is used only for SPI. The backpack has an MCP23008 for I2C and a 74HC595 for SPI use. I will clarify the Guide.