Last active
January 23, 2019 02:46
-
-
Save tillig/b3dff3f37c93db73e2e721cd82c5650e to your computer and use it in GitHub Desktop.
Pi Lights install/update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common \ | |
scons \ | |
gcc \ | |
make \ | |
git \ | |
libjpeg-dev \ | |
libpng-dev \ | |
python-dev \ | |
swig \ | |
-y | |
if [ ! -d "rpi-ws2812-server" ]; then | |
git clone https://github.com/tom-2015/rpi-ws2812-server.git | |
fi | |
if [ ! -d "rpi_ws281x" ]; then | |
git clone https://github.com/jgarff/rpi_ws281x.git | |
fi | |
cd rpi-ws2812-server | |
git pull --rebase origin master | |
make | |
chmod +x ws2812svr | |
mv ws2812svr /usr/bin | |
cd ~ | |
cd rpi_ws281x | |
git pull --rebase origin master | |
sed -i 's/^#define STRIP_TYPE .*/#define STRIP_TYPE WS2811_STRIP_GRB/g' main.c | |
sed -i 's/^#define WIDTH .*/#define WIDTH 600/g' main.c | |
sed -i 's/^#define HEIGHT .*/#define HEIGHT 1/g' main.c | |
sed -i 's/^LED_COUNT.*=.*/LED_COUNT = 600/g' python/examples/strandtest.py | |
scons | |
cd python | |
sudo rm -rf build | |
python ./setup.py build | |
sudo python ./setup.py install | |
cd ~ | |
echo "Setting ws2812svr to start at boot time." | |
cat > /etc/init.d/ws2812svr <<xyzzy | |
#! /bin/sh | |
# /etc/init.d/ws2812svr | |
### BEGIN INIT INFO | |
# Provides: ws2812svr | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: | |
# Short-Description: Starts the ws2812svr LED controller. | |
# Description: Runs the ws2812svr listener on port 9999 to handle LED control. | |
### END INIT INFO | |
case "$1" in | |
start) | |
echo "Starting ws2812svr" | |
/usr/bin/ws2812svr -tcp 9999 & | |
;; | |
stop) | |
echo "Stopping ws2812svr" | |
killall ws2812svr | |
;; | |
*) | |
echo "Usage: /etc/init.d/ws2812svr {start|stop}" | |
exit 1 | |
;; | |
esac | |
exit 0 | |
xyzzy | |
update-rc.d ws2812svr defaults | |
echo "Basic test:" | |
echo "sudo python rpi_ws281x/python/examples/strandtest.py -c" | |
echo "To test through ws2812svr:" | |
echo "sudo killall ws2812svr" | |
echo "sudo /usr/bin/ws2812svr -i \"setup 1,600,3;init;fill 1,ff0000;render;\"" | |
echo "sudo /usr/bin/ws2812svr -i \"setup 1,600,3;init;fill 1,000000;render;\"" | |
echo "To stop ws2812 from starting at boot:" | |
echo "sudo update-rc.d -f ws2812svr remove" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment