MOST simple WS2812-library

I have installed two WS2812 libraries and tested the demo-codes.
They work. But they are high complex using animations or "fireworks"-effects.
impressive to look at but hard to understand.

Can anybody recommend the most simple WS2812-library where anything must be coded "by hand" in a way like
adress pixel number "x" assign RED-PWM 50%, green-PWM 20%, blue-PWM 10%

best regards Stefan

FastLED.h

and

Adafruit_NeoPixel.h

can both be used at that kind of minimum level.

They both have other stuff which may take up memory.

They are both open source, so.

You might like APA type smart LEDs that work on a data and clock basis, you can do without any library whatsoever and you will indeed be on your hands and knees free of anyone else's ideas about how to make things "easy".

HTH

a7

2 Likes

Hi alto777,

thank you very much for pointing me to FastLED and Adafruit_NeoPixel.

I want to add a more precise description what I'm looking for:

The examples delivered with most libraries suffer from what I call
The experts blindness for beginners difficulties.

The comments are reduced to a minimum. Even inside the Ada_Fruit-example-codes.

I want to give an example: I tried the NeoPixelCylon-example. Inside this example there are some lines of code

void SetupAnimations() {
    // fade all pixels providing a tail that is longer the faster
    // the pixel moves.
    animations.StartAnimation(0, 5, FadeAnimUpdate);

    // take several seconds to move eye fron one side to the other
    animations.StartAnimation(1, 2000, MoveAnimUpdate);
}

This forces me to do some experiments on what the "5" and the "2000" really means. After having done the experiments by varying the values

I changed the code to use more variables/constants with self-explaining names and extended comments of what is doing what:

void SetupAnimations() {
  // fade all pixels providing a tail that is longer the faster the pixel moves.
  animations.StartAnimation(0, lengthOfTail, FadeAnimUpdate);

  // the number inside "TimeToFinish" is the time (in milliseconds) it takes to move eye from one side to the other
  animations.StartAnimation(1, TimeToFinish, MoveAnimUpdate);
}

Of course I can't force anybody to write more than they do because all this is opensource for free. My opinion is
if everybody is invited to put yourself into the position of somebody who does know nothing yet about your code and ask yourself is it easy to understand?

I guess a pretty high percentage of the coders would add some more comments or re-think about the code and re-write parts of it to make it easier to understand.

best regards Stefan

Good idea. I answered the question you asked. I wondered if you were being deliberately obtuse and gave you the benefit of the doubt.

Write your own demos is the answer to your actual question.

Use only the three necessary low level calls, all three available in some form in both libraries.

  • initialize the strip

  • set an LED to a color

  • move the current strip values to the physical strip

Perhaps a fourth can be convenient even if theoretically unnecessary:

  • get the color of an LED

I wrote functions that do those by calling through to whatever library I happen to need or want to use. It makes switching libraries or strip type simpler at the expense of going without any advanced features the libraries may provide.

I understand my answer was of no value to you, but it might be to someone else.

Same with this answer.

FWIW most demos and a fair percentage of smart pixel code is bad, not so much in that it doesn’t work but because it is not written with learning or using as a point of departure as even a secondary goal.

So do yes write some that you think will be better!

a7