5 phone = [ 75.0, 145.0 ];
7 prop_angles = [ 15, 30, 45, 60 ];
9 bumper = [ 0.250, -0.025 ];
10 // ^ One side. Overall size is increased by twice this.
11 // If no bumpers, is the gap around the phone.
17 button_cutout_depth = 9;
19 phone_edge_thick = 9.0;
20 phone_total_thick = 12.0;
21 phone_backside_slope_inner = 1.5; // larger means shallower
22 phone_backside_slope_outer = 1.0; // larger means shallower
24 camera_pos_tl = [ 6.450, 12.750 ]; // measured from tl corner
25 camera_pos_br = [ 22.300, 37.600 ]; // tl/br as seen from back
27 jack_pos = [ 14.38, 7.96 ];
28 jack_dia = 10.64 + .5; // some jack I had lying around
30 noisecancelmic_pos = [ 19.54, 7.37 ]; // from rhs
31 noisecancelmic_dia = 4.00;
33 //fingerpushhole_dias = [ 15, 18 ];
34 fingerpushhole_dias = [];
36 rearspeaker_pos_bl = [ 12.64, 18.72 ];
37 rearspeaker_size = [ 3.76, 7.36 ];
39 microusb_above = 3.27 - 0.25;
41 microusb_width = 16.12 + 1.25;
48 case_struts_count = 6;
49 case_struts_solid_below = 1.00;
50 case_struts_solid_above = 0.75;
51 case_struts_width = 0.10;
55 keeper_inner_width = 2.75;
56 keeper_inner_height = 2.75;
57 keeper_slant_slope = 2; // larger means steeper
59 keeper_gap_z_top = 0.25;
60 keeper_gap_z_bot = 0.75;
62 keeper_gap_x_holes = 0.75;
64 keeper_side = 0; // 0 = lhs; 1 = rhs
75 foldover_lever_gap = 0.50;
77 hingescrew_shaft_dia = 2.0 + 0.25; // M2 x 12mm machine screw
78 hingescrew_shaft_len = 12;
79 hingescrew_nut_thick = 1.93 + 0.20; // incl. washer
80 hingescrew_nut_dia = 4.72 + 0.50; // washer, actually
81 hingescrew_head_th = 1.38 + 0.75;
82 hingescrew_head_dia = 3.92;
83 lever_cover_th = 0.75;
90 buttonishleg_default_l_is_fudge = 10;
92 hinge_base_slope = 1.5; // bigger is steeper
94 strut_min_at_end = 1.5;
97 hinge_x_postscrew_gap = 0.75;
98 hinge_x_arms_gap = 0.35;
99 hinge_r_arms_gap = 0.55;
101 rearspeaker_gap = [ 2.0, 2.0 ]; // each side
105 catch_thickness = 1.0;
106 catch_side_gap = 0.75; // each side
110 catch_finger_height = 1.5;
111 catch_finger_depth = 2.5;
113 prop_recess_under = 0.50;
114 prop_recess_slop = 0.200; // each side
119 prop_side_gap = 0.75; // each side
120 prop_caserecess_behind = 0.75;
121 prop_caserecess_taper = 0.25; // each side
124 // ---------- calculated ----------
126 phone_width = (phone + bumper*2)[0];
127 phone_height = (phone + bumper*2)[1];
129 inside_br = [phone_width, -phone_height];
131 //echo(camera_pos_tl + bumper,
132 // camera_pos_br + bumper);
134 // ----- could be changed -----
135 lid_buttoncover_gap = lid_gap_x;
136 lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
138 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
140 prop_lidrecess_depth = case_th_lid - prop_recess_under;
142 prop_nose_len = case_th_lid - prop_recess_under;
143 prop_recess_slope = tan(prop_max_angle); // bigger means steeper
144 prop_recess_width = prop_main_th / cos(prop_max_angle) + prop_backfwd_gap;
147 //lid_lip_overlap_width xxx bad name = ;
148 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
151 epp1 = [0, -phone_edge_thick];
152 epp2i = epp1 + phone_backside_slope_thick * [ phone_backside_slope_inner, -1 ];
153 epp2o = epp1 + phone_backside_slope_thick * [ phone_backside_slope_outer, -1 ];
154 epp3 = epp2i + [10, 0];
155 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
156 epp4 = epp5 + [-1,0] * case_th_side;
159 kppd = kppe + [1,0] * keeper_inner_width;
160 kppc = kppd + [0,1] * keeper_th_z;
161 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
162 kppf = kppe - [0,1] * keeper_inner_height;
163 kppa = [ kppb[0], kppf[1] ];
165 lpp10 = [ epp5[0] + lid_gap_x, kppc[1] + lid_gap_z ];
166 lpp11 = [ lpp10[0], epp5[1] + lid_gap_z ];
168 lp_r12 = case_th_lid - (lpp11[1] - lpp10[1]);
170 lpp12 = [ epp4[0] + lp_r12, lpp11[1] ];
171 lpp13 = [ lpp12[0], lpp12[1] + lp_r12 ];
173 case_bottom_z = epp2o[1] - case_th_bottom;
177 bppN = [ 0.5 * (epp0[0] + epp4[0]), bppM[1] ];
178 bppR = [ bppN[0] + lid_buttoncover_gap, -button_cutout_depth ];
179 bppS = [ epp1[0], bppR[1] ];
180 bppQ = [ bppM[0], bppR[1] - lid_buttoncover_overlap ];
181 bppP = bppQ + [0,1] * lid_buttoncover_gap;
182 bppO = [ bppN[0], bppP[1] ];
183 bppL = lpp10 + [5,0];
184 bppK = [ bppL[0], bppN[1] ];
185 bppJ = [ bppN[0], bppL[1] ];
188 hp_rn = hingescrew_nut_dia/2;
189 hp_r2_min = hp_rn + lever_cover_th;
190 hp_rs = hingescrew_shaft_dia/2;
191 hp_r1_min = hp_rs + hingemount_th;
193 hp_r1 = max(hp_r1_min, hp_r2_min);
197 hppS = epp2o + [0,-1] * case_th_bottom;
198 hp_k = 0.5 * (hppU[1] - hppS[1] + foldover_gap);
200 hppM = [ epp4[0] - foldover_lever_gap - hp_r2,
201 0.5 * (hppU + hppS)[1] ];
202 hppT = [ hppM[0], hppU[1] - hp_r1 ];
203 hppB = hppT + [0,-1] * hp_k;
205 hppE_y = epp2o[1] - case_th_bottom + hp_r1;
206 hppE_x = hppB[0] + (hppB[1] - hppE_y) * hinge_base_slope;
207 hppE = [ hppE_x, hppE_y ];
209 // hinge elevation x coords
211 hingescrew_portion_len =
212 0.5* (hingescrew_shaft_len - hingescrew_nut_thick - hinge_x_gap);
214 hex20 = max(epp2o[0],
216 kppd[0] + hingescrew_head_th + keeper_gap_x_holes);
217 hex21 = hex20 + hingescrew_portion_len;
218 hex22 = hex21 + hinge_x_gap;
219 hex23 = hex22 + hingescrew_portion_len
220 - hingescrew_nut_thick; // bodge, need to divvy this up more sensibly
221 hex24 = hex20 + hingescrew_shaft_len + hinge_x_postscrew_gap;
222 //echo(hex20, hex21, hex22, hex23, hex24);
223 //echo(hingescrew_portion_len);
227 cppJ = [ epp4[0] + catch_thickness, lpp10[1] ];
228 cppA = cppJ + [lid_gap_x, -lid_gap_z];
229 cppB = [ epp0[0], cppA[1] ];
230 cppP = [ epp4[0], cppJ[1] ];
232 cppS = cppJ + [0,-1] * catch_len;
233 cppD = [ cppA[0], cppS[1] + catch_slop ];
234 cppC = [ cppB[0], cppD[1] ];
235 cppT = cppS + [1,0] * catch_depth;
236 cppU = cppT + [0,-1] * catch_height;
237 cppV = [ cppS[0], cppU[1] - catch_depth ];
239 cppR = 0.5*(cppP + cppJ);
241 cp_rQ = 0.5 * (cppJ[0] - cppP[0]);
243 cppV[1] - (catch_finger_height - cp_rQ) ];
244 cppF = [ cppV[0] + catch_finger_depth, cppC[1] ];
246 // prop recess in lid
248 prl_r1 = prop_end_dia/2 + prop_recess_slop; // radius of end
250 prlp1 = [ lpp10[0] + prop_recess_slop + prop_end_dia/2,
251 lpp10[1] + prop_recess_slop + prop_end_dia/2 ];
253 // prop recess in case
255 prcp2 = [ epp1[0], case_bottom_z ]; // protrusion corner
257 prc_r2 = prop_end_dia/2 + prop_recess_slop; // radius of end
259 prcp1_y = epp2o[1] - prop_recess_under - prc_r2;
260 prcp2_x = prcp2[0] + prop_caserecess_behind + prc_r2 +
261 (prcp1_y - case_bottom_z) * prop_caserecess_taper;
262 prcp2 = [ prcp1_x, prcp1_y ]; // centre of tip circle
264 prop_recess_hw = 0.5 * prop_main_width + prop_side_gap;
266 prop_caserecess_buildout_r = prcp2[0] - epp2o[0];
268 // ---------- modules ----------
270 module KeeperProfile(slant=0){
271 use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
272 polygon([use_e, kppd, kppc, kppb, kppa, kppf]);
275 module EdgeProfile(){
278 translate(epp3) square(case_th_bottom*2, center=true);
279 circleat(epp2o, r=case_th_bottom);
280 circleat(epp1, r=case_th_side);
281 rectfromto(epp0, epp4);
283 polygon([ epp5 + [0,10],
290 module LidEdgeProfile(){
299 circleat(lpp12, r=lp_r12);
300 rectfromto( lpp12 + [-10, 0],
301 lpp12 + [+10, +10] );
305 module ButtonCoverProfile(){
307 polygon([ bppM, bppP, bppO, bppJ, bppL, bppK ]);
315 module ButtonPlan(l, deep, cut){
317 (cut ? 0 : lid_buttoncover_gap);
320 (deep ? lid_buttoncover_overlap : 0);
322 C = [0,0]; // by definition
326 B0 = C + [0,-1] * button_cutout_depth;
327 B1 = B0 + [0,1] * epsilon;
329 r0 = 0.5 * (T[1] - B0[1]);
330 A = [ -(l + button_l_fudge)/2 + r0, 0.5 * (T[1] + B0[1]) ];
331 H = A + [0,-1] * delta;
337 E1 = E0 + [1,0] * epsilon;
339 I0 = [ E0[0], H[1] ];
340 I1 = [ E1[0], H[1] ];
343 for (m=[0,1]) mirror([m,0])
344 circleat(H, r0 - epsilon);
346 for (m=[0,1]) mirror([m,0]) {
356 circleat(D, r0 + epsilon);
361 module CatchCatchProfile(){
363 for (c=[ cppR, cppQ ])
367 circleat(lpp12, lp_r12);
368 circleat(lpp12 + [5,0], lp_r12);
369 rectfromto(cppP, cppP + [5,0.1]);
371 polygon([cppJ, cppS, cppT, cppU, cppV, cppQ, cppR]);
374 module CatchCutProfile(){
386 module Flip_rhs(yn=[0,1]) {
388 translate([phone_width/2, 0, 0])
389 mirror([$rhsflip,0,0])
390 translate([-phone_width/2, 0, 0])
395 module Flip_bot(yn=[0,1]) {
397 translate([0, -phone_height/2, 0])
398 mirror([0, $botflip, 0])
399 translate([0, phone_height/2, 0])
404 module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
407 translate([0, -phone_cnr_rad, 0])
409 linear_extrude(height = phone_height - phone_cnr_rad*2)
413 Flip_rhs() Flip_bot() {
414 translate([+1,-1] * phone_cnr_rad)
419 translate([-1,0] * phone_cnr_rad)
421 rectfromto([0,-20],[10,20]);
423 translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
429 translate([ phone_width - phone_cnr_rad, 0,0 ])
431 linear_extrude(height = phone_width - phone_cnr_rad*2)
435 translate([0,0, fill_zstart])
436 mirror([0,0, fill_downwards])
437 linear_extrude(height = fill_th)
438 rectfromto([+1,-1] * phone_cnr_rad,
439 [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
442 module CaseAperture(pos, dia, $fn) {
444 translate([ pos[0] + bumper[0],
447 rotate([-90, theta, 0])
448 cylinder(r = dia/2 / cos(theta),
452 module SideButton(y, y_ref_sign, l){
454 // +1 measured from top of actual phone to top of button
455 // -1 measured from bottom of actual phone to bottom of button
456 // 0 y is centre of button in coordinate system
458 eff_y = y_ref_sign > 0 ? -bumper [1] -y -l/2 :
459 y_ref_sign < 0 ? (-phone -bumper)[1] +y +l/2 :
462 translate([0, eff_y, 0])
466 module LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
467 $button_leg_only = true;
468 SideButton(y, y_ref_sign, l) children();
472 Flip_rhs(1) SideButton(15.580, +1, 8.9) children(); // power
473 Flip_rhs(1) SideButton(48.700, -1, 8.920) children(); // camera
474 Flip_rhs(0) SideButton(30.800, +1, 21.96) children(); // volume
475 Flip_rhs( ) LidButtonishLeg(14, -1) children();
476 // Flip_rhs(0) LidButtonishLeg(20, +1, 20) children();
479 module Struts(x_start, z_min, th){
480 // if th is negative, starts at z_min and works towards -ve z
481 // and object should then be printed other way up
482 for (i= [1 : 1 : case_struts_count]) {
486 mirror([0,0, th<0 ? 1 : 0])
488 -phone_height * i / (case_struts_count+1),
489 case_struts_solid_below])
490 linear_extrude(height= abs(th)
491 -(case_struts_solid_below+case_struts_solid_above))
492 rectfromto([ x_start, -0.5 * case_struts_width ],
493 [ phone_width - x_start, +0.5 * case_struts_width ]);
497 module OrdinaryRearAperture(rhs,bot, pos){
498 Flip_rhs(rhs) Flip_bot(bot)
501 translate(pos + bumper)
509 linextr(-epp2i[0], 60)
510 translate([0.5 * phone_width, 0, 0])
511 rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
512 [+microusb_width/2, epp0[1] + -microusb_above]);
516 module OrdinaryRearApertures(){
518 OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
519 rectfromto(-rearspeaker_gap,
520 rearspeaker_size + rearspeaker_gap);
522 // finger hole to remove phone
523 if (len(fingerpushhole_dias))
524 OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
526 scale(fingerpushhole_dias)
530 module RearCameraAperture(){
533 linear_extrude(height = 20)
536 rectfromto(camera_pos_tl, camera_pos_br);
539 module HingeLidProfile(){
541 circleat(hppT, hp_r1);
542 circleat(lpp12, lp_r12);
550 module HingeBaseProfile(){
553 circleat(hppB, hp_r1);
554 circleat(hppE, hp_r1);
555 circleat(epp2o, case_th_bottom);
556 circleat(hppB + [10,0], hp_r1);
558 polygon([epp5, epp1, epp2i, epp3, bppL]);
562 module HingeLeverOuterProfile(){
564 circleat(hppT, hp_r2);
565 circleat(hppB, hp_r2);
569 module HingeLeverInnerProfile(){
570 for (c = [hppT, hppB]) {
573 for (y=[0, c[1] - hppM[1]])
580 hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
581 translate(hinge_origin)
583 translate(-hinge_origin)
587 module HingePortion(x0,x1){
588 Flip_rhs() Flip_bot(1)
592 linear_extrude(height=x1-x0)
596 module CatchPortion(width){
597 translate([phone_width/2, 0,0])
599 linextr(-width/2, width/2)
604 AroundEdges(epp3[1], case_th_bottom, 1)
608 module Case(){ ////toplevel
613 // ledge (fixed keeper)
614 Flip_rhs(1-keeper_side) intersection(){
616 linear_extrude(height = phone_height + phone_cnr_rad * 2)
619 // outline of the whole case, to stop it protruding
620 translate([0,0, -25])
621 linear_extrude(height = 50)
624 circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
628 HingePortion(hex20, hex21) HingeBaseProfile();
632 Flip_rhs(keeper_side)
633 translate([0, -phone_cnr_rad, 0])
635 linear_extrude(height = phone_height + phone_cnr_rad * 2)
638 rectfromto([ -keeper_gap_x, -keeper_gap_z_bot ],
639 [ keeper_gap_x_holes, +keeper_gap_z_top ]);
643 RearCameraAperture();
645 // struts (invisible, because they're buried in the case)
646 Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
651 if (!($button_leg_only && enable_support))
654 linear_extrude(height= 20)
655 ButtonPlan($button_l, 0,1);
656 if ($button_leg_only)
658 translate([phone_width/2, -400, kppe[1]])
659 mirror([1-abs($rhsflip - keeper_side),0,0])
660 cube([400, 800, 50]);
663 translate([-400, -400, kppd[1]])
667 translate([0,0, -bppR[0]])
668 linear_extrude(height= 20)
669 ButtonPlan($button_l, 1,1);
672 // buildout for prop recess
674 linextr(-case_th_bottom, epp2i)
677 circleat([ prop_x_pos + dxs * prop_caserecess_buildout_r,
682 // apertures along top edge
683 CaseAperture(jack_pos, jack_dia, 8);
685 CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 8);
687 OrdinaryRearApertures();
691 // gaps for the lid's hinge arms
692 HingePortion(hex20 - hinge_x_arms_gap,
693 hex21 + hinge_x_arms_gap)
696 circle(r= hinge_r_arms_gap, $fn= 8);
699 // screw holes in the hinge arms
703 CatchPortion(catch_width + catch_side_gap*2)
710 linextr(-prop_recess_hw, +prop_recess_hw)
713 circleat(prcp2 + 20*(abs(zs) * [0,-1] +
714 zs * [1,0] * prop_caserecess_taper),
720 module Lid(){ ////toplevel
723 AroundEdges(lpp10[1], lpp13[1] - lpp10[1], 0)
731 linear_extrude(height= 20)
732 ButtonPlan($button_l, 1,0);
734 translate([0,0,-100])
735 linear_extrude(height= 200)
736 ButtonCoverProfile();
741 HingePortion(hex20, hex21) HingeLidProfile();
744 CatchPortion(catch_width)
747 Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
749 // screw holes in the hinge arms
754 module HingeLever(){ ////toplevel
756 // outer body, positive
757 HingePortion(hex22, hex22 + phone_width/2)
758 HingeLeverOuterProfile();
760 // space for the screws
761 HingePortion(hex23, hex24)
762 HingeLeverInnerProfile();
764 // bores for the screws
767 // space for the charging cable
769 Flip_hinge() MicroUSB();
773 module HingeLeverPrint(){ ////toplevel
778 module TestSelectLength(){
779 translate([-30, -200, -20])
780 cube([30 + 15, 250, 40]);
783 module TestLength(){ ////toplevel
790 module TestLengthRight(){ ////toplevel
798 module TestSelectWidth(){
799 translate([-30, -(phone_height - 25), -20])
804 module TestWidth(){ ////toplevel
811 module TestLidWidthPrint(){ ////toplevel
812 rotate([0,180.0]) intersection(){
818 module TestSelectRearAperture(){
822 cube([42, 2, 1], center=true);
826 module TestSelectCamera(){
828 TestSelectRearAperture()
829 RearCameraAperture();
830 cube([0.1, 50, 0.1]);
834 module TestSelectOrdinaryRearApertures(){
835 TestSelectRearAperture()
836 OrdinaryRearApertures();
839 module TestCamera(){ ////toplevel
846 module TestLidByCamera(){ ////toplevel
853 module TestLidByCameraPrint(){ ////toplevel
854 rotate([180,0,0]) TestLidByCamera();
857 module DemoByCamera(){ ////toplevel
858 color("blue") TestLidByCamera();
859 color("red") TestCamera();
862 module OneKeeper(){ ////toplevel
863 translate([0, -phone_cnr_rad, 0])
865 linear_extrude(height = phone_height - phone_cnr_rad * 2)
869 module OneKeeperPrint(){ ////toplevel
874 module LidPrint(){ ////toplevel
879 module TestSelectPropRecesses(posns){
881 translate([phone_width/2, -phone_height]){
882 square([ 3, 500 ], center=true);
885 for (dy=[ -prp5[0], -prp2[0] ])
887 square([prop_main_width+5, 5], center=true);
892 module TestSelectFrame(){
893 include = [1,-1] * (epp2i[0] + 4);
896 cube(1000, center=true);
897 translate([0,0, -100])
898 linear_extrude(height=200)
899 rectfromto(include, inside_br - include);
903 module TestSelectLidFrame(){
905 TestSelectPropRecesses(prop_lid_posns);
908 module TestFrameCase(){ ////toplevel
914 TestSelectOrdinaryRearApertures();
919 module TestFrameLidPrint(){ ////toplevel
920 rotate([0,180,0]) intersection(){
922 TestSelectLidFrame();
926 module ButtonPlanForDemo(z, deep, cut){
928 ButtonPlan(8, deep, cut);
931 module HingeScrews(){
932 Flip_rhs() Flip_bot(1){
933 for (c= [ hppT, hppB ])
939 cylinder( r= hingescrew_shaft_dia/2,
940 h = hingescrew_shaft_len+0.2 );
943 cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
948 module DemoFrame(){ ////toplevel
949 color("red") TestFrameCase();
950 color("blue") intersection(){ Lid(); TestSelectLidFrame(); }
951 color("black") HingeScrews();
955 module DemoHingedFrame(){ ///toplevel
956 color("red") TestFrameCase();
957 translate([0,0, -2*hp_k])
958 color("blue") intersection(){ Lid(); TestSelectLidFrame(); }
961 color("orange") HingeLever();
962 color("black") HingeScrews();
966 module DemoHinge(){ ////toplevel
968 translate([0,0, -hp_k*3])
972 module DemoProfiles(){ ////toplevel
976 translate([0,0,-1]) color("black") KeeperProfile(1);
982 demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
984 color("blue") ButtonCoverProfile();
986 rectfromto(bppQ, demopoint_QR);
987 rectfromto(bppR, demopoint_QR);
992 color("black") ButtonPlanForDemo(-2, 0,1);
993 color("red" ) ButtonPlanForDemo(-4, 1,1);
994 color("blue") ButtonPlanForDemo(-6, 1,0);
997 translate([0, -30]) {
1000 color("blue") HingeLidProfile();
1001 color("red") HingeBaseProfile();
1002 color("black") translate([0,0,-2]) HingeLeverOuterProfile();
1003 color("orange") translate([0,0,-1]) HingeLeverInnerProfile();
1006 translate([20,-30]) {
1009 //translate([0,0,1]) CatchCutProfile();
1010 color("blue") CatchCatchProfile();
1011 color("red") difference(){ EdgeProfile(); CatchCutProfile(); }