Fadecandy Server Setup

At this point you should have gone through the network configuration steps from the prior page, and should have working internet access before continuing. There’s a little more software to be fetched…

Recent Raspbian versions have the git tool preinstalled, but for posterity let’s confirm:

sudo apt-get -y install git

Then retrieve the Fadecandy software from Github:

git clone git://github.com/scanlime/fadecandy

The package includes a pre-built executable for Raspberry Pi, but it’s built on an older version of Raspbian and won’t work on the current system. Not to worry, a new one can be compiled in just a few steps:

cd fadecandy/server
make submodules
make

This takes about 10 minutes to complete, depending on your internet connection. Once it’s finished, type:

sudo mv fcserver /usr/local/bin

To make the fcserver program start automatically when the system boots:

sudo nano /etc/rc.local

Just above the final “exit 0” line, copy and paste the following:

/usr/local/bin/fcserver /usr/local/bin/fcserver.json >/var/log/fcserver.log 2>&1 &

Then create a new configuration file:

sudo nano /usr/local/bin/fcserver.json

Copy and paste the following block into the new file:

{
	"listen": [null, 7890],
	"verbose": true,

	"color": {
		"gamma": 2.5,
		"whitepoint": [0.7, 0.7, 0.7]
	},

	"devices": [
		{
			"type": "fadecandy",
			"serial": "TVUCPRXHXJQJOFKR",
			"map": [
				[ 0,    0,   0, 60 ],
				[ 0,   60,  64, 60 ],
				[ 0,  120, 128, 60 ],
				[ 0,  180, 192, 60 ],
				[ 0,  240, 256, 60 ],
				[ 0,  300, 320, 60 ],
				[ 0,  360, 384, 60 ],
				[ 0,  420, 448, 60 ]
			]
		},
		{
			"type": "fadecandy",
			"serial": "DBDJIGEEZLWFYVYJ",
			"map": [
				[ 0,  480,   0, 60 ],
				[ 0,  540,  64, 60 ],
				[ 0,  600, 128, 60 ],
				[ 0,  660, 192, 60 ],
				[ 0,  720, 256, 60 ],
				[ 0,  780, 320, 60 ],
				[ 0,  840, 384, 60 ],
				[ 0,  900, 448, 60 ]
			]
		},
		{
			"type": "fadecandy",
			"serial": "SIUEOKCKPNKVOLSN",
			"map": [
				[ 0,  960,   0, 60 ],
				[ 0, 1020,  64, 60 ],
				[ 0, 1080, 128, 60 ],
				[ 0, 1140, 192, 60 ],
				[ 0, 1200, 256, 60 ],
				[ 0, 1260, 320, 60 ],
				[ 0, 1320, 384, 60 ],
				[ 0, 1380, 448, 60 ]
			]
		}
	]
}

The “serial” strings refer to the unique serial numbers of each Fadecandy board: left, center and right. The default serial numbers above are meaningless…you’ll need to change them to the serial numbers of your own boards.

There are a couple of ways to get your serial number(s). If you haven’t yet rebooted the system since installing the fcserver program above, run it manually:

fcserver

Then connect each of your Fadecandy boards to a USB port. You’ll see messages such as this one:

USB device Fadecandy (Serial# TVUCPRXHXJQJOFKR, Version 1.07) attached.
There’s your serial number, which you can copy to the serial: line in the fcserver.json file (make sure it’s between quotes). Repeat for each board. Press Control+C to stop the fcserver program.

If you’ve rebooted since installing fcserver, it’s already running in the background now, and you’ll instead find the connection messages in the log file:

tail -f /var/log/fcserver.log

Once configured, you can hunt down and restart the fcserver process, but I find it much easier just to reboot:

sudo reboot

If fcserver doesn’t seem to be starting up, check the log as shown above. It’ll warn of configuration file errors (the format is very exacting…missing or misplaced characters are not uncommon).

Other Configuration Highlights


Notice this line near the top of the fcserver.json file:
		"whitepoint": [0.7, 0.7, 0.7]
This sets the overall color balance (red, green and blue, range 0.0 to 1.0) and maximum brightness of the LED matrix. Brightness has intentionally been dialed back to 70% (0.7), as explained on the “Power” page.

At their brightest, each NeoPixel can draw up to 60 milliamps of current. With 1,440 of them, that’s up to 86.4 Amps, exceeding the limits of our 60A power supply. 60 ÷ 86.4 = 0.746, but we’ll round down to 0.7 for a slight safety margin. If using a different power supply or a different number of NeoPixels, adjust these numbers to suit.

Then there’s these “map” sections in the file:
			"map": [
				[ 0,    0,   0, 60 ],
				[ 0,   60,  64, 60 ],
				[ 0,  120, 128, 60 ],
				[ 0,  180, 192, 60 ],
				[ 0,  240, 256, 60 ],
				[ 0,  300, 320, 60 ],
				[ 0,  360, 384, 60 ],
				[ 0,  420, 448, 60 ]
			]
Each Fadecandy board controls exactly 512 NeoPixels: 8 lines of 64 pixels each. This is unvarying and by design.

Our 2-meter curtain strands each contain 60 NeoPixels. We could just produce data for 64 pixels and let the surplus be ignored off the end of the strip. But as a persnickety thing I didn’t like having to account for the extra nonexistent pixels in code. These map sections let us address the LEDs contiguously in software, despite the gaps in the physical layout. Each line contains four values:

  1. A channel number. This will always be 0 in our application.
  2. A starting pixel number as we’d like to address them. For example, the first pixel of the second strand will be 60 (normally it would be 64). First pixel of the third strand will be 120. And so forth through 1380, the first pixel of the last strand.
  3. The corresponding pixel number as handled by this Fadecandy board. Remember, it regards every strand as 64 pixels, always, even if physically shorter. So we’ve mapped the second strand to position 64, third to 128, etc. Unlike the prior value, these numbers apply to the current board only, not globally, so they’ll always be from 0 to 511, never larger.
  4. The number of pixels being remapped. 60 in this case, the length of our strips.

If you’ve created a different strip layout, you’ll need to adjust these tables accordingly. Or if using a Fadecandy board in its ideal configuration — 8 strips of 64 pixels — you can leave the map section out altogether.
Last updated on 2015-05-04 at 04.27.56 PM Published on 2014-08-11 at 02.00.57 PM