Profile cover photo
Profile photo
Kit Parenteau
21 followers
21 followers
About
Posts

I've run into a wonky (but semi-explicable) behavior on RGBSets and I'm wondering if there's any way to avoid manual iteration.

Given a LED array 0-11, an array of pointers subset[0] and subset[1] to RGBSets are made of LED(5,0) and LED(6,11).

The 5,0 successfully makes it so that subset[0][0] is LED 5, while [0][1] is 4, [0][2] is 3, and so on.

When I try to access subset 0 via the iterator though, either as subset[0]->operator()(0,5) or (*subset[0])(0,5) it ends up addressing LEDs against the main array in positive sequential order instead of the order of the set. So, for example, (2,3) will address 7 and 8, rather than 3 and 2. Then things like fill_rainbow address the set, but in LED incremental order rather than set incremental order.

Is there any way I can correct pointers or references or such to get the built-in iterators to address it in the reverse order that it's stored in, or am I stuck losing the that benefit of RGBSets and having to make my own iterators anyway?

While the ability to create a table of LED pixel mappings exists, it gets messy, memory management becomes a pain, and group actions (fill_rainbow and such) become a mess. So I'm once again on a quest for a way to finagle non-contiguous RGBSets.

I'm going to be looking through the code of that system to try to figure out if there is a way to do it, but I'm not hopeful as I suspect it may be using a pointer to a position in the main array rather than an array of pointers to positions in the main array (which the latter I could potentially re-write the individual addresses pointed to, but in the former everything is pointer+n. T^T)

Obviously though I'd like to avoid replicating prior work or chasing a hopeless endeavor, so I'm looking for alternate solutions that don't make things a kludgy nightmare.

I need to be able to:
Dynamically form and delete sets/groupings that provide the ability to work with non-contiguous and occasionally-inconsistently-ordered (swaps between incrementing and decrementing) LEDs from the main RGBArray. Preferrably in such a way that I can use fill functions.

So, for example, I may at one point need to create a "strip" that is comprised of LEDs from the main strip (in order): 6 7 8 9 10 11 17 16 15 14 13 12 23 22 21 20 19 18 0 1 2 3 4 5; and then later change it to two that are comprised of 6 7 8 9 10 11 18 19 20 21 22 23 and 5 4 3 2 1 0 17 16 15 14 13 12 respectively. Changing based on control input.

Failing at that, I may need to figure out how to manually perform fill functions one LED at a time or start throwing in a lot of memory use and cycle use with a scrap array and addressed shuffling. T^T

I'm setting up to use an Arduino (Not sure what end type, right now it's running on a Mega 2560 but likely will try to end up on a micro or nano) to handle talking to some WS2812 objects. The objects have really bad physical layout of the LEDs though. I need to effectively treat them as diamond-shaped with three LEDs per side, and be able to logically "flatten" them either horizontally or vertically to convert them into two rows (or columns) of six LEDs each. Then I also have to handle multiples of these strung in sequence in arbitrary positions (The code needs to be able to be told at run time which corner is up and where the objects are relative to each other). Then to make it worse, the LEDs in them start at the middle of one of the sides. So there is a side that has 12, 1, 2, then the next side has 3, 4, 5, and so on through the four sides around,. The second object having 24, 13, 14, then 15, 16, 17 and so on. If that doesn't make sense, I apologize, it's a pain to comprehend as is.

The preferred annoying-but-I-think-I-can-make-it-work way would be to be able to set up arbitrary arrays for individual sides that reference segments of the main full array. Then applying things to a given side in forward or reverse order would be relatively easy. CRGBArray would work great for example except for the fact that one side is split between the first two and the last LED on each device. From that point, I should be able to map out the sides that need to interact with each other.

After 17 C++-less years, I can't for the life of me determine how to create such things. And I'm also open to better ideas. Lacking either, I'll end up with a complex mess of spaghetti functions and bad code that will incite vast sadness and failure.

So any help would be greatly appreciated.

Post has attachment
My feet hurt because Jade has acquired exceptional aim while jousting. Have to wear shoes at all times now.
https://www.youtube.com/watch?v=dYScCB2UtZM
Add a comment...

Post has attachment
Photo bomb bird.

Shot at Rocky Mountain National Park at rainbow curve. The Martin has always been elusive. The bird just wanted to help.
Photo
Add a comment...

Post has attachment
Yes, I fit. See?
Photo
Add a comment...

Post has attachment
Can you decipher the glyphs on the tree?

Damage caused by pine beetles killed this tree, but the trails left behind are interesting. While unlikely to hold arcane value or the lore of an alien civilization, it's easy to see why somebody could imagine that.
Photo
Photo
7/16/15
2 Photos - View album
Add a comment...

Post has attachment
A cool October night on the West side of Rockey Mountain National Park. This is a series of shots from around 10 PM with a good chunk of moon providing the light.
Photo
Add a comment...

Post has attachment
Representatives of the tallest trees in the world. A vertical panorama amongst the California redwoods
Photo
Add a comment...

Post has attachment
Levitating Bird?

Not exactly. This pre-flight capture shows that they leap up before spreading their wings.
Photo
Add a comment...
Wait while more posts are being loaded