Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Usage Example¶
see examples/neotrellis_simpletest.py for usage example
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Building locally¶
Zip release files¶
To build this library locally you’ll need to install the circuitpython-build-tools package.
python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools
Once installed, make sure you are in the virtual environment:
source .env/bin/activate
Then run the build:
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-neotrellis --library_location .
Sphinx documentation¶
Sphinx is used to build the documentation based on rST files and comments in the code. First, install dependencies (feel free to reuse the virtual environment from above):
python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme
Now, once you have the virtual environment activated:
cd docs
sphinx-build -E -W -b html . _build/html
This will output the documentation to docs/_build/html
. Open the index.html in your browser to
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
locally verify it will pass.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import time
from board import SCL, SDA
import busio
from adafruit_neotrellis.neotrellis import NeoTrellis
#create the i2c object for the trellis
i2c_bus = busio.I2C(SCL, SDA)
#create the trellis
trellis = NeoTrellis(i2c_bus)
#some color definitions
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)
#this will be called when button events are received
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 rising 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(.05)
for i in range(16):
trellis.pixels[i] = OFF
time.sleep(.05)
while True:
#call the sync function call any triggered callbacks
trellis.sync()
#the trellis can only be read every 17 millisecons or so
time.sleep(.02)
|
adafruit_neotrellis
¶
4x4 elastomer buttons and RGB LEDs
- Author(s): Dean Miller
Implementation Notes¶
Hardware:
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit Seesaw CircuitPython library https://github.com/adafruit/Adafruit_CircuitPython_seesaw/releases
-
class
adafruit_neotrellis.neotrellis.
NeoTrellis
(i2c_bus, interrupt=False, addr=46, drdy=None)¶ Driver for the Adafruit NeoTrellis.
-
activate_key
(key, edge, enable=True)¶ Activate or deactivate a key on the trellis. Key is the key number from 0 to 16. Edge specifies what edge to register an event on and can be NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING. enable should be set to True if the event is to be enabled, or False if the event is to be disabled.
-
sync
()¶ read any events from the Trellis hardware and call associated callbacks
-