Hi Jon,
I am trying to run Doom Fire (v2.0) 2D pattern in order to simulate virtual fireplace.
It runs very well on the default 16x16 matrix (except for the very top row of LEDs (index 0 to 15) is always inactive, not a big deal but a bit strange). However I cannot run this pattern correctly on the 16x32 matrix comprised from 2 serially connected 8x32 and staggered vertically. Pattern actually runs but somewhat oriented vertically like matrix is 32x16 (rotated 90 degree). Also changing width and height parameters seems to have no any effect:
// display size - enter the dimensions of your display here
var width = 32;
var height = 16;
I guess, matrix mapping is correct because test pattern “Red_Green_XY_2D_Sweep” runs correctly.
Just in case here is current mapping:
function (pixelCount) {
//set zigzag to true if every other LED row travels in reverse
//if they are all straight across, set it to false
zigzag = true
//rotate a point (x, y), along a center (cx, cy), by an angle in degrees
function rotate(cx, cy, x, y, angle) {
var radians = (Math.PI / 180) * angle,
cos = Math.cos(radians),
sin = Math.sin(radians),
nx = (cos * (x - cx)) + (sin * (y - cy)) + cx,
ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;
return [nx, ny];
}
//create a set of coordinates for a matrix panel
//sized (w, h), rotated by an angle, and offset by (sx, sy)
function panel(w, h, sx, sy, angle) {
var x, x2, y, p, map = []
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
//for zigzag, flip direction every other row
if (zigzag && y % 2 == 1)
x2 = w - 1 - x
else
x2 = x
p = rotate((w-1)/2, (h-1)/2, x2, y, angle);
p[0] += sx
p[1] += sy
map.push(p)
}
}
return map;
}
//assemble one or more panels
var map = [];
map = map.concat(panel(8, 32, 0, 0, 0))
map = map.concat(panel(8, 32, 8, 0, 0))
// map = map.concat(panel(8, 8, 0, 8, 0))
// map = map.concat(panel(8, 8, 8, 8, 0))
return map
}
Actually physical layout for the 16x16 and 8x32 matrix is very different and this could be part of a problem. Index-0 for the 16x16 matrix is in the upper right corner and than zigzagged right-to-left and top-to-bottom. For the 8x32 matrix Index-0 is in the lower right corner and than zigzagged bottom-to-top and right-to-left.
Do you have an idea what could be wrong and how to fix things?
Eventually I would like to use three 16x16 matrix driven by Pixelblaze Output Expander.