These are chat archives for Makuna/NeoPixelBus

9th
Jun 2015
Michael Miller
@Makuna
Jun 09 2015 00:45
@bbx10 In issue https://github.com/Makuna/NeoPixelBus/issues/11#issuecomment-109486923 you copied some code, I finally got around to trying and I don't see a problem. Is there more you missed? I sent several packets to it while it was cycling, everything was good.
All: I found that the 3.3v power I was providing my esp8266 was under powered when wifi is active. We I switched out to higher power (800ma+) I have had no problems with resets. Please confirm your power ratings and let me know if this happened to solve the green pixel.
Michael Miller
@Makuna
Jun 09 2015 00:52
ALL: I added a small change to the code to "help" with the "Green First Pixel". Please let me know if this fixes it or not. Still trying to get a repo on my side, but I am not running level shifters for IO yet (still waiting on the delivery).
sticilface
@sticilface
Jun 09 2015 15:40

@Makuna Since i got rid of all my initialised variables, and put the include for neopixelbus first, I've not had any (only when accessing a web page) green flickering. ie. it is totally acceptable. However, if i move the include, it goes totally to shit and i get a constantly flickering green pixel. Your latest changes do not help that.

I can confirm that using a level shifter allows you to dim the pixels right down to almost nothing. I build a prototype that did not level shift, and it is fine for high output, but when you start to dim to quite low, say under 25%, the strip would go totally spastic. The whole strip would flash white, bits would light up. I'm using an 74HCT245N and that totally fixes it, i can dim until it is barely even visible with no flashing. so IMHO worth having.

I'm trying to make a library for the HSV colors, that includes your Rgbcolor lib and it compatible with it. I've made progress but I'm stuck on how to include functions in the cpp file that are only for the lib itself. i've scanned a few .h .cpp but not found an example. there are a few functions such as 3waymin+max and a map function that works for double that i need. i guess i can just put them in manually but it might be good to know how to do it. here is what i have

HsvColor HsvColor::RgbToHsv(RgbColor colour) {

    byte r = colour.R;
    byte g = colour.G;
    byte b = colour.B;

    double rd = (double) r/255;
    double gd = (double) g/255;
    double bd = (double) b/255;
    double max = threeway_max(rd, gd, bd), min = threeway_min(rd, gd, bd);
    double h, s, v = max;

    double d = max - min;
    s = max == 0 ? 0 : d / max;

    if (max == min) { 
        h = 0; // achromatic
    } else {
        if (max == rd) {
            h = (gd - bd) / d + (gd < bd ? 6 : 0);
        } else if (max == gd) {
            h = (bd - rd) / d + 2;
        } else if (max == bd) {
            h = (rd - gd) / d + 4;
        }
        h /= 6;
    }

    return HsvColor(h,s,v);  

}

// helper modules... these have to go in private declarations... NOT WORKING...  mmmm

double threeway_max(double a, double b, double c) {
    return max(a, max(b, c));
}

double threeway_min(double a, double b, double c) {
    return min(a, min(b, c));
}


double map_double(double x, double in_min, double in_max, double out_min, double out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Michael Miller
@Makuna
Jun 09 2015 16:37
@sticilface That method should just be a copy constructor instead.
HsvColor::HsvColor(RgbColor colour)
{
Michael Miller
@Makuna
Jun 09 2015 16:43
If you only have one CPP, then just place the functions within it and include static at the front of function. for those "threeway", they really should be inlines, put them in a header, include "inline" in the front. If you want them only used in the library, then put them in a private header, "utility_private.h" as an example and include this in your header or cpp.
Note, I am thinking of revamping the NeoPixelBus and RgbColor a little. I am considering pulling out the animations into its own class, so that it can animation RgbColor, CygColor, HsvColor without requiring custom animation methods.
sticilface
@sticilface
Jun 09 2015 16:59
Thanks, this stuff it a bit beyond me to be honest, i've not heard of inline before so i might just keep them as function in my sketch for now. especially if your thinking of revamping them. The conversion rgbtohsv i posted earlier seem to work really well, if you want to use it. i get very nice dimming and transformations effects with them. let me know if you want me to test anything?
sticilface
@sticilface
Jun 09 2015 17:14
I was also wondering if it would be worth including a power function, or limit. most of the time if ur animating pixels you don't need a power supply that can handle 60mA * LEDs... but using your linear fader which will often go through white my power supply would freak out.
Michael Miller
@Makuna
Jun 09 2015 18:36
it should go through grey, so 255, 0, 0 to 0,0, 255, at the midway would be 128, 0, 128 so it would be at half brightness. The power would be no different at the mid point than the either of the edges.
sticilface
@sticilface
Jun 09 2015 20:30
Thats a good point. i'll see what i can do