Introduction¶
Use Adafruit TrellisM4 Express board as 2 Neotrellis board. You can you use this to extend TrellisM4 with Neotrellis (seesaw) boards.
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¶
To use Trellis as 2 Neotrellis (seesaw):
from neotrellism4 import NeoTrellisM4
trellis_left = NeoTrellisM4()
trellis_right = NeoTrellisM4(left_part=trellis_left)
To use TrellisM4 tilled with Neotrellis (seesaw):
from board import SCL, SDA
import busio
from adafruit_neotrellis.neotrellism4 import NeoTrellisM4
from adafruit_neotrellis.neotrellis import NeoTrellis
from adafruit_neotrellis.multitrellis import MultiTrellis
I2C = busio.I2C(SCL, SDA)
trellim4_left = NeoTrellisM4()
trellim4_right = NeoTrellisM4(left_part=trellim4_left)
trelli = [
[trellim4_left, trellim4_right],
[NeoTrellis(I2C, False, addr=0x2F), NeoTrellis(I2C, False, addr=0x2E)]
]
trellis = MultiTrellis(trelli)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Soldering TrellisM4 with 2 Neotrellis¶
Here is how to do tilled one trellis m4 and 2 neotrellis (seesaw) into a square :
solder the 2 neotrellis together as described in the tutorial (including pad for I2C addresses as needed).
solder the tilled neotrellis to the trellis :
Here is a picture of the full tilled board:

Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2021 Arofarn
3#
4# SPDX-License-Identifier: MIT
5
6import time
7
8from board import SCL, SDA
9import busio
10from adafruit_neotrellis.neotrellis import NeoTrellis
11from adafruit_neotrellis.multitrellis import MultiTrellis
12from neotrellism4 import NeoTrellisM4
13
14# Create the i2c object for the trellis
15I2C = busio.I2C(SCL, SDA)
16
17# Create the trellis. This is for a 2x2 array of TrellisM4 (first row) with
18# 2 Neotrellis (second row).
19#
20# [ NeoM4_left | NeoM4_right ]
21# neotrellis0 | neotrellis1
22
23trellim4_left = NeoTrellisM4()
24trellim4_right = NeoTrellisM4(left_part=trellim4_left)
25trelli = [
26 [trellim4_left, trellim4_right],
27 [NeoTrellis(I2C, False, addr=0x2F), NeoTrellis(I2C, False, addr=0x2E)],
28]
29
30trellis = MultiTrellis(trelli)
31
32# some color definitions
33OFF = (0, 0, 0)
34RED = (127, 0, 0)
35YELLOW = (127, 75, 0)
36GREEN = (0, 127, 0)
37CYAN = (0, 127, 127)
38BLUE = (0, 0, 127)
39PURPLE = (90, 0, 127)
40
41# this will be called when button events are received
42def blink(xcoord, ycoord, edge):
43 """Turn the LED on when a rising edge is detected or
44 turn the LED off when a falling edge is detected
45 """
46 if edge == NeoTrellis.EDGE_RISING:
47 trellis.color(xcoord, ycoord, BLUE)
48 elif edge == NeoTrellis.EDGE_FALLING:
49 trellis.color(xcoord, ycoord, OFF)
50
51
52for y in range(8):
53 for x in range(8):
54 # activate rising edge events on all keys
55 print(x, y)
56 trellis.activate_key(x, y, NeoTrellis.EDGE_RISING)
57 # activate falling edge events on all keys
58 trellis.activate_key(x, y, NeoTrellis.EDGE_FALLING)
59 trellis.set_callback(x, y, blink)
60 trellis.color(x, y, PURPLE)
61 time.sleep(0.05)
62
63for y in range(8):
64 for x in range(8):
65 trellis.color(x, y, OFF)
66 time.sleep(0.05)
67
68while True:
69 # the trellis can only be read every 17 millisecons or so
70 trellis.sync()
71 time.sleep(0.02)
trellism4_extended
¶
CircuitPython library to extended Adafruit NeotrellisM4 board with two Neotrellis seesaw boards (or more !).
Author(s): arofarn
Implementation Notes¶
Hardware:
Adafruit NeoTrellis M4 Express: https://www.adafruit.com/product/3938
Adafruit NeoTrellis RGB Driver PCB for 4x4 Keypad :https://www.adafruit.com/product/3954
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit CircuitPython bus_devices library (from Adafruit_CircuitPython_Bundle): https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases
- class trellism4_extended.NeoTrellisM4(left_part=None)¶
Driver for the Adafruit NeoTrellis.
- Parameters
left_part – None (default) or left part object
Note
if None (or ommitted) the class create a neotrellis.multitrellis-compatible object for the left half of the TrellisM4 board. Else the right part is created and the arguement should be the left part object.
Example:
from neotrellism4 import NeoTrellisM4 trellis_left = NeoTrellisM4() trellis_right = NeoTrellisM4(left_part=trellis_left)
- activate_key(key, edge, enable=True)¶
Activate or deactivate a key on the trellis
:param int key : key number from 0 to 16. :param int edge : specifies what edge to register an event on and can be NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING. :param bool enable : should be set to True if the event is to be enabled, or False if the event is to be disabled.
- property count¶
Return the pressed keys count
- property interrupt_enabled¶
Only for compatibility with neotrellis module: Interrupts are disable on trellis M4 keypad
- set_event(key, edge, enable)¶
Control which kinds of events are set
- sync()¶
Read any events from the Trellis hardware and call associated callbacks.