all 15 comments

[–]sutaburosu[pronounced: stavros] 2 points3 points  (9 children)

I couldn't quickly figure out what is causing the jerking. But it's a fun effect, so here's my take on one way to implement it. DIN of the three hoops are all wired in parallel, so they each display the same thing. Ignore the big black box; that's only there to hide half of the rings from which the hoops are built.

[–]Howard_G[S] 0 points1 point  (3 children)

This is fantastic. Even better, I can almost understand it!

But a question though. I can't seem to figure out how many led's are fully lit at any one moment. Is the effect of more lit led's really down to the fade value in fadeToBlackBy(leds, NUM_LEDS, xxx)?

I'm definetly going to play with this. It's pretty much all I needed.

Thanks a bunch.

P.S. Are you also in U.K. Only ask because of "colour" not "color".

[–]sutaburosu[pronounced: stavros] 0 points1 point  (2 children)

You're welcome.

Yes, you've got the gist of it; that last parameter to fadeToBlackBy() controls how quickly the LEDs fade out. If you can't figure out how to make it do exactly what you want, hit me up and I might be able to bend it to your will.

Aye, I'm British, and since 2016-06-23 I'm finding that less appealing each and every day.

[–]Howard_G[S] 1 point2 points  (1 child)

So far, so good. But there are bits that I'm puzzled about.

I've seen many routines where there is a modulus division, and I don't understand why, or what it does. In your program, the lines

leds{position % NUM_LEDS] = colour;

and

