These are chat archives for Makuna/NeoPixelBus

11th
Nov 2016
Michael Miller
@Makuna
Nov 11 2016 02:23
24 bit color is considered normal for many PC applications, so it should be fine. Look at gamma correction also as you may use some interpolating as you go from 8 to 10 bits.
protolyser
@protolyser
Nov 11 2016 04:46
how can I change the brightness of the LED strip dynamically? I want to be able to set the brightness (darker/brighter, without loosing the original color) in all my modes.
Michael Miller
@Makuna
Nov 11 2016 04:54
The hardware does not support it (NeoPixels, Dot Stars do). So to change it would require remembering the original and applying the change and setting it. The library doesn't do it as this would introduce a memory cost or a processing cost when you render.
If you think a processing cost (every show the color is modified before sending) is something you want, enter an issue, I was looking into including a "filter" that would allow you modify the color as it sends it, could brightness, could be tinting.
protolyser
@protolyser
Nov 11 2016 05:04
mhm processing cost is why I changed to your library. But setting the brightness is a important thing. How do you use it when you need it?
Michael Miller
@Makuna
Nov 11 2016 05:08
The plan is that you provide a filter class like you do a color feature class in the constructor. This filter class will have one method that is called with the original color and you return the modified color. A default filter class that does nothing will get compiled away.
'NeoPixelBus <NeoRgbFeature, Neo800KbpsMethod, MyBrightnessFilter> strip()'
protolyser
@protolyser
Nov 11 2016 05:12
thanks
Michael Miller
@Makuna
Nov 11 2016 05:13
Remember, if you want this add an issue 😃
protolyser
@protolyser
Nov 11 2016 14:42

whats the best way to handle a custom led strip matrix. I have a serpentine layout starting from bottom right with 2 LEDs for each matrix pixel.
13 14 | 15 16 | 17 18 ....
12 11 | 10 9 | 8 7 | 6 5 | 4 3 | 2 1

currently I'm defining numbers and shapes manually:

const byte number_zero[] = {156, 157, 158, 159, 160, 161, 152, 153, 110, 111, 108, 109, 66, 67, 64, 65, 144, 145, 118, 119, 100, 101, 74, 75, 56, 57, 24, 25, 26, 27, 28, 29, 0};

void loadDigit(const byte *pixelList) {
  for (byte j=0; pixelList[j]; ++j)
     strip.SetPixelColor(pixelList[j], COLOR);
}

and then call it with:

loadDigit(number_zero);

Now I want to do animations for example start with a Dot in the middle of the matrix and then light in a circle to the outside (like a stone in the water) How can I do that?

Michael Miller
@Makuna
Nov 11 2016 17:58
@protolyser do the two LEDs light the same value? Treating two pixels to act as one was not something I built into my support; so its something you will always have to do.
@protolyser If you look at the wiki Matrix Panels Support you can find how the library exposes support for matrix panels.
When you state they start from bottom right; the pixel index starts from bottom right. But the question is where does the X,Y start from?
Michael Miller
@Makuna
Nov 11 2016 18:07
There is an example that also demonstrates how to use the features.
If you need a truly custom layout that I missed, you can look at how the layout classes are written and create one of your own and pass it through. The layout classes JUST need to have the same Map methods exposed and they will work. See the RowMajorLayout as an example.
protolyser
@protolyser
Nov 11 2016 18:08
I just cut a led strip with 60/m neopixels and put them in serpentines starting vom bottom right and I use 2 leds per "box". Currently I don't have a X,Y? the question ist how I can "build" a matrix out of that setup.
Michael Miller
@Makuna
Nov 11 2016 18:09
By providing an X,Y coordinate system; you set the ground work for creating understandable animations for the 2D coordinate space.
protolyser
@protolyser
Nov 11 2016 18:10
ah ok so in your row major layout line 258 matches with my setup only that I have 11 (*2 Leds) in a row
Michael Miller
@Makuna
Nov 11 2016 18:11
The center is Width/2, Height/2; then look at a circle drawing routines on the internet; then in the animation just slowly increase the radius of the circle.
You can define the width and height of the layouts; but having one "location" light two LEDs is the problem.
protolyser
@protolyser
Nov 11 2016 18:16
how hard is it to make it work with the two led thing..? the two led thing was to save soldering time. Now the question is what takes less time. Changing the hardware setup or modifying the software.
Michael Miller
@Makuna
Nov 11 2016 18:19
@protolyser BTW, what Arduino board are you using?
It will always require memory for the extra LED pixel, as its about the protocol and sending it fast.
If you wanted to "just skip" the extra pixel, you could create your layout class that skips every other pixel when it maps.
BUT, if you wanted to light the extra pixel likes its twin; that's an issue today.
protolyser
@protolyser
Nov 11 2016 18:25
i'm using esp12-e
Michael Miller
@Makuna
Nov 11 2016 18:25
This could be solved by the "filter" support though; your filter would ignore the incoming color completely for Odd pixels; look up the color to the pixel before it and use it instead. You would still need the custom layout I mention above. Does that make sense?
protolyser
@protolyser
Nov 11 2016 18:25
skipping the extra pixel would be an option
Michael Miller
@Makuna
Nov 11 2016 18:29
Another alternative: Use one of the bitmap classes to draw into; then scale render it into the final strip (which would stretch across the extra pixels. But this requires extra memory (the bitmap) and extra processing (as you are stretching and copy into the final strip).
Oh well, just checked, the NeoBuffer and stretch support is still in development; so you would have to implement it today.
protolyser
@protolyser
Nov 11 2016 18:32
I think I'll go with the "just skip" thing for now. how can I do that?
Michael Miller
@Makuna
Nov 11 2016 18:36

Look at the examples for using layouts; look at the implementation of a layout, use them to represent Virtual Pixels (half the width since you will double); then consider this as an example

class RowMajorLayout : public RowMajorTilePreference
{
public:
    static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
    {
        return x + y * width;
    }
};

Modify the calculation to skip; so if the doubling is on X, then return (x * 2) + y * width;

protolyser
@protolyser
Nov 11 2016 18:54
Thanks a lot. I don't exactly understand how the alternating layout class works. What does the "& 0x0001" mean?
class RowMajorAlternating180Layout : public RowMajorAlternatingTilePreference
{
public:
    static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
    {
        uint16_t my = ((height - 1) - y);
        uint16_t index = my * width;
        if (my & 0x0001)
        {
            index += x;
        }
        else
        {
            index += ((width - 1) - x);
        }
        return index;
    }
};
Michael Miller
@Makuna
Nov 11 2016 18:56
its a check for odd numbers ;-) C doesn't have an intrinsic function to check for odd numbers.
protolyser
@protolyser
Nov 11 2016 19:40
don't really get how to skip with the alternating layout..