This project creates a series of effects to be displayed using multiple different renderers:
- Browser-based simulator
- WS2812x directly connected to raspberry pi GPIO using node-rpi-ws2812x-native
- Fadecandy server
The rPi's native PWM driver does work, but I found the Fadecandy to be a wonderful product with great colour correction and dithering, and the advantage of allowing computers other than rPis to be used. The system you run it on simply needs to have the FC connected over USB.
This project is written in TypeScript and organised around a number of distinct concepts:
- Shapes
- Layers
- Scenes
- Compositor
- Renderers
- Player
Component list
- Raspberry Pi 4
- 8GB Micro SD card
- Fadecandy
- USB A - Mini USB cable
- Right-angled 8x2 ribbon cable socket
- Ribbon cable
- WS2812B LED strip (30 LEDs/metre)
- 5V power supply
- WS2812 pre-soldered connectors
Tool list:
For the bamboo project:
- Download Raspbian lite (current version was Buster)
- Use balena Etcher to flash it to an SD card
- Create the
wpa_supplicant.conf
andssh
files in the boot partition as instructed by the headless setup instructions to allow the pi to connect to wifi when it boots - Eject and remove the SD card from the laptop and plug it into the Pi.
- Connect a power supply and power-up the Pi. Wait 1 minute.
- Use IP Scanner to locate the Pi on the network
- From a bash terminal on the laptop, connect to the Pi (password 'raspberry'):
> ssh [email protected]
- Update the OS (this takes ages)
> sudo apt update
> sudo apt full-upgrade
- Install NodeJS and Git:
> curl -sSL https://deb.nodesource.com/setup_16.x | sudo bash -
> sudo apt install -y nodejs git
- Clone this project. Use HTTP github URL so there's no need to add SSH keys onto the pi.
> git clone https://github.com/triblondon/pixel-wall.git
> cd pixel-wall
> npm install
- Clone fadecandy
> cd ~
> git clone https://github.com/scanlime/fadecandy.git
- Create a fadecandy config file.
"listen": [null, 7890]
is required to enable fc to listen for remote connections, andmap
is used to limit the initial set of LEDs to 6.
> cd ~/pixel-wall
> nano fadecandy-config.json
{
"listen": [null, 7890],
"relay": null,
"verbose": true,
"color": {
"gamma": 2.5,
"whitepoint": [1.0, 1.0, 1.0]
},
"devices": [
{
"type": "fadecandy",
"serial": "______________________",
"map": [
[ 0, 0, 0, 6 ]
]
}
]
}
Run the server, and connect the Fadecandy board to the rpi using a USBA - Mini USB cable. The terminal acknowledges the connection:
> sudo ~/fadecandy/bin/fcserver-rpi ~/pixel-wall/fadecandy-config.json
[1581767783:9703] NOTICE: Server listening on *:7890
USB device Fadecandy (Serial# XXXXXXXXXXXXXXXX, Version 1.07) attached.
Try opening a browser to http://[IPADDRESS]:7890/ to check that the server is accessible.
Connect an LED strip to the Fadecandy, using the rpi for power for now:
- LED +ve -> GPIO 4 (5v)
- LED data -> Fadecandy pin 0
- LED -ve -> GPIO 6 (ground)
- Fadecandy ground -> GPIO 14 (ground)
I soldered a right angle 16-pin IDC ribbon cable connector to the fadecandy connected a ribbon cable and used a multimeter to find the right pin on the end of the ribbon.
Run the Flame simulation:
> cd ~/pixel-wall
> npm run dev
Hopefully the LEDs light up and flicker
I cut the first six LEDs off the strip in three sets of two. Each set was connected to the next with a snap-on 15cm connector wire. Lesson: a single hole in the base of the bamboo is much easier to work with than threading the strip in one hole and out another.
Create a systemd
profile for the fadecandy server (guide):
> sudo nano /etc/systemd/system/fadecandy.service
Paste:
Description=Fadecandy
Wants=network.target
After=syslog.target network-online.target
[Service]
Type=simple
ExecStart=/home/pi/fadecandy/bin/fcserver-rpi /home/pi/pixel-wall/config/fadecandy.json
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
> sudo nano /etc/systemd/system/led-player.service
Paste:
Description=LED player
Wants=network.target fadecandy.target
After=syslog.target network-online.target
[Service]
Type=simple
WorkingDirectory=/home/pi/pixel-wall
ExecStart=npm start
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Run:
> sudo systemctl daemon-reload
> sudo systemctl enable fadecandy
> sudo systemctl enable led-player
> sudo systemctl start fadecandy
> sudo systemctl start led-player
TODO: solder wires onto LED strips, heatshrink on the strips, glue gun the strips into the bamboo.
TODO: connect JST connector at the end of the first and last bamboo of the group. Make longer wires connecting between groups.
It requires a very particular USBC power cable and won't work with my common-or-garden MacBook power supply. Solved by ordering the official power supply.
I have this running on another rpi but no idea how I got it to compile as it now chokes on the npm install. Fixed by removing the rpi-ws281x-native dependency, which isn't needed anyway now that I'm using fadecandy.