Mapping function for 72 + 256 + 64 LED staff
function (pixelCount) {
// All _base and _length measurements in mm
handle_base = 340
strip_pixels = 72
strip_length = 500
strip_gap = strip_length / strip_pixels
cylinder_base = handle_base + strip_length
cylinder_side_p = 16
cylinder_pixels = cylinder_side_p * cylinder_side_p
cylinder_side_l = 160
cylinder_radius = cylinder_side_l / Math.PI
f64_base = handle_base + strip_length + cylinder_side_l
f64_radius = 200
f64_pixels = 64
var map = []
for (p = 0; p < strip_pixels; p++) {
map.push([0,0, p * strip_gap + handle_base ])
}
for (p = 0; p < cylinder_pixels; p++) {
x = Math.floor(p / cylinder_side_p)
y = p % cylinder_side_p
y = x % 2 == 1 ? (cylinder_side_p - 1 - y) : y
theta = x * (Math.PI * 2) / cylinder_side_p
map.push([
cylinder_radius * Math.sin(theta),
cylinder_radius * Math.cos(theta),
(y/cylinder_side_p * cylinder_side_l) + cylinder_base
])
}
buildFermatSpiral(0, 0, cylinder_radius, 64, map, f64_base, 0)
map.push([0,0,0]) // unused pixel at origin
return map
}
function buildFermatSpiral(originX, originY, spacing, pixelCount, map, zend, angleoffset) {
reallocation = [0, 13, 26, 39, 52, 57, 44, 31,
18, 5, 10, 23, 36, 49, 62, 54,
41, 28, 15, 2, 7, 20, 33, 46,
59, 51, 38, 25, 12, 4, 17, 30,
43, 56, 61, 48, 35, 22, 9, 1,
14, 27, 40, 53, 58, 45, 32, 19,
6, 11, 24, 37, 50, 63, 55, 42,
29, 16, 3, 8, 21, 34, 47, 60 ]
for (var i = 0; i < pixelCount; i++) {
r = spacing * Math.sqrt(reallocation[i]/63);
theta = reallocation[i] * 2.3998277 + angleoffset // golden angle
y = originY - (r * Math.sin(theta));
x = originX + (r * Math.cos(theta));
map.push([x, y, zend])
}
}