Sean Meighan
Software => General Software => Topic started by: robs113 on July 18, 2016, 07:37:01 AM
-
Greetings.
I am wanting to add a couple my Arduino/FastLeds effects to my xLights.
I setup the development environment as per the docs.
It appears adding an effect is quite different in xLights 4 than is was in the tutorial and docs.
Is there an xLights 4 equivalent document to the "How_To_Add_effects_To_Nutcracker.pdf" ?
or...
Is xLights 3 source available so I can try adding my effect to that?
Thanks.
-
It should be a ton easier now with xLights 2016 than with 3.x/4.x. If you look in the xLights/effects directory, you can see that each effect now has it's own c++ class that implements a few methods. Thus, you pretty much need to implement that class (actually, its two classes, one for the effect and one for the Panel in the UI, but the latter is mostly generated via CodeBlocks), add the class to the list in EffectManager.cpp, and that's about it. The only two "existing" files you need to modify are the EffectManager.h and EffectManager.cpp.
Anyway, I'd look at one of the simple effects in there to use as an example.
-
Can you show a video of the effect(s) you have in mind or describe them? We just want to make sure its really something completely different from what's there because in some cases you can just add an option to an existing effect to produce the same thing.
-
Good point.
I will make a video of the effect on a setup I have in my basement.
-
Not sure how relevant it is now with all of the changes the last 6 months, but Sean did create a video on adding effects to xLights.
https://vimeo.com/138371241 (https://vimeo.com/138371241)
-
kevinp, yes that is the video that got me thinking of bringing my effect over to xLights ;)
gilrock,
Here are some videos of what I want to do.
In general a static light display with some animation to change colors.
That is, static red/green, animation to change to static blue/green. Hold static for 20-30 seconds, then another animation, etc.
Slide Fill
https://youtu.be/OKjiV37pzww (https://youtu.be/OKjiV37pzww)
Slide Clear
https://youtu.be/3KevXlPVYJU (https://youtu.be/3KevXlPVYJU)
Centre Fill (like slide file but starts at string centre and fill to ends.
https://youtu.be/C1s7ENHKFeU (https://youtu.be/C1s7ENHKFeU)
Chase Fill (Shown here at 4x speed)
https://youtu.be/1kVqhSNyiTo (https://youtu.be/1kVqhSNyiTo)
If I can do something similar with the existing xLights that would be great.
-
I think some of those could be accomplished by just adding a few more options to the existing Fill effect. Like if we allowed the user to specify that the colors alternate through the palette and define band size and gaps kinda like Marquee it would work like you want if you specify a value curve to define the motion.
-
Slide fill and Center fill can be done with the Single Strand effect and turning on the "Persistent" checkbox on the "Layer Settings" panel.
The slide clear (and center clear) can be done with two layers. Stick an On effect on the bottom layer and then on the top layer, put the "persistent Single Strand effect from above, but with "black" as the only color.
Chase fill is interesting.
-
Thanks guys.
I will do some experimenting with single strand.
-
I have had no luck figuring how to make an existing effect do what I require, so I am on to attempting my own.
Question:
In the RenderBuffer, what are:
curPeriod
curEffStartPer
curEffEndPer
I am assuming the myEffect code needs to set all pixels each time it is called.
I would like to be able to know how many times the code is called so I can write a different pattern of pixels each call.
Simplified example, say model has 100 pixels.
First call just turn on pixel 1.
Second call turn on pixel 1 and 3.
Third call turn on 1,3,5.
etc..
curPeriod seems to increment each time the effect is called, up to curEffEndPer.
Hence the above question.
-
Curperiod - cureffstartperiod gives you your 0 based frame number. Yes you have to render each and every frame in full.
-
However I think you are on the wrong track. I looked at your videos and every one of them is achievable with existing effects. Share your rgb effects file and I can generate you a sequence that does it.
-
Except maybe the last and that should be a change to garlands.
-
Those are the frame counts for the currently rendering effect. However, it's rare that you should use them. If you have a 25ms sequence compared to a 50ms sequence, the effect will run faster or slower if you depend on them. Instead, use the buffer.GetEffectTimeIntervalPosition() (or the version that takes the number of cycles if your effect does cycles) to determine the % you are into the effect. Base the calculations on what to draw based on that value.
-
Even if we can't create them with existing effects most of those examples we do not want to create completely brand new effects. What I was suggesting is I could add a couple more slider options to the existing Fill effect to do at least 2 of those. For brand new effects they should really be new concepts. I've already made that mistake myself. I created the Fan effect which turned out I could have just modified and added options to Pinwheel to do the same thing. I just think if we end up with 150 effect icons on the toolbar its going to be confusing.
-
I think the question is are you really just wanting to learn to write effect code for xLights or do you just want to be able to create those effects. If you just want those effects I think we can get that done by using or modifying existing effects. If you want to learn to write effects maybe we find a different one for you to do like I've been wanting a Fractals effect. Maybe have a drop-down that can select between various fractal algorithms.
-
Gilrock, I am just looking be add effects I require to my copy of xLights.
I am a programmer but total noob in xLights, so it seems easier to write the code than figure out the intricacies of existing effects. (that will come with time I hope ;-)
dkulp, I am always getting 0 for buffer.GetEffectTimeIntervalPosition() but buffer.curPeriod/buffer.curEffEndPer seems to be giving me what I need.
-
I'm not near the code but I believe buffer.GetEffectTimeIntervalPosition() returns a float from 0.0 to 1.0 so we use it like a percentage with 0.5 meaning 50%.
-
I will say it again. Post your rgb effects file with your models and we can show you how to get your effects with no coding. Much easier than writing new effects.
-
I appreciate the offer keith but those are done with an Arduino micro-controller and the FastLeds library so there is no effect file I can post.
-
Not your arduino file. You xlights model file.
-
Ahhh.. and that would be which file? (As I said total noob)
-
dkulp, I am always getting 0 for buffer.GetEffectTimeIntervalPosition() but buffer.curPeriod/buffer.curEffEndPer seems to be giving me what I need.
That would only be true when the effect that is being rendered starts at the very beginning (frame 0) of your sequence. :-) Once you move that effect to other parts of the sequence, that won't work as well.
-
Xlights_rgbeffects.xml
-
I've already got a couple nice additions to the Fill effect that will do at least 2 of these. I'm sitting here having fun figuring out all the new cool stuff we will be able to do with it. I just need to add an offset and wrap option now because originally there was no way to start that effect in the middle and have it wrap back around to itself.
-
I just checked in the new options for the Fill effect. How's that for service?
In this GIF I'm linking you can see an example of your slide fill being done. I created two Window models so each model has a Fill effect on it. So it's done with 2 effects.
http://gph.is/29SBXlM (http://gph.is/29SBXlM)
-
Here's a 5 minute video showing how to use the new Fill effect options:
https://youtu.be/VvLcaN4XXX8 (https://youtu.be/VvLcaN4XXX8)
-
Wow, that's amazing :)
Thanks Gil.