Requires RGB Tree from https://thepihut.com/products/3d-rgb-xmas-tree-for-raspberry-pi
Original code from https://github.com/ThePiHut/rgbxmastree#rgbxmastree
tree.py
modified to allow colour updates etc without actually sending update to the tree. This allows multiple changes all to be done at the same time.
Spiral and Rotate code taken from https://github.com/rendzina/XmasTree
Provides a simple web interface to the tree.
This allows selection from a number of LED Modes. Including "Sparkles","Hue","Layers","Spiral","Rotate" and "Fixed Colour". As well as an "Auto" option to reselect a random mode after a defined interval.
For convenience the web page also allows shutting down the Raspberry Pi and restarting of the code to simplify development.
The following hardware is used:
If you're using Raspbian Desktop, you don't need to install anything else. If you're using Raspbian Lite, you'll need to install gpiozero with:
sudo apt install python3-gpiozero
Might require the following if sdnotify is not present
pip install sdnotify
Copy all files to /home/pi/tree
Install service so tree starts when the pi does
sudo systemctl enable /home/pi/tree/tree.service
sudo systemctl start tree
Assuming pitree is the name of the pi
Note There is no security on the web server on port 8080
- Image copyright ThePiHut
This is used by the web interface for changes and status updates
http://pitree:8080/api?action=<comand>&value=<value>
- status - Returns tree status in json format
- modeno - Sets tree to a specific display type. Value is one of "Off", "Auto", "Sparkles", "Hue", "Layers", "Spiral", "Rotate", "Fixed Colour" or "On" which uses the default mode
- brightness - Sets tree brightness. Value is 1 to 31 (Note Web interface only show 1-16 as Ive found even 1 is quite bright)
- percentage - Sets brightness as a percentage, Value is 0 to 100
- shutdown - Shutdown the Pi
- setdefaults - Sets the current setup as that for startup
- restart - restarts the tree code
- colour - Sets the tree colour. Value is R,B,G each in the range 0 to 255
- Set Tree to Auto
http://pitree.home:8080/api?action=mode&value=Auto
- Get tree status
Returns something like the following
http://pitree.home:8080/api?action=status&value=x
{"ModeText": "Auto", "ModeNo": 1, "Current": "Layers", "Brightness": 1, "displaytime": 120, "timeleft": 18}
- Set tree colour to red
http://pitree.home:8080/api?action=color&value=255,0,0
/usr/local/bin/python3 /home/pi/tree/thetree.py
- 2.2 Fixed bugs
- 2.3 Added settings for Auto mode to cotrol which layout can be chosen