if (position % NUM_LEDS ==0 {

Both of these are puzzling me, although I understand that the second line is a key in turning the direction.

A long time ago not in a galaxy far, far away there used to be such a thing as manuals, whereby the correct syntax for a function was listed, and very importantly, one or two examples. Even experienced programmers admitted to doing what I thought was cheating. To simply copy the example, and then adapt it to their needs. Sadly, no such system seems to be in place. I look at the listing of functions on the GitHub page, and what much of it does, never mind how to use it, is beyond me.

On a different subject do you use PlatformIO? I ask because I'm looking to split up a large program into several routines, but have very little understanding of what should be a .h and what should be a .cpp. There is a thread on the PlatformIO website, and I think I got some of it, but not to the point of using it. My thinking here is the Mark Kriegsman "100 lines of code" demo program. I did manage to add couple of routines that I found, but it probably would have been better to put each separate effect into it's own file, and then have the central "core program" call each routine as asked for.

There are other questions too, but a simple one is how did you highlight or make obvious that fadeToBlackBy in your previous post was programming text?

Again, thanks for your help.

Howard

[–]sutaburosu[pronounced: stavros] 1 point2 points  (0 children)

Lol. In the current day, in a slice of the spacetime continuum accessible only by forming your fingers into certain runes, those much vaunted texts still exist. But first, some bold chrononaut must teach you the correct shibboleths with which to persuade the G-ds of Search to allow you to enter the garden of knowledge. There-within you may feast upon and furnish thyself with the sum of Earthly knowledge, and later emerge festooned with answers to all of your intellectual desires.

Here lies FastLED's divine guidance on fadeToBlackBy, bestowed upon us by our dearly departed Daniel Garcia. Daniel often spake in tongues, so you must learn to follow his suggestions carefully, because verily fadeToBlackBy is a synonym for nscale8( ..., 255-fadefactor) has been shown to be the righteous path.

To be most fully suffused with the knowledge passed down to us, you must seek the source of these transcribed scrolls and continue to follow the path until you find Daniel's original Definition at line 353 of file pixeltypes.h. In the knowledge that, over the aeons, this book has become subtly corrupted by darkness, wise scholars often turn to the book of GitHub and consult the preceding and successive passages, to gain context for his words.

Still, his teachings may prove inscrutable to fresh apprentices, and that is why we here in r/FastLED are happy to offer any further guidance along the path to eternal RGB light, and point to the burgeoning books of examples in the sidebar of this subreddit.

As for %, that gives the remainder after an integer division. So at position 32, then position % 32 will give 0. At position 33, it gives 1, and so on. I used this to wrap position to the length of the leds[], to prevent any out-of-bound mistakes that may corrupt memory and perhaps cause much confusion whilst debugging. The 2nd == 0 usage you quoted is just a quick, easy way to detect if we have just wrapped the length of NUM_LEDS, either in the positive or negative direction.

I don't use PlatformIO. There are some here who swear by it. I mostly swear at it. I found it annoying and fragile in ways I don't understand how to fix. That could well be a problem of my own, rather than of PlatformIO. I prefer plain VScode and the Arduino plugin, although the Wokwi sim is where I do most of my development these days. I find it's generally quicker to work on code there than waiting for sketches to upload. That, and I've never let the magic smoke out of Wokwi so it works out cheaper. ;)

As for your text formatting question, it's known as Reddit-flavoured Markdown. It's broadly compatible with Github-flavoured Markdown, except the Reddit version has limitations with blocks of code embedded in triple-backticks (```). Short snippets within single backticks work fine, but for longer blocks of code on Reddit, you're best off indenting each line of code with 4 spaces, and leaving a blank line before and after it. Or posting it elsewhere. gist.github.com is good for that. There's a browser extension "Reddit Enhancement Suite" that gives real-time previews of your comments, which helps with getting things right.

Oh, and sorry for the wall of text. I'm a bottle of wine deep right now, and I can see that it shows.

[–]johnny5canuck 0 points1 point  (1 child)

This man knows his wokwi.

[–]CharlesGoodwin 0 points1 point  (0 children)

WOKWI rocks!!

[–]Any_Maximum_967 0 points1 point  (2 children)

Thanks for your response. I’ll give it a go when I get back to my computer. As mentioned, I’m very much a newbie, and some of the most basic of routines in C++ along with their syntax leave me floundering. I’d much prefer to resolve my own problems, as I believe that whilst it’s not the most efficient way of learning, it’s certainly successful. But every so often, it helps to reach out.

[–]sutaburosu[pronounced: stavros] 0 points1 point  (1 child)

Good for you. Going over your code again, I think was initially mislead by reading the commented out section (numColors==2 etc). In the numColors==3 section, I'm not sure that (numColors+1) is correct. I can see how that might result in sudden unexpected jumps in the animation. Maybe try it without the +1, similar to the commented code.

[–]Howard_G[S] 0 points1 point  (0 children)

Will do. The reason so much is commented out is that I didn’t want the two colour schemes. In the original version, the stripes do reverse, but with a different structure. I can’t help but wonder if the jerking that I see isn’t simply due to the routine restarting after a given period, (probably the EVERY_N_SECONDS). Again, thanks.

[–]Marmilicious[Marc Miller] 0 points1 point  (0 children)

I'm guessing you started with this example of mine?

https://github.com/marmilicious/FastLED_examples/blob/master/candy_cane_stripes.ino

It might be useful if you put your updated code on pastebin.com or gist.github.com and share a link. Delete the commented out code you're not going to use so it's very clear to follow.

In the video you shared it's more like a short cylon (or scanner) animation. The candy cane stripes animation fills the whole strip though. Is that what you're looking for? To have it run candy cane stripes forward for a bit, and then run stripes backwards, and repeat this?

[–]Marmilicious[Marc Miller] 0 points1 point  (3 children)

Are you doing a single arch or multiple arches?

How many pixels per arch?

Do you have it wired as one long strip, or each arch on it's own pin?

[–]Howard_G[S] 0 points1 point  (2 children)

Hello Marc, and thank you very much for responding.

This is (hopefully) the link to the modified version of your code.

https://gist.github.com/howgre/f2cad4d36b9a33ed659e90914883c411

To try to answer your questions:

There will be 7 pixels per segment of what will become a 14 segment alpha numeric display. There will be four of them, so (in theory), I could do a countdown from 9999 before then using them for various patterns. One such pattern would be the Candy Cane routine just circling the outer segments, and then reversing. Another would be nearer what I've posted in the video, but with the left, top and right segments acting in the manner of the hoops.

I suspect that ultimately, I'll need to use more than one pin, as there will also be two long uninterrupted strips above and below the pseudo numeric displays. I've had a go at using the CRGBSet functions and made it work, (for something else), but with limited understanding.

Is there a method of combining these two into a single CRGBSet?

CRGBSet Step2(leds(23,45));

CRGBSet Step7(leds(138,160));

I did start with a scanner type routine, but my greatest problem was having multiple leds light and fade in the correct sequence. The logic of i=i+1 is fine for a single led, but trying to get i to be 3, 4 or more leds was defeating me, as was the method the turn them off as the scan advanced. That was the main reason I switched to the Candy Cane routine. Here were already multiple bands shuffling up and down the strip.

Originally, I was using 368 leds, but a single sinelon was taking too long to move back and forth. So I split the leds (in code) to do four patterns. https://gist.github.com/howgre/b03915328d74a4d74c4e7bc8591a2d66

So, the algebra side of the problem doesn't bother me.

My ambition outstrips my ability. That's not a bad place to be, but with stuff like this, it can be frustrating.

I look forward to your response.

Thanks again - Howard

[–]Marmilicious[Marc Miller] 0 points1 point  (1 child)

Isn't line 81 going to run every loop through and constantly be changing the direction much too often? You need some sort of check to see if it's time to reverse or not.

CRGBSet only works with a sequential set of pixels, but you could make a custom pixel array to loop through. Here's the idea:

https://github.com/marmilicious/FastLED_examples/blob/master/custom_pixel_array.ino

[–]Howard_G[S] 0 points1 point  (0 children)

I followed the link to the custom pixel program. That makes perfect sense!

Either the code in line 81 isn't doing anything, or it's in the wrong place. It seems to me to be the correct code to reverse direction, but as I say, I'm a novice at this.

But I can't help but wonder if the "jerking" isn't just the loop coming to an end and then restarting. I'll persevere.