Open spuder opened 1 year ago
For anyone else struggling to get this working
Download the January 12th, 2023 release of Circuit Python 7.x Bundle
Download version 1.3.2 of NeoTrellis Library
You no longer need to install the adafruit_bus_driver
adafruit_neotrellis
library from the neotrellis download to the lib
folderadafrut_seasaw
library from the bundle download to the lib
folercode.py
on the deviceYou will need to update board.GP3
and board.GP2
with the SCL and SDA pins on your microcontroller.
Some microcontrollers have aliases like board.SDA
that you can reference. Other boards (like the raspberry pi pico) don't have those aliases. You can find out available pins by entering dir(board)
in the REPL.
import time
import board
import busio
from adafruit_neotrellis.neotrellis import NeoTrellis
# To view available pins, enter REPL and type `dir(board)`
# https://i0.wp.com/peppe8o.com/wp-content/uploads/2021/05/raspberry-pi-pico-pinout.jpg?w=792&ssl=1
# SDA = GP2 = pin4
# SCL = GP3 = pin5
i2c_bus = busio.I2C(board.GP3, board.GP2)
#create the trellis
trellis = NeoTrellis(i2c_bus)
trellis.brightness = 0.5
OFF = (0, 0, 0)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
def blink(event):
# turn the LED on when a rising edge is detected
if event.edge == NeoTrellis.EDGE_RISING:
trellis.pixels[event.number] = CYAN
# turn the LED off when a falling edge is detected
elif event.edge == NeoTrellis.EDGE_FALLING:
trellis.pixels[event.number] = OFF
for i in range(16):
# activate rising edge events on all keys
trellis.activate_key(i, NeoTrellis.EDGE_RISING)
# activate falling edge events on all keys
trellis.activate_key(i, NeoTrellis.EDGE_FALLING)
# set all keys to trigger the blink callback
trellis.callbacks[i] = blink
# cycle the LEDs on startup
trellis.pixels[i] = PURPLE
time.sleep(0.05)
while True:
trellis.sync()
time.sleep(0.02)
I don't see a place in the guide that says to download any specific (or older) version of the NeoTrellis library. It may be necessary to to update the pins though as you have done, as different CircuitPython boards have different names and quirks that cause the pin names to differ in the board
module. If you'd like to submit a PR mentioning that in a comment in the i2c_bus = busio.I2C(...
line, please do!
Setup
Circuit Python 7.20230112.zip Raspberry Pi Pico
Problem
If a user attempts to follow the instructions to set this up, they will run into the following problems.
create the i2c object for the trellis
i2c_bus = busio.I2C(SCL, SDA)
create the trellis
trellis = NeoTrellis(i2c_bus)