These are chat archives for Makuna/NeoPixelBus

28th
Mar 2016
Michael Miller
@Makuna
Mar 28 2016 01:20

Just a heads up: A new version will be made available soon to improve HslColor and HsbColor blending. Due to their inherent circular nature of the Hue component, it is important to control how the direction of the blending.

    template <typename T_NEOHUEBLEND> static HslColor LinearBlend(const HslColor& left,
        const HslColor& right,
        float progress)

Four method classes are being exposed...

NeoHueBlendShortestDistance
NeoHueBlendLongestDistance
NeoHueBlendClockwiseDirection
NeoHueBlendCounterClockwiseDirection

And these get used with the HslColor::LinearBlend and HsbColor::LinearBlend like....

HslResult result = HslColor::LinearBlend<NeoHueBlendShortestDistance>(left, right, progress);
marksev1
@marksev1
Mar 28 2016 10:06
Makuna so how do i implement some of those effects that are shown in those yt clips i posted like - strobe effect, alternating color half strip, knightrider effect, randomly turning on single pixels around the strip, Etc.
Also that one is good when the leds turn on from one side one at a time and then from another side
Also that one where the pixels randomly turn on until whole strip is lit. But lets go one at a time. If i find code for some or them is it portable? Which older lib do they need to have?
3DSasha
@3DSasha
Mar 28 2016 13:21
@marksev1 I think that Makuna's animation engine is better for procedural effects (using math functions). Some of your described effects are more like raster effects. I think you need write function using array of predefined values like [pixnumber_001, color, starttime, duration]...[pixnumber_N, color, starttime, duration] and fill the ledstrip by this functions. By the way, I work for almost the same aim. My idea: I use SD card to save effects created by me in compositing program like After Effects. I did some layouts and configurations there for my ledstrip (like Makuna matrix and layouts in the lib) and make wished animations myself there too. On the final I save BMP-file by own javascript, where every RGB raw is my ledstrip frame. So I have a number of BMP files on SD-card, and play them on ESP in order (random, slow FX, fast FX, scenarios). Some effects are short-timed and short-sized and can be used in sync play with music (like Johnson family at Christmas). Of course, my idea is not original (LedStudio, Vixen, Madrix and etc), but I have more functionality to create FX and music-lights (I am professional 2D-3D artist)
marksev1
@marksev1
Mar 28 2016 17:46
That sounds too complicated to me (use of the sd card and so on)
Michael Miller
@Makuna
Mar 28 2016 18:37
The raster support is coming, the feature class is a NeoTexture. It will provide the blitting of the image from the texture to the pixels, but you still need to manage things like, what rectangle from the texture (even if its only one pixel high) is draw to what rectangle on the pixels (again, even if its one pixel high).
marksev1
@marksev1
Mar 28 2016 18:37
Makuna hey
Is this raster support neccessary for the types of animations that i outlined?
Will you add some class for doing that kind of animations like in those yt clips i posted
Michael Miller
@Makuna
Mar 28 2016 18:40
@marksev1 a lot of samples demonstrate similar effects, raster is a slow way to do animations, but as 3DSasha stated, often its easier using external tools that only kick out raster data.
marksev1
@marksev1
Mar 28 2016 18:41
So which examples should i be porting next (with hopefully your help for problems)?
Michael Miller
@Makuna
Mar 28 2016 18:41
@marksev1 Its unlikely I will do that. Most are small changes to animations that are already in my samples or could be done building from the examples.
marksev1
@marksev1
Mar 28 2016 18:41
Cool
Michael Miller
@Makuna
Mar 28 2016 18:42
Unlikely I will build them, I can always answer questions.
marksev1
@marksev1
Mar 28 2016 18:42
So which ones do you suggest so i could build on then? :)
This neopixelanimation example gives random color to each new pixel right
The best would be for me to implement all the animations from examplea
A
S
Michael Miller
@Makuna
Mar 28 2016 18:49
Several of them provide random colors in animate to the colors. A few I have videos of them running (https://github.com/Makuna/NeoPixelBus/wiki/Examples)
See here 5 functions for animations. Is this portable?
Michael Miller
@Makuna
Mar 28 2016 18:59
All of them are in a way. They use delay() in them which is bad to use in my animation system. You will need to convert these routines and again, some are very similar to ones I already have in my examples, so comparing them would be a good learning experience.
marksev1
@marksev1
Mar 28 2016 19:01
The compactness was what attracted me
sticilface
@sticilface
Mar 28 2016 19:06
"might" be worth checking out my animations in https://github.com/sticilface/Melvanimate
specifically the files in the src/effect folder. i've written handler classes that manage groups of pixels, shapes, and movement of the shapes. so you can have groups of pixels all doing different things, moving in different directions... it might all be a bit impenetrable though... they all just run in a loop with Run() being called, and before that Start() and after Stop() is called. initvars() is called before anything and sets up variables for use. I've converted rainbowchase which might be a good place to start..... just thought i'd throw it in the mix
Michael Miller
@Makuna
Mar 28 2016 19:06
The could almost be run as is with only minor changes to the calls around colors and setting pixels; the problem will be if you try to use WiFi at the same time, the use of delay() is problematic long term.
marksev1
@marksev1
Mar 28 2016 19:07
Could i use those in combination with neopixelbus?
sticilface
@sticilface
Mar 28 2016 19:19
is that directed at me @marksev1?
marksev1
@marksev1
Mar 28 2016 19:20
Well either of you
sticilface
@sticilface
Mar 28 2016 19:20
all the stuff i've written uses neopixelbus.
marksev1
@marksev1
Mar 28 2016 19:20
Cool
sticilface
@sticilface
Mar 28 2016 19:21
as far as i know its the only 'lib' around.. that is reliable for esp8266.
marksev1
@marksev1
Mar 28 2016 19:22
So i would just include melvanimate.h and then continue?
Michael Miller
@Makuna
Mar 28 2016 19:22
My comment was directed at marksev1
marksev1
@marksev1
Mar 28 2016 19:23
What about that Makunas consideration will you maybe optimize it further
Oh
So sticilfaces animations is already totally good to go?
sticilface
@sticilface
Mar 28 2016 19:25
@marksev1 kind of... you have to include the dependancies in the main ino. so arduinojson, wifi stuff, neopixelbus... to get it to work fully you have to send the index.htm and colorpicker.js stuff to SPIFFS... and MQTT is not quite fully working... mostly... and i want a way to exclude it... but essentially
marksev1
@marksev1
Mar 28 2016 19:27
Dunno
Too much stuff around and i have mqtt in my sketch
sticilface
@sticilface
Mar 28 2016 19:28
the javascript frontend is a bit of a disaster but it works... i need to get it optimised... but I'm new to that. you can exclude the the ESPmanager stuff and just write the wifi, and OTA into the sketch if you need it
i've got a whole load more animations and blends to write... just quite busy at the moment.
the 'nice' thing about this is that each animation is only loaded into ram once it is ready to go... so even with my wifimanager heap sits at 23kb free... animator is created dynamically. and it stores and retrieves presets... so you can save your favourite configuration of an animation and retrieve it later...
marksev1
@marksev1
Mar 28 2016 19:35
I kinda think yours is already like a selfsufficient project while for mine i would require just some chunks :) thanks anyway
Id need to show you my sketch
perhaps once you get mqtt working i could replace this one that i have currently with your. What is the scope when using mqtt of your sticilface?
sticilface
@sticilface
Mar 28 2016 19:47
mqtt is working. i've just not been able to test it, and the front end does work quite right yet to configure it. but if you set the right details in the configfile on spiffs it just works...
basically i think you can control the sketch... and change any of the variable for the currently running sketch, and load presets...
not tried saving presets yet
i have to test it, more
Michael Miller
@Makuna
Mar 28 2016 19:50
@3DSasha Do you have an example of raster data you use? How do you store it, code, files, other? I am looking at what sort of support for "initializing" the NeoTexture I need to provide.
marksev1
@marksev1
Mar 28 2016 19:54
@Makuna in the NeoPixelFunLoop.ino how would i tie one of my else if(pub.payload_string() == "funloop") ... would I need to call there LoopAnimUpdate and FadeOutAnimUpdate? Or something else? I copy pasted stuff in the same locations around the sketch like in the example
and should i rename the rgbcolors to hsbcolors
and starting color to animstarting color like i have now in the example
I mean like i have now in the sketch that you rewrittene
Michael Miller
@Makuna
Mar 28 2016 20:00
Looking at NeoPixelFunLoop, in the setup, it starts the animation, this is no different than the other examples that were present. The issue is this animation will never end unless you stop it. So when ever you want to do something else, you either reuse the same animation index that you started it on or you will have to call StopAnimation with that same index.
marksev1
@marksev1
Mar 28 2016 20:02
where would i call stopanimation?
animations.StartAnimation(0, NextPixelMoveDuration, LoopAnimUpdate); with this i start it
but how do i tie it to mqtt message
you know that sketch that you reworked
Should I leave this project am I too much pain in the ass :D ? :D
Michael Miller
@Makuna
Mar 28 2016 20:08
You are missing some fundamentals is all. Do you know what a state machine is?
"state machine"
marksev1
@marksev1
Mar 28 2016 20:09
probably no
:D
3DSasha
@3DSasha
Mar 28 2016 20:10
@Makuna Now I have only some files with random colors to test my sketch. Files are saved in BMP format from Aftereffects with my javascript, but it is possible to use any graphic editor to create and save BMP file to use them as effects. As I said, my ledstrip contains 100 pixels, therefore BMP files have 100 pix width and Y pix height (Y=number of frames, FPS can be tuned in the sketch with speed setting, max 30 fps is enough like video FPS). BMP has 24 bit depth (full RGB color), flipped order format to easiest way to read from SD without seeking. For me 100 pixels is full frame. If BMP width is less than pixel count, then there are settings to scale frame to full length of strip or texturize it.
Michael Miller
@Makuna
Mar 28 2016 20:10
ok, go look that up and understand how to use it. Its not really hard and you probably already do similar things without knowing that's what it is called.
You will need one to track what "state" the end point is in.
marksev1
@marksev1
Mar 28 2016 20:10
I think i now figure something, I will look at it but first i will post a codde snippet and you tell me if its right
Michael Miller
@Makuna
Mar 28 2016 20:12
@3DSasha Do you code the reading the bmp or are you currently relying on the in memory object to read it?
3DSasha
@3DSasha
Mar 28 2016 20:13
I wrote BMP parser to read BMP file from SD
marksev1
@marksev1
Mar 28 2016 20:14
}
else if(pub.payload_string() == "funloop")
{
  // capture colors for animation
  AnimStartingColor = currentColor;
  AnimEndingColor = SkyBlueColor;
  // change our stored color
  frontColor = AnimEndingColor;
  if (isOn) {
    // only apply if we are on, but we still remember
    animations.StartAnimation(0, NextPixelMoveDuration, LoopAnimUpdate);
  }
}
3DSasha
@3DSasha
Mar 28 2016 20:15
It reads line and sends them to pixel buffer (earlier it was FastLed lib) now I trying new esp platform and your lib, @Makuna
Michael Miller
@Makuna
Mar 28 2016 20:16
@3DSasha When you say you send them to the pixel buffer, you are calling SetPixelColor or getting the pointer to the buffer and writing directly? Or are you caching it in memory in another buffer that you latter call into NeoPixelStrip?
@marksev1 That seems fine.
sticilface
@sticilface
Mar 28 2016 20:18
This is something i'm very interested in.... as well... not tried it yet... what program would you use to generate the BMP with the animations?
Michael Miller
@Makuna
Mar 28 2016 20:18
@marksev1 P.S. The variable 'isOn' is an example of a state machine.
3DSasha
@3DSasha
Mar 28 2016 20:19
@Makuna on esp I am at start of coding anew. On arduino my code reads stream of 300 bytes from bmp directly to fastled buffer to save time
Michael Miller
@Makuna
Mar 28 2016 20:21
@3DSasha With the esp, you would have enough memory to cache it in ram. Do you use SPIFFs for the SD support or do you actually have an SD module attached?
3DSasha
@3DSasha
Mar 28 2016 20:21
@sticilface AfterEffect VERY powerful for videoeffects creating.
@Makuna I have SD card module and use SD lib for esp to read
marksev1
@marksev1
Mar 28 2016 20:24
Makuna that on isOn i understand that
its a boolean so its true or false
and if isOn is true then this starts right
Michael Miller
@Makuna
Mar 28 2016 20:25
now think if its an enum, IsOff, IsOnDisplayingAnim1, IsOnDisplayingAnim2, IsOnDisplayingColor, etc
sticilface
@sticilface
Mar 28 2016 20:25
cool cheers
3DSasha
@3DSasha
Mar 28 2016 20:27
@Makuna Therefore i start to migrate from arduino on a middle way to more powerfull esp. My other idea is use cross-dissolve transitions between effects from BMP effects, and some RAM buffer is needed to do this. Like your Linear Blend procedure but between two raster effects
Michael Miller
@Makuna
Mar 28 2016 20:27
@3DSasha Ok, first version will use memory cache then, I will look at expanding it to allow you to provide a "block reader" and also a "program memory" for those who want to embed the bmp into a PROGMEM variable.
marksev1
@marksev1
Mar 28 2016 20:30
if its an enum then it can have more "states" right
Michael Miller
@Makuna
Mar 28 2016 20:30
@3DSasha Exactly! The NeoTexture will expose a Draw(sourceX, sourceY, destX, destY) for opaque render (fast), and another for "blend render" (0.0 to 1.0 to blend)
@marksev1 yes
@3DSasha if the NeoTexture is RGBA, it will also blend itself into the destination. But all this requires an extra NeoTextures for backgrounds, layers, etc.
marksev1
@marksev1
Mar 28 2016 20:32
so...if I would invoke that funloop animation, you said that it runs indefinately
so even if i do: else if(pub.payload_string() == "sunyellow")
{
// capture colors for animation
AnimStartingColor = currentColor;
AnimEndingColor = SunYellowColor;
// change our stored color
currentColor = AnimEndingColor;
if (isOn) {
// only apply if we are on, but we still remember
animations.StartAnimation(0, 3000, AnimBlendUpdate); // three seconds to turn on
}
}
will it still run that animation
it will just fade into different color or ?
Michael Miller
@Makuna
Mar 28 2016 20:33
yes, since they are the same animation index number, it stops the animations and replaces it
marksev1
@marksev1
Mar 28 2016 20:33
is that index 0
Michael Miller
@Makuna
Mar 28 2016 20:33
yes
marksev1
@marksev1
Mar 28 2016 20:33
good
thats cool :)
Michael Miller
@Makuna
Mar 28 2016 20:34
When you run more than one animation, you need to watch for collisions, collisions in working on the same pixels. It wont crash, but you may not get the effect you want.
@3DSasha I want to avoid writing a complex game render engine, I have done that enough times already in my life.
marksev1
@marksev1
Mar 28 2016 20:37
Makuna how does this look then - http://pastebin.com/ACri0Nx5
3DSasha
@3DSasha
Mar 28 2016 20:39
@Makuna if you'll write that for neopixels, marksev1 will have no questions to you :-)
marksev1
@marksev1
Mar 28 2016 20:42
but then you'll have to answer all my questions 3DSasa
Sasha*
:D
Michael Miller
@Makuna
Mar 28 2016 20:48
@marksev1 Does that even compile?
(going offline for while)
marksev1
@marksev1
Mar 28 2016 20:51
dunno I'm not compiling yet :D
do you see some blatant errors :D
Michael Miller
@Makuna
Mar 28 2016 20:54
To respect others time, you should always compile before show code; unless its obvious a snippet or pseudo code
marksev1
@marksev1
Mar 28 2016 20:59
ok
will do so in the future
thanks for the tip
which version of the ide would be best suited for use with this library?
marksev1
@marksev1
Mar 28 2016 21:11
i get lots of errors yeah :D
man i get lots of pubsubclient errors too @AdySan goona need your help here
marksev1
@marksev1
Mar 28 2016 21:20
does it clash if i have both neopixel lib and neopixelbus lib?
Aditya Tannu
@AdySan
Mar 28 2016 21:58
Why do you need both?
i'm using this fork btw https://github.com/Imroy/pubsubclient
marksev1
@marksev1
Mar 28 2016 22:01
dont need both i guess
oh
so that fork
i'll try with that
marksev1
@marksev1
Mar 28 2016 22:23
Thanks