These are chat archives for Makuna/NeoPixelBus

26th
Mar 2016
Michael Miller
@Makuna
Mar 26 2016 00:33
@sticilface that's a good question to put on the esp8266/arduino chat channel, there are some good small 4 channel modules that could be replicated for only one channel. I have never seen a single channel module.
sticilface
@sticilface
Mar 26 2016 00:38
cool will do...
marksev1
@marksev1
Mar 26 2016 10:42
@Makuna So i dont need to replace RgbColor with HsbColor in the animations part?
marksev1
@marksev1
Mar 26 2016 11:44
@Makuna http://pastebin.com/wzZWjGcY notice lines 120-130
3DSasha
@3DSasha
Mar 26 2016 13:57
@Makuna I disconnected WS2812B from ESP and did run example sketch with ESP and some different power adapters. Result is the same - on GPIO3 pin I see oscillations (DMA working) with usual not rgb led with resistor and after 10...75 seconds oscillations stops randomly on logic "1" or "0" and keep it until reset.
3DSasha
@3DSasha
Mar 26 2016 14:03
@Makuna Therefore I dont think that absence of logic shifter is causing stop working. May be some software conditions are stops DMA output? Or my board is broken. I have no other board to test this.
Aditya Tannu
@AdySan
Mar 26 2016 14:17
Someone asked about level shifters yesterday, anything better than this SparkFun Voltage-Level Translator Breakout - TXB0104
@Makuna found this here btw, someone driving NeoPixels via I2S DMA on nRF51 (my current muse :smile: )
Aditya Tannu
@AdySan
Mar 26 2016 14:29
so yes, Ali seems to have cheaper alternatives.
marksev1
@marksev1
Mar 26 2016 16:31
yeah i have that exact one, it seemed to work since my esp didnt get burned :)...
when i tried connecting a 16x2 lcd i2c display, but then all the sensors and the lcd were to much for esps power supply since it began to restart itself
then i removed the lcd and all was fine :D
need a beefier power supply for that setup
AdySan those nrf's use less current right
Aditya Tannu
@AdySan
Mar 26 2016 16:57
Yep BLE is all about low power consumption
They don't have such a nice Arduino core though, libraries are almost non exostent
I wish I could run this library on that
Michael Miller
@Makuna
Mar 26 2016 17:05
@marksev1 You shouldn't need to.
Michael Miller
@Makuna
Mar 26 2016 17:11

@3DSasha Ok, so we now know its the DMA as you see the output stop. Add this line to your setup()...

 pinMode(3, OUTPUT);

... and see if reproduces.

Michael Miller
@Makuna
Mar 26 2016 17:21

@marksev1 You still have the SetPixelColor calls there. Animations replace calling SetPixelColor and instead the animation itself calls them. But you need to know what you want your animation to do. A simple one for this is to "fade" between the current color and the new color over 3 seconds. You can see this some of the Examples, the following was taken from one and is an animation update function...

// simple blend function
void BlendAnimUpdate(const AnimationParam& param)
{
    // this gets called for each animation on every time step
    // progress will start at 0.0 and end at 1.0
    // we use the blend function on the RgbColor to mix
    // color based on the progress given to us in the animation
    RgbColor updatedColor = RgbColor::LinearBlend(
        animationState[param.index].StartingColor,
        animationState[param.index].EndingColor,
        param.progress);

    // apply the color to the strip
    for (uint16_t pixel = 0; pixel < PixelCount; pixel++)
    {
        strip.SetPixelColor(pixel, updatedColor);
    }
}

You can replace RgbColor with HsbColor and it will still work. You should notice that there animationState stored there. There is a simplier way to store it, but it only works on Esp, you can find this in the NeoPixelAnimation sample (yes, this might blow your mind, as it uses lambdas )

        // we must supply a function that will define the animation, in this example
        // we are using "lambda expression" to define the function inline, which gives
        // us an easy way to "capture" the originalColor and targetColor for the call back.
        //
        // this function will get called back when ever the animation needs to change
        // the state of the pixel, it will provide a animation progress value
        // from 0.0 (start of animation) to 1.0 (end of animation)
        //
        // we use this progress value to define how we want to animate in this case
        // we call RgbColor::LinearBlend which will return a color blended between
        // the values given, by the amount passed, hich is also a float value from 0.0-1.0.
        // then we set the color.
        //
        // There is no need for the MyAnimationState struct as the compiler takes care
        // of those details for us
        AnimUpdateCallback animUpdate = [=](const AnimationParam& param)
        {
            // progress will start at 0.0 and end at 1.0
            // we convert to the curve we want
            float progress = easing(param.progress);

            // use the curve value to apply to the animation
            RgbColor updatedColor = RgbColor::LinearBlend(originalColor, targetColor, progress);
            strip.SetPixelColor(pixel, updatedColor);
        };
