Control your LED-Strip from your RaspberryPi using multiprocessing and an object-oriented animation creation.
Many thanks to Jks23456 who did major work on this repository.
You need to have python3.8 installed.
-
Clone our Project:
git clone https://github.com/Camaendir/JB-LED.git
-
Move into the folder
cd JB-LED
-
Install necessary packets (make sure you are using python 3.x):
sudo pip3.8 install -r requirements.txt
-
Now you can try out our TestScript, which prints the Animation to the Console:
python3 TestEngine.py
-
Connect your own LED-Strip:
Look at the TestEngine.py file and follow the instructions in the comments
-
Create a new File:
touch YOURANIMATION.py
-
Create a subclass of SubEngine...
class YOURCLASS(SubEngine):
-
... and implement the necessary methods:
def __init__(self, name, pixellength): super().__init__(name, pixellength) # the super constructor needs to be called pass def update(self): # one frame has passed. Move your animation to the next one. # Nothing has to be returned pass def terminating(self): # Your animation is about to be terminated. Do what you need to do # Nothing has to be returned pass
-
For your animation to actually do something you have to create an object...:
isVisible = True position = 0 content = [[255, 255, 255]] * pixellength obj = Object(isVisible, position, content) # The content can be of any length (smaller than your pixellength) # the content is a list of lists containing the pixels rgb values: [ [r,g,b], [r,g,b], ... ]
-
... and add it to your SubEngine:
self.addObj(obj)
-
To animate just change it's position and content...:
obj.position = 5 obj.content = [[255, 0, 0], [0, 255, 0], [0, 0, 255]]
-
... and/or add a few more:
isVisible = True position = 0 content = [[255, 0, 0]] * pixellength obj2 = Object(isVisible, position, content) self.addObj(obj2)
To explore what your SubEngine and Objects can do for you and what Controllers and Layers are visit our Wiki here on GitHub
Thanks for looking at our repository and happy coding