diff --git a/model/common.scad b/model/common.scad index 0a9b063..3f87d66 100644 --- a/model/common.scad +++ b/model/common.scad @@ -1,45 +1,88 @@ +include + BASE_MODEL_SCALE = [1.1, 1, 1.1]; BASE_MODEL_TRANSLATE = [-0.4, 0, 16.978]; +EPS = 0.01; +$fn = 50; -module main_display(){ - // Outer dimensions, height currently unknown - cube([55.04, 89.3, 10]); +module main_display() { + // Outer dimensions, height currently unknown + cube([55.04, 89.3, 10]); } -module pad(){ - // A button has 4.2 x 6 mm -> At least ~20x20 are required for the PCB - cube([20, 20, 10]); +module pad() { + // A button has 4.2 x 6 mm -> At least ~20x20 are required for the PCB + cube([20, 20, 10]); } -module small_display_below_main() -{ - // https://de.aliexpress.com/item/1005003753680706.html - cube([45.8, 20, 11.3]); - // old i2c variant: - //cube([43.5, 19.44, 4.5]); +module small_display_below_main() { + // https://de.aliexpress.com/item/1005003753680706.html + cube([45.8, 20, 11.3]); + // old i2c variant: + //cube([43.5, 19.44, 4.5]); - // initial dimension ideas - // cube([38,16,4]); - // translate([150,0,0]) cube([22,5.5,4]); + // initial dimension ideas + // cube([38,16,4]); + // translate([150,0,0]) cube([22,5.5,4]); } -module tertiary_display() -{ - // https://de.aliexpress.com/item/1005006034531826.html - cube([80, 36, 10]); +module tertiary_display() { + // https://de.aliexpress.com/item/1005006034531826.html + cube([80, 36, 10]); } -module battery() { - // 18650 - rotate([0,90,0]) cylinder(d=18, h=65); +module battery(anchor = BOTTOM) { + // 18650 + rotate([0, 90, 0]) cylinder(d=18, h=65, anchor=anchor); } -module microcontroller() { - // width 32 including USB-C port - length = 91.5; - height = 20; - battery_length = 65; - delta = length - battery_length; - cube([length, 32, height]); - translate([delta / 2,16, 15]) battery(); +/// USB-C port and switch not 100% dimensionally accurate, take care! +module micro_controller(battery_holder = false, battery = false) { + pcb_length = 91.5; + pcb_height = 6.5; // including components, highest point: jst connector, followed by uC + pcb_height_no_components = 1.1; + pcb_width = 28.8; + + hole_diameter = 2.5; + hole_inset = 1; + usb_protrusion = 1.7; + usb_width = 9; + usb_inset_from_pcb_end = 5; + power_switch_protrusion = 2.1; + power_switch_inset_from_pcb_end = 8.1; + power_switch_width = 4; + + battery_holder_height = 15; + battery_holder_width = 21; + battery_holder_length = 77.3; + + battery_length = 65; + battery_protrusion = 4.5; + + difference() { + cuboid([pcb_length, pcb_width, pcb_height], rounding=2, edges="Z") { + if (battery_holder) + position(TOP) + cube([battery_holder_length, battery_holder_width, battery_holder_height], anchor=BOTTOM + CENTER) { + if (battery) + position(TOP) + up(battery_protrusion) + battery(anchor=CENTER + LEFT); + } + position(RIGHT + BOTTOM) { + position(FRONT) + left(usb_inset_from_pcb_end) + cube([usb_width, usb_protrusion, pcb_height - pcb_height_no_components], orient=FRONT, anchor=RIGHT + BOTTOM + FRONT); + position(BACK) + left(power_switch_inset_from_pcb_end) + cube([power_switch_width, power_switch_protrusion, pcb_height - pcb_height_no_components], orient=FRONT, anchor=RIGHT + TOP + FRONT); + } + } + + xcopies(pcb_length - (2 * hole_inset) - hole_diameter) { + ycopies(pcb_width - (2 * hole_inset) - hole_diameter) { + cyl(d=hole_diameter, h=pcb_height + EPS, orient=UP); + } + } + } }