/* [Rendering options] */ // Show placeholder PCB in OpenSCAD preview show_pcb = false; // Lid mounting method lid_model = "cap"; // [cap, inner-fit] // Conditional rendering render = "case"; // [all, case, lid] /* [Dimensions] */ // Height of the PCB mounting stand-offs between the bottom of the case and the PCB standoff_height = 5.0; // PCB thickness pcb_thickness = 1.6; // Bottom layer thickness floor_height = 1.2; // Case wall thickness wall_thickness = 1.2; // Space between the top of the PCB and the top of the case headroom = 0; /* [M2.5 screws] */ // Outer diameter for the insert insert_M2_5_diameter = 3.27; // Depth of the insert insert_M2_5_depth = 3.75; /* [Hidden] */ $fa=$preview ? 10 : 4; $fs=0.2; inner_height = floor_height + standoff_height + pcb_thickness + headroom; module wall (thickness, height) { linear_extrude(height, convexity=10) { difference() { offset(r=thickness) children(); children(); } } } module bottom(thickness, height) { linear_extrude(height, convexity=3) { offset(r=thickness) children(); } } module lid(thickness, height, edge) { linear_extrude(height, convexity=10) { offset(r=thickness) children(); } translate([0,0,-edge]) difference() { linear_extrude(edge, convexity=10) { offset(r=-0.2) children(); } translate([0,0, -0.5]) linear_extrude(edge+1, convexity=10) { offset(r=-1.2) children(); } } } module box(wall_thick, bottom_layers, height) { if (render == "all" || render == "case") { translate([0,0, bottom_layers]) wall(wall_thick, height) children(); bottom(wall_thick, bottom_layers) children(); } if (render == "all" || render == "lid") { translate([0, 0, height+bottom_layers+0.1]) lid(wall_thick, bottom_layers, lid_model == "inner-fit" ? headroom-2.5: bottom_layers) children(); } } module mount(drill, space, height) { translate([0,0,height/2]) difference() { cylinder(h=height, r=(space/2), center=true); cylinder(h=(height*2), r=(drill/2), center=true); translate([0, 0, height/2+0.01]) children(); } } module connector(min_x, min_y, max_x, max_y, height) { size_x = max_x - min_x; size_y = max_y - min_y; translate([(min_x + max_x)/2, (min_y + max_y)/2, height/2]) cube([size_x, size_y, height], center=true); } module pcb() { thickness = 1.6; color("#009900") difference() { linear_extrude(thickness) { polygon(points = [[0.0,0.0], [35.0,0.0], [35.0,25.0], [0.0,25.0], [0.0,0.0]]); } translate([3, 13, -1]) cylinder(thickness+2, 1.0999999999999996, 1.0999999999999996); translate([32, 3, -1]) cylinder(thickness+2, 1.0999999999999996, 1.0999999999999996); translate([15, 22, -1]) cylinder(thickness+2, 1.1000000000000014, 1.1000000000000014); translate([23, 10, -1]) cylinder(thickness+2, 1.0999999999999996, 1.0999999999999996); } } module case_outline() { polygon(points = [[-2.0,-2.0], [37.0,-2.0], [37.0,27.0], [-2.0,27.0]]); } module Insert_M2_5() { translate([0, 0, -insert_M2_5_depth]) cylinder(insert_M2_5_depth, insert_M2_5_diameter/2, insert_M2_5_diameter/2); translate([0, 0, -0.3]) cylinder(0.3, insert_M2_5_diameter/2, insert_M2_5_diameter/2+0.3); } rotate([render == "lid" ? 180 : 0, 0, 0]) scale([1, -1, 1]) translate([-17.5, -12.5, 0]) { pcb_top = floor_height + standoff_height + pcb_thickness; difference() { box(wall_thickness, floor_height, inner_height) { case_outline(); } } if (show_pcb && $preview) { translate([0, 0, floor_height + standoff_height]) pcb(); } if (render == "all" || render == "case") { // MH1 [('M2.5', 2.5)] translate([3, 13, floor_height]) mount(2.2, 4.2, standoff_height) Insert_M2_5(); // MH2 [('M2.5', 2.5)] translate([32, 3, floor_height]) mount(2.2, 4.2, standoff_height) Insert_M2_5(); // MH3 [('M2.5', 2.5)] translate([15, 22, floor_height]) mount(2.2, 4.2, standoff_height) Insert_M2_5(); // MH4 [('M2.5', 2.5)] translate([23, 10, floor_height]) mount(2.2, 4.2, standoff_height) Insert_M2_5(); } }