--- /dev/null
+// x,y is [0,0] at near left PCB screw
+// z=0 is the bottom of the PCB
+
+wall_thickness = 1.5;
+front_panel_thickness = 1.2;
+
+// Measured between PCB screws
+pcb_width = 66; // x
+pcb_length = 58.4; // y
+screw_inside_diam = 2;
+screw_outside_diam = 5;
+
+// From screws to PCB edges
+pcb_left = 5;
+pcb_right = 5;
+pcb_front = 5;
+pcb_back = 5;
+
+// Interior dimensions relative to z=0
+box_height = 25;
+box_depth = 10;
+
+// Cable hole
+cable_x = 7.5;
+cable_z = 4.5;
+cable_diameter = 8;
+
+// Holes in front panel
+ref_x = pcb_width + 3.8;
+led1_x = ref_x - 63;
+led2_x = ref_x - 45;
+led3_x = ref_x - 40;
+led4_x = ref_x - 35;
+led_z = 6.2;
+led_diameter = 3.1;
+usb_left = ref_x - 26;
+usb_right = ref_x - 17;
+usb_bottom = 13.5;
+usb_top = 17.5;
+
+// Lid holders
+holder_width = 10;
+holder_depth = 6;
+holder_tail_depth = 14;
+
+// Lid
+lid_thickness = 2;
+lid_screw_thickness = 3;
+lid_screw_head_diam = 5.8;
+lid_screw_head_height = 2.8;
+lid_screw_holder_height = 4; // includes lid_thickness
+// we want lid_screw_holder_height + (holder_depth + holder_tail_depth)/2 >= screw length (13 mm)
+
+over = 0.1;
+$fn = 50;
+
+module led_hole() {
+ rotate([-90, 0, 0])
+ cylinder(h = front_panel_thickness + 2*over, d = led_diameter);
+}
+
+module screw_hole() {
+ translate([0, 0, -box_depth])
+ difference() {
+ translate([0, 0, -over])
+ cylinder(h = box_depth + over, d = screw_outside_diam);
+ cylinder(h = box_depth + over, d = screw_inside_diam);
+ }
+}
+
+module lid_holder() {
+ difference() {
+ rotate([90, 0, 0])
+ linear_extrude(height = holder_width, center = true)
+ polygon(points = [[0,0], [0,-holder_tail_depth], [holder_width,-holder_depth], [holder_width,0]]);
+
+ translate([holder_width/2, 0, -holder_depth])
+ cylinder(h = holder_depth + over, d = screw_inside_diam);
+ }
+}
+
+module bottom() {
+ union() {
+ difference() {
+ // Exterior
+ translate([-wall_thickness - pcb_left, -front_panel_thickness - pcb_front, -wall_thickness - box_depth])
+ cube([wall_thickness + pcb_left + pcb_width + pcb_right + wall_thickness,
+ front_panel_thickness + pcb_front + pcb_length + pcb_back + wall_thickness,
+ wall_thickness + box_depth + box_height]);
+
+ // Interior
+ translate([-pcb_left, -pcb_front, -box_depth])
+ cube([pcb_left + pcb_width + pcb_right, pcb_front + pcb_length + pcb_back, box_depth + box_height + over]);
+
+ // USB connector hole
+ translate([usb_left, -front_panel_thickness - pcb_front - over, usb_bottom])
+ cube([usb_right - usb_left, front_panel_thickness + 2*over, usb_top - usb_bottom]);
+
+ // LED holes
+ translate([led1_x, -pcb_front - front_panel_thickness - over, led_z])
+ led_hole();
+ translate([led2_x, -pcb_front - front_panel_thickness - over, led_z])
+ led_hole();
+ translate([led3_x, -pcb_front - front_panel_thickness - over, led_z])
+ led_hole();
+ translate([led4_x, -pcb_front - front_panel_thickness - over, led_z])
+ led_hole();
+
+ // BSB cable hole
+ translate([cable_x, pcb_length + pcb_back - over, cable_z])
+ rotate([-90, 0, 0])
+ cylinder(h = wall_thickness + 2*over, d = cable_diameter);
+ }
+
+ // Screw holes
+ screw_hole();
+ translate([pcb_width, 0, 0]) screw_hole();
+ translate([0, pcb_length, 0]) screw_hole();
+ translate([pcb_width, pcb_length, 0]) screw_hole();
+
+ // Lid holders
+ lh = box_height - lid_screw_holder_height;
+ translate([-pcb_left, 0, lh])
+ lid_holder();
+ translate([-pcb_left, pcb_length, lh])
+ lid_holder();
+ translate([pcb_width + pcb_right, 0, lh])
+ rotate([0, 0, 180])
+ lid_holder();
+ translate([pcb_width + pcb_right, pcb_length, lh])
+ rotate([0, 0, 180])
+ lid_holder();
+ }
+}
+
+module lid_screw_holder() {
+ translate([-holder_width/2, -holder_width/2, -lid_screw_holder_height])
+ cube([holder_width, holder_width, lid_screw_holder_height]);
+}
+
+module lid_screw_hole() {
+ translate([0, 0, -lid_screw_holder_height - over])
+ cylinder(h = lid_screw_holder_height + 2*over, d = lid_screw_thickness);
+ translate([0, 0, -lid_screw_head_height])
+ cylinder(h = lid_screw_head_height + over, d1 = lid_screw_thickness, d2 = lid_screw_head_diam);
+}
+
+module lid() {
+ difference() {
+ union() {
+ translate([-pcb_left, -pcb_front, -lid_thickness])
+ cube([pcb_left + pcb_width + pcb_right, pcb_front + pcb_length + pcb_back, lid_thickness]);
+
+ translate([0, 0, 0])
+ lid_screw_holder();
+ translate([0, pcb_length, 0])
+ lid_screw_holder();
+ translate([pcb_width, 0, 0])
+ lid_screw_holder();
+ translate([pcb_width, pcb_length, 0])
+ lid_screw_holder();
+ }
+ translate([0, 0, 0])
+ lid_screw_hole();
+ translate([0, pcb_length, 0])
+ lid_screw_hole();
+ translate([pcb_width, 0, 0])
+ lid_screw_hole();
+ translate([pcb_width, pcb_length, 0])
+ lid_screw_hole();
+ }
+}
+
+bottom();
+// color([1, 0, 0]) translate([0, 0, box_height]) lid();