Cylinder pixel map

Hi all,

I’m trying to map a cylinder and I’m having a difficult time of it. I’m building a lamp that will have 18 rings with 17 LEDs on each ring. I seem to be having some difficulty designing it and was wondering if anyone could give me a hand?

Thanks,
Nick

1 Like

Sure! This map just builds off the pre-loaded “Ring” example.

I assumed each layered ring is wired sequentially, and that pixel index 0 is in the bottom layer.

function (pixelCount) {
  var map = [];
  var layers = 18;
  var pixPerRing = 17;
  for (layer = 0; layer < layers; layer++) {
    for (i = 0; i < pixPerRing; i++) {
      c = i / pixPerRing * Math.PI * 2
      map.push([Math.cos(c), Math.sin(c), layer])
    }
  }
  return map
}

oh, that’s amazing. Thanks!

One caveat, the above assumes it’s wired around the same direction each time, and not zigzag. That bit me too, working on a similar mapping.

See Manually adjusting spin in mapper?

But I need to shift 1 for the zags, to get it right. This week, next time I get time to play. (It’s also top down, as well as zigzag). Hopefully between the two, we can have a good example. I’ll recraft mine to have variables for up/down and zigzag/continuous.

1 Like

I have one issue and I guess I don’t understand the code enough to fix it. The first row only has 16 pixels on it, as I needed room for the wiring from the pixelblaze. Everything else is perfect. How would I adjust for this offset?

Ah, it’s always the exceptions…

So layer 0 has only 16 pixels not 17?

Add this:

If (layer==0 && i==0){
// Skip the first very spot, no pixel
} else {
map.push([Math.cos©, Math.sin©, layer])
}

Around that map.push line. It’ll skip only the one spot.

(Sorry, on mobile, will edit for code later)

3 Likes

thanks, I appreciate it :smiley: !

This is a different take on a cylinder, and I haven’t yet made this in pixelblaze, but I made a thing where I wrapped a pole in a single long line of LEDs (actually 7 attached strings). Since I wrapped it at a fixed number of pixels per loop (mostly) it lined up in an easily addressable way. It ends up as a long helix. The mapping is something like this:

function (pixelCount) {
var map = [];
numloops=41
for (i = 0; i < pixelCount; i++) {
c = i / pixelCount * Math.PI * 2*numloops
map.push([Math.cos©, Math.sin©,i/pixelCount])
}
return map
}

image

It probably is easier to do this than have a large number of small loops.

4 Likes

Yup, that’s another variation, more of a helix than a matrix (where a row is all at the same height).

I’ll be sure and add that into my “comprehensive ring/helix” mapper. Thanks!

That is a bit deceptive due to the large number of loops I used in that one, it is a true helix where there is a continuous gradient of height. Here is an example with less loops.

image

1 Like

Yes, but the difference between the two is just one thing: does a row maintain a consistent height (and then a drop/rise to the next row), or is it a gradient to the next level with each slightly higher or lower? Otherwise the math is the same.

thanks for posting that! the next one I do like this will most likely be a spiral and not a matrix… save myself the soldering :stuck_out_tongue:

True, but for me it is trivial to run a long single loop of leds (and occasionally inject voltage), and much more of a pain to wire up several small loops.

Oh completely understand. In my case, I inserted LEDs of a strand into a sheet of plastic (which was supposed to be used as core of a plastic lamp) so it was super easy to make a zigzag matrix of it, rather than any other method. Do whatever works, as doing the mapper afterward is pretty easy (and I’m trying to help make it easier)

I need to take a photo of that lamp, will post it as part of a pile of stuff I’m working on. My to-do list grows.

Is this visualization done with Pixel Teleporter?

The pixelblaze pixel mapper (in version 2.23)

I was going to try to do a correct conical mapping for fun, but then I did a search for it, and found that the wizard had already done one AND had a nearly identical cylindrical mapping. Is there a place where various mappings can be found?

1 Like

We’re in the midst of a reorganizing, and mapping is part of that. Searching the forum is your best bet for now. Hopefully by 2021, it’ll be easier to find a large selection of maps and flexible mapping code to solve most common setups.

2 Likes

warning: i’m new with no coding or mapping experience

I’ve just started on a new project (Pineapple) that involves a cylinder which has 16 vertical strips with 14 pixels per strip wired in an up/down pattern. I’d like to map this so I can attempt (key word) to apply patterns that can a) travel up and down the cylinder, and b) travel clockwise and counter clockwise around the cylinder both vertical and diagonal (off-set).

I tried modifying some of the code above but failed miserably. I’m also not comprehending how the mapping code interacts with the pattern code so that the pattern matches the map.

Any advice or examples would be greatly appreciated.

ok, so let’s break this down:

vertical strips, up and down… going around in a circle.

you could just call it a 2d map, and it’ll work fine… it’s a zig zag, left right left, if you turn the cylinder on it’s side. Right? Ah, no, it’s reversed, looking at the wires above, it’s up (right), left (down), and so on.

If you want it to be 3d, we can build a map for that, but I suspect the simple 2d map (16x14) will work for most of what you want… so long as it’s right/left/right… not left/right/left