3DSasha
@3DSasha
Mar 26 2016 17:49
@Makuna same results with pinMode(3, OUTPUT). If in example I make leds number lower - lights freezes faster, higher - more time lights. One more moment (i think its important)- I have real 50 leds. When I change leds number to lower than my 50 , in DMA mode (funloop example) all leds are working (from start to end strip) before dma stops, but in other modes correct number leds are working.
Michael Miller
@Makuna
Mar 26 2016 17:53
@3DSasha
Just to confirm, what Arduino IDE version do you have, what EspArduino board version do you have, and what version of NeoPixelBus.
3DSasha
@3DSasha
Mar 26 2016 17:54
@Makuna I think all are latest, but i checking right now...
Michael Miller
@Makuna
Mar 26 2016 17:54
@3DSasha In the fun loop example, how did you change the pixel count? What was passed to NeoPixelBus at construction? or the constant const uint16_t PixelCount = 16;
3DSasha
@3DSasha
Mar 26 2016 17:55
@Makuna const uint16_t PixelCount = 32; i change this
Michael Miller
@Makuna
Mar 26 2016 17:59
@3DSasha Which Esp do you have (link please). Also what do you select in the board menu for it.
So what you observed with the funloop sample is very strange. I suspect you don't have a logic analyzer do you 8-)
arduino ide 1.6.7, neopixelbus 2.0.4. In IDE settings - NODEMCU 1.0 (esp12e module, cpu freq 80(160 also tryed), 4M (3M spiffs), upload speed 256000)
3DSasha
@3DSasha
Mar 26 2016 18:08
My home logic analyzer is AV-tester :-)
Michael Miller
@Makuna
Mar 26 2016 18:11
What version of Arduino ESp board do you have? IDE 1.6.7 did have bugs but nothing that effects ESP; they quickly put out 1.6.8.
Your hardware is my primary config I test with. I have a similar board but not exactly the same.
By Arduino ESP board, I mean, the version listed in the board manager for the Esp8266 environment.
3DSasha
@3DSasha
Mar 26 2016 18:17
2.1.0-rc2
@Makuna Do you think full reinstall all of this componnents from zero helps me?
3DSasha
@3DSasha
Mar 26 2016 18:27
I didnt read about bugs after i start work with ESP. In Arduino IDE the main bug that now i have with esp is need to write functions in code in order (first - functions, then functions that use these first functions and so one and recursion is impossible.) May be that is answer to my trouble?
marksev1
@marksev1
Mar 26 2016 18:49
Makuna
I'm gonna read now your tips and try to fix that
@Makuna do I need to copy paste just parts of the BlendAnimUpdate function or the whole one?
I'm a bit lost being a noob :D
marksev1
@marksev1
Mar 26 2016 18:56
That Cyclone is a good one to start, what do I have to remove from the sketch to get that to work
jakeloggins
@jakeloggins
Mar 26 2016 19:03
Just donated to @Makuna from the paypal link. Would like to encourage everyone else to do so too.
Michael Miller
@Makuna
Mar 26 2016 19:06
@3DSasha RC2? 2.1.0 has been out for a while. You might need to uninstall the esp board and do a manual cleanout of the bits before installing the new board. What OS are you using? The manual cleanout is easy on Windows, and may translate to other platforms.
marksev1
@marksev1
Mar 26 2016 19:07
my noobness strikes again Makuna :)
Michael Miller
@Makuna
Mar 26 2016 19:09
@marksev1 Spend a little time examining the samples, looking for concepts and functionality that might fit your idea of your project. Do have a firm idea of what you are trying to accomplish?
marksev1
@marksev1
Mar 26 2016 19:10
well i have just a general idea to put a few animations there and then remotely trigger them
the problem is when I read an example its often not readable for me that much
thats why I didn't understand your tip up. I understand that i need to delete the strip.SetPixelColor there but
dunno with what to replace that
I posted all the things from Cyclone example I think wouldn't that work if I rework the sketch a bit?
else if(pub.payload_string() == "cyclone")
{
  animations.StartAnimation(0, 5, FadeAnimUpdate);
  animations.StartAnimation(1, 2000, MoveAnimUpdate);
}   
would this work?
marksev1
@marksev1
Mar 26 2016 19:15
this seems to call the FadeAnimUpdate and the MoveAnimUpdate functions
Michael Miller
@Makuna
Mar 26 2016 19:16
@marksev1 Let me give you an example, I will take your paste from the link from above, modify it so it "just fades" the colors in all the cases and give that back to you. It might help. The samples sometimes show too much complexity and I am working on how to provide introduction to animations, its tuff, its a complex subject.
Give me about 15 minutes.
marksev1
@marksev1
Mar 26 2016 19:17
Thanks!
Yeah that will probably help me understand. Because I'm an extra noob :D
Michael Miller
@Makuna
Mar 26 2016 20:06
I don't have the pubsub stuff on my machine so I could not compile, so there maybe very minor compile cleanup (missing ;, that sort of thing)
marksev1
@marksev1
Mar 26 2016 20:13
Lemme see how it should be done
:)
Michael Miller
@Makuna
Mar 26 2016 20:14
The paint program I use to get colors is http://www.getpaint.net/index.html, its free, and on the color picker select advanced and it will show a color wheel and the values in RGB and HSV
marksev1
@marksev1
Mar 26 2016 20:17
Thanks i'll look at that.Uh its quite reworked, does this mean everything will be an animation or no?
Michael Miller
@Makuna
Mar 26 2016 20:18
everything will be in an animation. You should generally do this anyhow, except for rare cases.
marksev1
@marksev1
Mar 26 2016 20:20
So for normal colors it just fades from black to the color choosen or something like that
Michael Miller
@Makuna
Mar 26 2016 20:21
fades from current color to the color you choose.
turn off just fades to black, but leaves the current color so color changes effect it but do not turn it on.
marksev1
@marksev1
Mar 26 2016 20:23
Thanks for also figuring out the colors for me
Michael Miller
@Makuna
Mar 26 2016 20:23
turn on fades from black to the current color, which may have been changed when it was off
about to sign off, I will intermittently check for next 20 min and then I am out for a few hours.
marksev1
@marksev1
Mar 26 2016 20:25
So cyclone is not here right
Michael Miller
@Makuna
Mar 26 2016 20:25
I removed it for now, it confuses the conversion. Understand what I did, then you can add it back if you want.
marksev1
@marksev1
Mar 26 2016 20:27
Yep, will do so
3DSasha
@3DSasha
Mar 26 2016 20:27
@Makuna I reinstalled all. Newest versions and ... nothing changes unfortunately. Now i set PixelCount higher values - and time to freeze rises too. With 300 virtual leds funrandom change example works 15 minutes already
marksev1
@marksev1
Mar 26 2016 20:27
Many thanks Makuna
3DSasha
@3DSasha
Mar 26 2016 20:37
Somewhere is dependency of stability time from pixelcount in my case... funrandom works yet. :-)
Michael Miller
@Makuna
Mar 26 2016 21:02
@3DSasha One more thing to try, put a 4.7kohm resistor between the pin you have the pixels on and ground. This is under the thought that maybe your board may have a strange setup on that pin and this may help ground it at idle.
3DSasha
@3DSasha
Mar 26 2016 21:23
@Makuna Resistor inserted. Nothing. btw, with 256 pixelcount fanrandom works more than 30 minutes till I reset it manually. 50 leds - freezes from a minute. I think this is temporari;y solution for me to take such big buffer without bugs. All i need is 100 led output with enough speed to show my own prerendered effects...
Other unused virtual leds is my cost for no bugs. I ll buy another esp to compare. May be that will be more lucky. On what frequency is 256 leds will be refreshed with DMA engine?
marksev1
@marksev1
Mar 26 2016 22:28
Makuna I learned how to get colors, not its gonna be easy for me to add additional preset colors
did you put the different time of turning on a specific color just for example that I can specify the time
marksev1
@marksev1
Mar 26 2016 22:34
so current color that it initializes with is red?
marksev1
@marksev1
Mar 26 2016 22:43
warm tungsten 40w rgb 255, 197, 143 - hsb 28.0f / 360.0f, 0.43f, 1.0f -> did i do correct conversion. I think I'll put this as current color :)
I think i understand the code its nicely readable :D
marksev1
@marksev1
Mar 26 2016 22:50
These Fade ins into the color will they go like around the color wheel? :) thats gonna look quite cool :)
Regarding animations https://www.youtube.com/watch?v=DMEVmuxoJJk these are cool animations, I'd like to add few of those each as a separate entity tied with mqtt. And later I will maybe also add IR remote support to the sketch so I could either operate it from mobile phone with mqtt or locally from IR remote. :) Thats long term goal :D....