2020-12-31 12:59:34 +00:00
|
|
|
// dependency: https://github.com/revarbat/BOSL
|
|
|
|
include <BOSL/constants.scad>
|
|
|
|
use <BOSL/transforms.scad>
|
|
|
|
use <BOSL/shapes.scad>
|
|
|
|
use <BOSL/masks.scad>
|
2020-12-31 22:51:48 +00:00
|
|
|
use <BOSL/sliders.scad>
|
2020-12-31 12:59:34 +00:00
|
|
|
|
|
|
|
// DEBUG:
|
|
|
|
//validation = 1;
|
2020-12-31 18:31:11 +00:00
|
|
|
//xray = 1;
|
2020-12-31 12:59:34 +00:00
|
|
|
|
|
|
|
// EXPORT:
|
|
|
|
MODEL_HARNESS_LEFT=1;
|
|
|
|
MODEL_HARNESS_RIGHT=2;
|
|
|
|
MODEL_HARNESS_TOP=3;
|
2020-12-31 22:51:48 +00:00
|
|
|
MODEL_HARNESS_SLIDER_FRONT=4;
|
|
|
|
MODEL_HARNESS_SLIDER_BACK=5;
|
2020-12-31 18:28:23 +00:00
|
|
|
export=0; // [0:5]
|
2020-12-31 12:59:34 +00:00
|
|
|
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];
|
|
|
|
|
|
|
|
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];
|
2020-12-31 22:51:48 +00:00
|
|
|
shell_wall=3;
|
|
|
|
shell_rim_wall=3;
|
|
|
|
rim_edge_thickness=1.2;
|
|
|
|
rim_edge_tolerance=0.4;
|
|
|
|
expose_back_camera=false;
|
|
|
|
screwmount_screw=3;
|
|
|
|
harness_divider=[16, 0, 1.3];
|
|
|
|
harness_size=[ps.x+shell_wall*2, ps.y+shell_wall*2, ps.z+shell_wall*2];
|
|
|
|
rim_size=[harness_size.x+2*shell_rim_wall, harness_size.y+2*shell_rim_wall, 6];
|
|
|
|
|
2020-12-31 18:28:23 +00:00
|
|
|
w=shell_wall;
|
2020-12-31 12:59:34 +00:00
|
|
|
f=2;
|
|
|
|
rf=5;
|
2020-12-31 22:51:48 +00:00
|
|
|
hs=harness_size;
|
|
|
|
backplane_rim_size=[30, ps.y*0.95, shell_wall/2];
|
|
|
|
|
|
|
|
// ==== SHELL ====
|
2020-12-31 12:59:34 +00:00
|
|
|
|
|
|
|
module shell() {
|
|
|
|
$fn = $preview ? 6 : 30;
|
|
|
|
difference() {
|
|
|
|
cuboid(hs, fillet=f);
|
|
|
|
cuboid(ps, fillet=f);
|
|
|
|
}
|
|
|
|
shell_rim();
|
2020-12-31 18:28:23 +00:00
|
|
|
shell_screwmounts();
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module shell_rim() {
|
|
|
|
$fn = $preview ? 6 : 30;
|
2020-12-31 18:28:23 +00:00
|
|
|
w=shell_rim_wall;
|
2020-12-31 22:51:48 +00:00
|
|
|
s=rim_size;
|
2020-12-31 12:59:34 +00:00
|
|
|
intersection() {
|
|
|
|
difference() {
|
|
|
|
cuboid(s, fillet=rf, edges=EDGES_Z_ALL);
|
|
|
|
cuboid(ps, fillet=f, edges=EDGES_Z_ALL);
|
|
|
|
}
|
|
|
|
cuboid(s, fillet=1);
|
|
|
|
}
|
2020-12-31 22:51:48 +00:00
|
|
|
rail_extension=10;
|
|
|
|
fwd(hs.y/2) xrot(90) harness_rail(slider_len_front+rail_extension);
|
|
|
|
back(hs.y/2) xrot(-90) harness_rail(slider_len_back+rail_extension);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module shell_rim_edge(thickness, groove, tolerance=rim_edge_tolerance) {
|
|
|
|
$fn = $preview ? 6 : 30;
|
|
|
|
w=thickness + (groove ? tolerance : 0);
|
|
|
|
offset=(groove ? 0 : tolerance/2);
|
2020-12-31 18:28:23 +00:00
|
|
|
res=[hs.x+2*(w+offset), hs.y+2*(w+offset), 3];
|
2020-12-31 12:59:34 +00:00
|
|
|
resi=[hs.x+2*offset, hs.y+2*offset, res.z+1];
|
2020-12-31 18:28:23 +00:00
|
|
|
up(0.0) difference() {
|
2020-12-31 12:59:34 +00:00
|
|
|
intersection() {
|
|
|
|
cuboid(res, fillet=rf, edges=EDGES_Z_ALL);
|
2020-12-31 18:28:23 +00:00
|
|
|
cuboid(res, fillet=(groove?1:1.5), edges=EDGES_BOTTOM);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
cuboid(resi, fillet=rf, edges=EDGES_Z_ALL);
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 18:28:23 +00:00
|
|
|
module foreach_screwmount() {
|
|
|
|
for(x = [0:1]) for (y = [0:1]) {
|
|
|
|
translate([(-0.5+x)*ps.x, (-0.5+y)*ps.y, -hs.z/2])
|
|
|
|
children();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module shell_screwmounts() {
|
|
|
|
$fn = $preview ? 6 : 30;
|
|
|
|
r=3;
|
|
|
|
foreach_screwmount() {
|
|
|
|
cylinder(r=r, h=hs.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module shell_screwmounts_holes() {
|
|
|
|
$fn = $preview ? 6 : 30;
|
|
|
|
foreach_screwmount() {
|
|
|
|
up(w) cylinder(d2=screwmount_screw, d1=screwmount_screw*0.5, h=hs.z+1);
|
|
|
|
up(hs.z-1) cylinder(d=screwmount_screw+1.5, h=5);
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 22:51:48 +00:00
|
|
|
module shell_backplane(groove) {
|
|
|
|
down(hs.z/2 - shell_wall/6) up(backplane_rim_size.z/2) right(harness_divider.x) scale(groove ? 1.01 : 1) cuboid(backplane_rim_size, fillet=5, edges=EDGES_Z_LF);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==== SHELL SLIDER AND RAIL ====
|
|
|
|
|
|
|
|
rail_angle=36;
|
|
|
|
rail_wall=1;
|
|
|
|
slider_slop=0.1;
|
|
|
|
slider_len_back=hs.x*0.3;
|
|
|
|
slider_len_front=hs.x*0.3;
|
|
|
|
module harness_slider(l) {
|
|
|
|
base=2;
|
|
|
|
ss=[l, shell_rim_wall, rim_size.z+rail_wall*2];
|
|
|
|
up(ss.y + base) xrot(180) slider(l=ss.x, w=ss.z, h=ss.y, base=base, chamfer=0.9, wall=2, ang=rail_angle, slop=slider_slop, orient=ORIENT_X, align=V_UP);
|
|
|
|
}
|
|
|
|
module harness_rail(l) {
|
|
|
|
sw=2;
|
|
|
|
ss=[l, shell_rim_wall, rim_size.z+rail_wall*2];
|
|
|
|
rail(l=ss.x, w=ss.z, h=ss.y, chamfer=0.5, ang=rail_angle, orient=ORIENT_X, align=V_UP);
|
|
|
|
}
|
2020-12-31 12:59:34 +00:00
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// ==== SHELL CUTOUTS ====
|
|
|
|
module shell_cutouts() {
|
|
|
|
top_cutout();
|
|
|
|
bottom_cutout();
|
|
|
|
left_cutout();
|
|
|
|
right_cutout();
|
|
|
|
front_cutout();
|
|
|
|
shell_screwmounts_holes();
|
|
|
|
}
|
|
|
|
// -- TOP --
|
2020-12-31 12:59:34 +00:00
|
|
|
module screen_cutout() {
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[138, 69, 100];
|
2020-12-31 12:59:34 +00:00
|
|
|
up(s.z/2) cuboid(s, fillet=3, edges=EDGES_Z_ALL);
|
|
|
|
}
|
|
|
|
top_offset=6.5;
|
2020-12-31 18:28:23 +00:00
|
|
|
module top_speaker_cutout() {
|
|
|
|
s=[3, 12, 100];
|
|
|
|
right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) cuboid(s, fillet=1);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module front_camera_cutout() {
|
|
|
|
$fn = $preview ? 6 : 30;
|
|
|
|
d=5;
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[d, d, 100];
|
2020-12-31 12:59:34 +00:00
|
|
|
right(ps.x/2 - top_offset) fwd(11) cylinder(d=s.x, h=s.z);
|
|
|
|
}
|
|
|
|
module leds_cutout() {
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[4, 14, 100];
|
|
|
|
right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) back(23) cuboid(s, fillet=1);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module top_cutout() {
|
|
|
|
screen_cutout();
|
2020-12-31 18:28:23 +00:00
|
|
|
top_speaker_cutout();
|
2020-12-31 12:59:34 +00:00
|
|
|
front_camera_cutout();
|
|
|
|
leds_cutout();
|
|
|
|
}
|
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// -- BOTTOM --
|
2020-12-31 12:59:34 +00:00
|
|
|
module back_camera_cutout() {
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[13, 25, expose_back_camera ? 100 : 11];
|
|
|
|
right(ps.x/2 - 7.5) fwd(ps.y/2 - 23) down(s.z/2 - ps.z/3) cuboid(s, fillet=6, edges=EDGES_Z_ALL);
|
|
|
|
}
|
|
|
|
module bottom_speaker_cutout() {
|
|
|
|
s=[8, 49, 100];
|
|
|
|
left(ps.x/2 - 13)
|
|
|
|
difference() {
|
|
|
|
down(s.z/2 - ps.z/3) cuboid(s, fillet=1);
|
|
|
|
bars=8;
|
|
|
|
down(ps.z/2)
|
|
|
|
for (i = [0:bars-1]) {
|
|
|
|
bs=[s.x+2, 1, 2];
|
|
|
|
step=s.y/bars;
|
|
|
|
fwd(i*step - s.y/2 + step/2) down(w) cube(bs, center=true);
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module bottom_cutout() {
|
|
|
|
back_camera_cutout();
|
2020-12-31 18:28:23 +00:00
|
|
|
bottom_speaker_cutout();
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// -- RIGHT --
|
2020-12-31 12:59:34 +00:00
|
|
|
module headphones_cutout() {
|
|
|
|
$fn = $preview ? 10 : 30;
|
2020-12-31 18:28:23 +00:00
|
|
|
d=8.8;
|
|
|
|
p=[ps.x/2, ps.y/2-24, -0.88];
|
|
|
|
h=100;
|
|
|
|
translate(p) yrot(90) down(10) cylinder(h=h, d=d);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module right_cutout() {
|
|
|
|
headphones_cutout();
|
|
|
|
}
|
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// -- LEFT --
|
2020-12-31 12:59:34 +00:00
|
|
|
module usbc_cutout() {
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[100, 20, 6];
|
2020-12-31 14:37:55 +00:00
|
|
|
left(ps.x/2) down(2) cuboid(s, fillet=1);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module left_cutout() {
|
|
|
|
usbc_cutout();
|
|
|
|
}
|
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// -- FRONT --
|
2020-12-31 12:59:34 +00:00
|
|
|
module buttons_cutout() {
|
2020-12-31 18:28:23 +00:00
|
|
|
s=[42, 100, 5];
|
2020-12-31 14:37:55 +00:00
|
|
|
fwd(ps.y/2) right(ps.x/2 - 44.5) cuboid(s, fillet=1);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
module front_cutout() {
|
|
|
|
buttons_cutout();
|
|
|
|
}
|
|
|
|
|
2020-12-31 22:51:48 +00:00
|
|
|
// ==== MODEL ====
|
2020-12-31 12:59:34 +00:00
|
|
|
|
2020-12-31 18:28:23 +00:00
|
|
|
divider=harness_divider;
|
2020-12-31 12:59:34 +00:00
|
|
|
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();
|
2020-12-31 22:51:48 +00:00
|
|
|
shell_backplane(groove=true);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 22:51:48 +00:00
|
|
|
shell_backplane(groove=false);
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 22:51:48 +00:00
|
|
|
module model_harness_slider_front() {
|
|
|
|
difference() {
|
|
|
|
fwd(hs.y/2) xrot(90) harness_slider(slider_len_front);
|
|
|
|
front_cutout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module model_harness_slider_back() {
|
|
|
|
back(hs.y/2) xrot(-90) harness_slider(slider_len_back);
|
|
|
|
}
|
2020-12-31 12:59:34 +00:00
|
|
|
|
|
|
|
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();
|
2020-12-31 22:51:48 +00:00
|
|
|
if (is_model(MODEL_HARNESS_SLIDER_FRONT)) model_harness_slider_front();
|
|
|
|
if (is_model(MODEL_HARNESS_SLIDER_BACK)) model_harness_slider_back();
|
2020-12-31 12:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|