From a box-fresh install of Raspberry Pi OS Lite via NOOBS 3.5 (on a Pi 4, which is probably important because this involves Docker):
Login on the Pi's console and
sudo raspi-config nonint do_ssh 0
You should now be able to get on to the Pi with
ssh pi@raspberrypi.local
(Optionally) change the hostname:
sudo raspi-config nonint do_hostname queube
sudo reboot
You need git
:
sudo apt-get install -y git
Then clone this repo:
git clone https://github.com/pikesley/queube
And install everything:
cd queube
make setup
The Cube:Bit is basically a cube made out of 27 ws2812 NeoPixels (I think), which can be driven with the usual Python libs. It presents itself as a 1-dimensional array of pixels, but this list wraps itself around physical space like some sort of Peano Curve (which makes more sense when you look at how the layers are connected together).
The core of all this is the Cube. Its #display
method takes data like this:
[
[
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [255, 0, 0]],
],
[
[[0, 0, 0], [0, 255, 0], [0, 0, 0]],
[[0, 0, 0], [0, 255, 0], [0, 0, 0]],
[[0, 0, 0], [0, 255, 0], [0, 0, 0]],
],
[
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[255, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
],
]
which is 3, 3x3 layers of RGB colours, maps it onto the actual layout of the Cube, and turns on the lights.
You can run it locally (with FakePixels for testing):
make build
make run
Then inside the container:
make
to run the tests
There's also a Redis LIFO queue , with a worker which picks JSON like this:
{
"data": ["3x3x3 RGB colours like the above"]
}
off of the queube
queue and passes the .data
to the Cube
There's some Ruby in a Docker image called frillsberry which I wrote more than two years ago (when I was still writing Ruby every day for work) and I'm still trying to piece together exactly how it works, but basically it conjures up a 3-dimensional grid bigger than the Cube, with the Cube at the centre of it, picks a random starting point somewhere outside the Cube, creates a sphere of random radius centred on that point, colours it a random colour (with the intensity fading towards the outside), then fires it towards and through the centre of the Cube, lighting the pixels as it goes, creating a pretty light show.
Well, actually it does all this in the abstract, generating a series of 3x3x3 grids of RGB colours, which it turns into JSON and pushes onto the queue.
The existence of this Ruby client is the main reason (other than over-engineering for the sake of it) that there's a queue in here and I'm not just hitting up the Python directly, tbh.
You can run this locally with:
cd generators/frillsberry
make build
make run
Then inside the container:
rake
to run the specs. There's a few things that can be usefully tuned in here, which I should really abstract out into some YAML or something.