From 60585efd158b5f8ea5e00580f37372608b79b616 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Thu, 31 Dec 2020 13:59:34 +0100 Subject: [PATCH] Base phone harness --- main.scad | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 main.scad diff --git a/main.scad b/main.scad new file mode 100644 index 0000000..7e90c12 --- /dev/null +++ b/main.scad @@ -0,0 +1,218 @@ +// dependency: https://github.com/revarbat/BOSL +include +use +use +use + +// DEBUG: +//validation = 1; +//xray = 1; + +// EXPORT: +MODEL_HARNESS_LEFT=1; +MODEL_HARNESS_RIGHT=2; +MODEL_HARNESS_TOP=3; +export=0; // [0:5] +function is_not_export() = is_undef(export) || export == 0; +function is_export() = !is_not_export(); +function is_model_strict(m) = is_export() && export == m; +function is_model(m) = is_not_export() || export == m; + +function get_phone_size() = [160, 76.7, 10]; + +rim_edge_thickness=0.8; +rim_edge_tolerance=0.6; + +module phone() { + s=get_phone_size(); + color("gray") + cuboid(s, fillet=5); +} +module arm() { + $fn=6; + s=[210, 55, 50]; + color("SaddleBrown") + down(s.z/2 + get_phone_size().z/2) cuboid(s, fillet=20); +} + +module phone_harness() { + ops=get_phone_size(); + ps=[ops.x+0.2, ops.y+0.2, ops.z+0.2]; + w=1; + f=2; + rf=5; + hs=[ps.x+w*2, ps.y+w*2, ps.z+w*2]; + + module shell() { + $fn = $preview ? 6 : 30; + difference() { + cuboid(hs, fillet=f); + cuboid(ps, fillet=f); + } + shell_rim(); + } + module shell_rim() { + $fn = $preview ? 6 : 30; + w=2; + s=[hs.x+2*w, hs.y+2*w, 6]; + intersection() { + difference() { + cuboid(s, fillet=rf, edges=EDGES_Z_ALL); + cuboid(ps, fillet=f, edges=EDGES_Z_ALL); + } + cuboid(s, fillet=1); + } + } + module shell_rim_edge(thickness, groove, tolerance=rim_edge_tolerance) { + $fn = $preview ? 6 : 30; + w=thickness + (groove ? tolerance : 0); + offset=(groove ? 0 : tolerance/2); + res=[hs.x+2*(w+offset), hs.y+2*(w+offset), 4.5]; + resi=[hs.x+2*offset, hs.y+2*offset, res.z+1]; + up(0.5) difference() { + intersection() { + cuboid(res, fillet=rf, edges=EDGES_Z_ALL); + cuboid(res, fillet=(groove?1:2), edges=EDGES_BOTTOM); + } + cuboid(resi, fillet=rf, edges=EDGES_Z_ALL); + } + } + + module screen_cutout() { + s=[138, 69, 10]; + up(s.z/2) cuboid(s, fillet=3, edges=EDGES_Z_ALL); + } + top_offset=6.5; + module speaker_cutout() { + s=[3, 12, 10]; + right(ps.x/2 - top_offset) up(ps.z/2) cuboid(s, fillet=1); + } + module front_camera_cutout() { + $fn = $preview ? 6 : 30; + d=5; + s=[d, d, 10]; + right(ps.x/2 - top_offset) fwd(11) cylinder(d=s.x, h=s.z); + } + module leds_cutout() { + s=[4, 14, 10]; + right(ps.x/2 - top_offset) up(ps.z/2) back(23) cuboid(s, fillet=1); + } + module top_cutout() { + screen_cutout(); + speaker_cutout(); + front_camera_cutout(); + leds_cutout(); + } + + module back_camera_cutout() { + s=[13, 25, 10]; + right(ps.x/2 - 8) fwd(ps.y/2 - 24) down(ps.z/2) cuboid(s, fillet=6, edges=EDGES_Z_ALL); + } + module bottom_cutout() { + back_camera_cutout(); + } + + module headphones_cutout() { + $fn = $preview ? 10 : 30; + d=9; + p=[ps.x/2, ps.y/2-24, -1]; + h=10; + translate(p) yrot(90) down(h/2) cylinder(h=h, d=d); + } + module right_cutout() { + headphones_cutout(); + } + + module usbc_cutout() { + s=[10, 20, 8]; + left(ps.x/2) down(1) cuboid(s, fillet=1); + } + module left_cutout() { + usbc_cutout(); + } + + module buttons_cutout() { + s=[42, 10, 5]; + fwd(ps.y/2) right(ps.x/2 - 42) cuboid(s, fillet=1); + } + module front_cutout() { + buttons_cutout(); + } + + module shell_cutouts() { + top_cutout(); + bottom_cutout(); + left_cutout(); + right_cutout(); + front_cutout(); + } + + divider=[30, 0, 2.3]; + module model_harness_left() { + intersection() { + intersection() { + translate(divider) downcube([1000, 1000, 1000]); + translate(divider) leftcube([1000, 1000, 1000]); + } + difference() { + shell(); + shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance); + shell_cutouts(); + } + } + } + module model_harness_right() { + intersection() { + intersection() { + translate(divider) downcube([1000, 1000, 1000]); + translate(divider) rightcube([1000, 1000, 1000]); + } + difference() { + shell(); + shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance); + shell_cutouts(); + } + } + } + module model_harness_top() { + intersection() { + translate(divider) upcube([1000, 1000, 1000]); + difference() { + shell(); + shell_cutouts(); + } + } + difference() { + shell_rim_edge(rim_edge_thickness, groove=false); + shell_cutouts(); + } + } + + if (is_model(MODEL_HARNESS_LEFT)) model_harness_left(); + if (is_model(MODEL_HARNESS_RIGHT)) model_harness_right(); + if (is_model(MODEL_HARNESS_TOP)) model_harness_top(); +} + +module model() { + phone_harness(); +} + +if (!is_undef(validation)) { + intersection() { + phone(); + model(); + } +} else { + intersection() { + if (!is_undef(xray)) { + span_cube([0,1000*xray], [0,1000*xray], [-1000,1000]); + } + union() { + if (is_not_export()) { + //phone(); + //arm(); + } + model(); + } + } +}