The Nulsom rainbow matrix is compatible with the Pimoroni unicorn hat Raspberry Pi library but needs a few modifications. Tested on a Raspberry 2.
Connect the matrix 5V and GND to the Raspberry, connect the DI pin to P18.
Install the unicorn hat library with \curl -sS get.pimoroni.com/unicornhat | bash
.
Clone the repo from https://github.com/pimoroni/unicorn-hat, and modify as follow:
diff --git a/python/UnicornHat/unicornhat.py b/python/UnicornHat/unicornhat.py
index 3e6dde9..f088aeb 100644
--- a/python/UnicornHat/unicornhat.py
+++ b/python/UnicornHat/unicornhat.py
@@ -25,6 +25,7 @@ _rotation = 0
Store a map of pixel indexes for
translating x, y coordinates.
"""
+"""
map = [
[7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ],
[8 , 9 , 10, 11, 12, 13, 14, 15],
@@ -35,6 +36,18 @@ map = [
[55, 54, 53, 52, 51, 50, 49, 48],
[56, 57, 58, 59, 60, 61, 62, 63]
]
+"""
+map = [
+ [56, 48, 40, 32 , 24 , 16 , 8 , 0 ],
+ [57, 49, 41, 33, 25, 17, 9, 1],
+ [58, 50, 42, 34, 26, 18, 10, 2],
+ [59, 51, 43, 35, 27, 19, 11, 3],
+ [60, 52, 44, 36, 28, 20, 12, 4],
+ [61, 53, 45, 37, 29, 21, 13, 5],
+ [62, 54, 46, 38, 30, 22, 14, 6],
+ [63, 55, 47, 39, 31, 23, 15, 7]
+]
def _clean_shutdown():
In python/UnicornHat/
install the modified unicornhat library with:
sudo ./setup.py install
That's all.
Verify that everything is working launching the Pimoroni demo in Pimoroni/unicornhat
with:
sudo ./demo.py
The Unicorn Hat lib has been modified, so the above diff has changed a bit, now they've added multiple defaults for every Hat they sell, let's add a new matrix for the Nulsom Rainbow Matrix that will be the default: