// ----------------------------------------------------------------------- // Modular LED Matrix Prismatic Lens Array (Short Pegs / Manifold Fix) // ----------------------------------------------------------------------- // NATIVE LANDSCAPE LAYOUT (3 columns x 2 rows) // Select which tile to generate: // 1 = Top Left | 2 = Top Mid | 3 = Top Right // 4 = Bottom Left | 5 = Bottom Mid | 6 = Bottom Right part = 1; // [1:6] // --- Matrix Parameters --- cellsX = 16; cellsY = 16; pitch = 10; meshSolid = 2; meshSpace = pitch - meshSolid; // 8mm hole space from the Front Grid borderWidth = 10; // --- Lens Array Parameters --- baseThickness = 0.4; // 2 layers at 0.2mm for an ultra-thin sandwich film clearance = 0.3; // Friction fit tolerance plugSize = meshSpace - clearance; // ~7.7mm peg plugHeight = 1.5; // SHORTENED: Snaps into hole but leaves an air gap above the LED prismSize = 1.5; // Size of the light-scattering pyramids on top prismHeight = 0.8; // Height of the pyramids // --- Logic --- hasLeft = (part == 1 || part == 4) ? 1 : 0; hasRight = (part == 3 || part == 6) ? 1 : 0; hasTop = (part == 1 || part == 2 || part == 3) ? 1 : 0; hasBottom = (part == 4 || part == 5 || part == 6) ? 1 : 0; gridWidth = cellsX * pitch; gridHeight = cellsY * pitch; leftOffset = hasLeft * borderWidth; bottomOffset = hasBottom * borderWidth; totalWidth = gridWidth + (hasLeft * borderWidth) + (hasRight * borderWidth); totalHeight = gridHeight + (hasTop * borderWidth) + (hasBottom * borderWidth); holeRad = 2; // Clearance for M3 screws // --- Procedural Prismatic Refractor (Manifold Safe) --- module pyramid(size, h) { // A 4-sided cylinder rotated 45 degrees makes a perfect, render-safe square pyramid translate([size/2, size/2, 0]) rotate([0, 0, 45]) cylinder(h=h, r1=size/sqrt(2), r2=0, $fn=4); } module refractor_top(size, h, step) { count = floor(size / step); offset = (size - (count * step)) / 2; translate([offset, offset, 0]) for(x=[0:count-1]) { for(y=[0:count-1]) { translate([x*step, y*step, 0]) pyramid(step, h); } } } // --- Main Build --- difference() { union() { // 1. The Ultra-Thin Sandwich Film Base cube([totalWidth, totalHeight, baseThickness]); // 2. The Extruded Diffuser Pegs for (x = [0 : cellsX - 1]) { for (y = [0 : cellsY - 1]) { // Calculate position to exactly match the Front Grid holes px = leftOffset + (meshSolid/2) + (x * pitch) + (clearance/2); py = bottomOffset + (meshSolid/2) + (y * pitch) + (clearance/2); translate([px, py, baseThickness]) { // Solid Light Pipe cube([plugSize, plugSize, plugHeight]); // Prismatic Scatter Top translate([0, 0, plugHeight]) refractor_top(plugSize, prismHeight, prismSize); } } } } // 3. Punch alignment holes perfectly matched to the outer frame if (hasLeft) { for (i = [1 : 3]) { translate([borderWidth / 2, bottomOffset + (i * gridHeight/4), -0.1]) cylinder(h=baseThickness + plugHeight + prismHeight + 1, r=holeRad, $fn=32); } } if (hasRight) { for (i = [1 : 3]) { translate([totalWidth - (borderWidth / 2), bottomOffset + (i * gridHeight/4), -0.1]) cylinder(h=baseThickness + plugHeight + prismHeight + 1, r=holeRad, $fn=32); } } if (hasTop) { for (i = [1 : 3]) { translate([leftOffset + (i * gridWidth/4), totalHeight - (borderWidth / 2), -0.1]) cylinder(h=baseThickness + plugHeight + prismHeight + 1, r=holeRad, $fn=32); } } if (hasBottom) { for (i = [1 : 3]) { translate([leftOffset + (i * gridWidth/4), borderWidth / 2, -0.1]) cylinder(h=baseThickness + plugHeight + prismHeight + 1, r=holeRad, $fn=32); } } }