/JB-LED

A python library to easily and quickly create efficient Animations for your LED-Strip(s) powered by your RasPi. Multiprocessing, Shared-Memory and Object-Oriented Animation Creation, all for your LED-Experience.

Primary LanguagePythonMIT LicenseMIT

LED Animations

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.

Getting started

You need to have python3.8 installed.

  1. Clone our Project:

    git clone https://github.com/Camaendir/JB-LED.git
  2. Move into the folder

    cd JB-LED
  3. Install necessary packets (make sure you are using python 3.x):

    sudo pip3.8 install -r requirements.txt
  4. Now you can try out our TestScript, which prints the Animation to the Console:

    python3 TestEngine.py
  5. Connect your own LED-Strip:

    Look at the TestEngine.py file and follow the instructions in the comments

Creating your own Animations

  1. Create a new File:

    touch YOURANIMATION.py
  2. Create a subclass of SubEngine...

    class YOURCLASS(SubEngine):
  3. ... 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
  4. 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], ... ]   
  5. ... and add it to your SubEngine:

    self.addObj(obj)
  6. To animate just change it's position and content...:

    obj.position = 5
    obj.content = [[255, 0, 0], [0, 255, 0], [0, 0, 255]] 
  7. ... and/or add a few more:

    isVisible = True
    position = 0
    content = [[255, 0, 0]] * pixellength
    obj2 = Object(isVisible, position, content)
    self.addObj(obj2)

Getting better

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