5 phone = [ 75.0, 145.0 ];
8 prop_buildout_less = 3;
10 prop_angles = [ 15, 30, 45, 60 ];
12 bumper = [ 0.250, -0.025 ];
13 // ^ One side. Overall size is increased by twice this.
14 // If no bumpers, is the gap around the phone.
20 button_cutout_depth = 9;
22 phone_edge_thick = 9.0;
23 phone_total_thick = 12.0;
24 phone_backside_slope_inner = 1.5; // larger means shallower
25 phone_backside_slope_outer = 1.0; // larger means shallower
27 camera_pos_tl = [ 6.450, 12.750 ]; // measured from tl corner
28 camera_pos_br = [ 22.300, 37.600 ]; // tl/br as seen from back
30 jack_pos = [ 14.38, 7.96 ];
31 jack_dia = 10.64 + .5; // some jack I had lying around
33 noisecancelmic_pos = [ 19.54, 7.37 ]; // from rhs
34 noisecancelmic_dia = 4.00;
36 //fingerpushhole_dias = [ 15, 18 ];
37 fingerpushhole_dias = [];
39 rearspeaker_pos_bl = [ 12.64, 18.72 ];
40 rearspeaker_size = [ 3.76, 7.36 ];
42 microusb_above = 3.27 - 0.25;
44 microusb_width = 16.12 + 1.25;
51 case_struts_count = 6;
52 case_struts_solid_below = 1.00;
53 case_struts_solid_above = 0.75;
54 case_struts_width = 0.10;
58 keeper_inner_width = 2.75;
59 keeper_inner_height = 2.75;
60 keeper_slant_slope = 2; // larger means steeper
62 keeper_gap_z_top = 0.25;
63 keeper_gap_z_bot = 0.75;
65 keeper_gap_x_holes = 0.75;
67 keeper_side = 0; // 0 = lhs; 1 = rhs
78 foldover_lever_gap = 0.50;
80 hingescrew_shaft_dia = 2.0 + 0.25; // M2 x 12mm machine screw
81 hingescrew_shaft_len = 12;
82 hingescrew_nut_thick = 1.93 + 0.20; // incl. washer
83 hingescrew_nut_dia = 4.72 + 0.50; // washer, actually
84 hingescrew_head_th = 1.38 + 0.75;
85 hingescrew_head_dia = 3.92;
86 lever_cover_th = 0.75;
93 buttonishleg_default_l_is_fudge = 10;
95 hinge_base_slope = 1.5; // bigger is steeper
97 strut_min_at_end = 1.5;
100 hinge_x_postscrew_gap = 0.75;
101 hinge_x_arms_gap = 0.35;
102 hinge_r_arms_gap = 0.55;
104 rearspeaker_gap = [ 2.0, 2.0 ]; // each side
108 catch_thickness = 1.0;
109 catch_side_gap = 0.75; // each side
113 catch_finger_height = 1.5;
114 catch_finger_depth = 2.5;
116 prop_recess_under = 0.50;
117 prop_recess_slop = 0.200; // each side
122 prop_side_gap = 0.75; // each side
123 prop_caserecess_behind = 0.75;
124 prop_caserecess_taper = 0.25; // each side
126 // ---------- calculated ----------
128 phone_width = (phone + bumper*2)[0];
129 phone_height = (phone + bumper*2)[1];
131 inside_br = [phone_width, -phone_height];
133 //echo(camera_pos_tl + bumper,
134 // camera_pos_br + bumper);
136 // ----- could be changed -----
137 lid_buttoncover_gap = lid_gap_x;
138 lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
140 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
142 //prop_lidrecess_depth = case_th_lid - prop_recess_under;
144 //prop_nose_len = case_th_lid - prop_recess_under;
145 //prop_recess_slope = tan(prop_max_angle); // bigger means steeper
146 //prop_recess_width = prop_main_th / cos(prop_max_angle) + prop_backfwd_gap;
149 //lid_lip_overlap_width xxx bad name = ;
150 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
153 epp1 = [0, -phone_edge_thick];
154 epp2i = epp1 + phone_backside_slope_thick * [ phone_backside_slope_inner, -1 ];
155 epp2o = epp1 + phone_backside_slope_thick * [ phone_backside_slope_outer, -1 ];
156 epp3 = epp2i + [10, 0];
157 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
158 epp4 = epp5 + [-1,0] * case_th_side;
161 kppd = kppe + [1,0] * keeper_inner_width;
162 kppc = kppd + [0,1] * keeper_th_z;
163 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
164 kppf = kppe - [0,1] * keeper_inner_height;
165 kppa = [ kppb[0], kppf[1] ];
167 lpp10 = [ epp5[0] + lid_gap_x, kppc[1] + lid_gap_z ];
168 lpp11 = [ lpp10[0], epp5[1] + lid_gap_z ];
170 lp_r12 = case_th_lid - (lpp11[1] - lpp10[1]);
172 lpp12 = [ epp4[0] + lp_r12, lpp11[1] ];
173 lpp13 = [ lpp12[0], lpp12[1] + lp_r12 ];
175 case_bottom_z = epp2o[1] - case_th_bottom;
179 bppN = [ 0.5 * (epp0[0] + epp4[0]), bppM[1] ];
180 bppR = [ bppN[0] + lid_buttoncover_gap, -button_cutout_depth ];
181 bppS = [ epp1[0], bppR[1] ];
182 bppQ = [ bppM[0], bppR[1] - lid_buttoncover_overlap ];
183 bppP = bppQ + [0,1] * lid_buttoncover_gap;
184 bppO = [ bppN[0], bppP[1] ];
185 bppL = lpp10 + [5,0];
186 bppK = [ bppL[0], bppN[1] ];
187 bppJ = [ bppN[0], bppL[1] ];
190 hp_rn = hingescrew_nut_dia/2;
191 hp_r2_min = hp_rn + lever_cover_th;
192 hp_rs = hingescrew_shaft_dia/2;
193 hp_r1_min = hp_rs + hingemount_th;
195 hp_r1 = max(hp_r1_min, hp_r2_min);
199 hppS = epp2o + [0,-1] * case_th_bottom;
200 hp_k = 0.5 * (hppU[1] - hppS[1] + foldover_gap);
202 hppM = [ epp4[0] - foldover_lever_gap - hp_r2,
203 0.5 * (hppU + hppS)[1] ];
204 hppT = [ hppM[0], hppU[1] - hp_r1 ];
205 hppB = hppT + [0,-1] * hp_k;
207 hppE_y = epp2o[1] - case_th_bottom + hp_r1;
208 hppE_x = hppB[0] + (hppB[1] - hppE_y) * hinge_base_slope;
209 hppE = [ hppE_x, hppE_y ];
211 // hinge elevation x coords
213 hingescrew_portion_len =
214 0.5* (hingescrew_shaft_len - hingescrew_nut_thick - hinge_x_gap);
216 hex20 = max(epp2o[0],
218 kppd[0] + hingescrew_head_th + keeper_gap_x_holes);
219 hex21 = hex20 + hingescrew_portion_len;
220 hex22 = hex21 + hinge_x_gap;
221 hex23 = hex22 + hingescrew_portion_len
222 - hingescrew_nut_thick; // bodge, need to divvy this up more sensibly
223 hex24 = hex20 + hingescrew_shaft_len + hinge_x_postscrew_gap;
224 //echo(hex20, hex21, hex22, hex23, hex24);
225 //echo(hingescrew_portion_len);
229 cppJ = [ epp4[0] + catch_thickness, lpp10[1] ];
230 cppA = cppJ + [lid_gap_x, -lid_gap_z];
231 cppB = [ epp0[0], cppA[1] ];
232 cppP = [ epp4[0], cppJ[1] ];
234 cppS = cppJ + [0,-1] * catch_len;
235 cppD = [ cppA[0], cppS[1] + catch_slop ];
236 cppC = [ cppB[0], cppD[1] ];
237 cppT = cppS + [1,0] * catch_depth;
238 cppU = cppT + [0,-1] * catch_height;
239 cppV = [ cppS[0], cppU[1] - catch_depth ];
241 cppR = 0.5*(cppP + cppJ);
243 cp_rQ = 0.5 * (cppJ[0] - cppP[0]);
245 cppV[1] - (catch_finger_height - cp_rQ) ];
246 cppF = [ cppV[0] + catch_finger_depth, cppC[1] ];
250 prop_recess_hw = 0.5 * prop_main_width + prop_side_gap;
252 prc_r1 = prop_end_dia/2;
253 prc_r3 = prc_r1 + prop_recess_slop;
255 prcp2 = [ epp4[0] + prop_buildout_less,
258 prop_caserecess_buildout_r = prcp2[0] - epp2o[0];
262 prcp1 = [ prcp2[0] + prop_caserecess_behind + prc_r3,
265 // ---------- modules ----------
267 module KeeperProfile(slant=0){
268 use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
269 polygon([use_e, kppd, kppc, kppb, kppa, kppf]);
272 module EdgeProfile(){
275 translate(epp3) square(case_th_bottom*2, center=true);
276 circleat(epp2o, r=case_th_bottom);
277 circleat(epp1, r=case_th_side);
278 rectfromto(epp0, epp4);
280 polygon([ epp5 + [0,10],
287 module LidEdgeProfile(){
296 circleat(lpp12, r=lp_r12);
297 rectfromto( lpp12 + [-10, 0],
298 lpp12 + [+10, +10] );
302 module ButtonCoverProfile(){
304 polygon([ bppM, bppP, bppO, bppJ, bppL, bppK ]);
312 module ButtonPlan(l, deep, cut){
314 (cut ? 0 : lid_buttoncover_gap);
317 (deep ? lid_buttoncover_overlap : 0);
319 C = [0,0]; // by definition
323 B0 = C + [0,-1] * button_cutout_depth;
324 B1 = B0 + [0,1] * epsilon;
326 r0 = 0.5 * (T[1] - B0[1]);
327 A = [ -(l + button_l_fudge)/2 + r0, 0.5 * (T[1] + B0[1]) ];
328 H = A + [0,-1] * delta;
334 E1 = E0 + [1,0] * epsilon;
336 I0 = [ E0[0], H[1] ];
337 I1 = [ E1[0], H[1] ];
340 for (m=[0,1]) mirror([m,0])
341 circleat(H, r0 - epsilon);
343 for (m=[0,1]) mirror([m,0]) {
353 circleat(D, r0 + epsilon);
358 module CatchCatchProfile(){
360 for (c=[ cppR, cppQ ])
364 circleat(lpp12, lp_r12);
365 circleat(lpp12 + [5,0], lp_r12);
366 rectfromto(cppP, cppP + [5,0.1]);
368 polygon([cppJ, cppS, cppT, cppU, cppV, cppQ, cppR]);
371 module CatchCutProfile(){
383 module Flip_rhs(yn=[0,1]) {
385 translate([phone_width/2, 0, 0])
386 mirror([$rhsflip,0,0])
387 translate([-phone_width/2, 0, 0])
392 module Flip_bot(yn=[0,1]) {
394 translate([0, -phone_height/2, 0])
395 mirror([0, $botflip, 0])
396 translate([0, phone_height/2, 0])
401 module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
404 translate([0, -phone_cnr_rad, 0])
406 linear_extrude(height = phone_height - phone_cnr_rad*2)
410 Flip_rhs() Flip_bot() {
411 translate([+1,-1] * phone_cnr_rad)
416 translate([-1,0] * phone_cnr_rad)
418 rectfromto([0,-20],[10,20]);
420 translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
426 translate([ phone_width - phone_cnr_rad, 0,0 ])
428 linear_extrude(height = phone_width - phone_cnr_rad*2)
432 translate([0,0, fill_zstart])
433 mirror([0,0, fill_downwards])
434 linear_extrude(height = fill_th)
435 rectfromto([+1,-1] * phone_cnr_rad,
436 [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
439 module CaseAperture(pos, dia, $fn) {
441 translate([ pos[0] + bumper[0],
444 rotate([-90, theta, 0])
445 cylinder(r = dia/2 / cos(theta),
449 module SideButton(y, y_ref_sign, l){
451 // +1 measured from top of actual phone to top of button
452 // -1 measured from bottom of actual phone to bottom of button
453 // 0 y is centre of button in coordinate system
455 eff_y = y_ref_sign > 0 ? -bumper [1] -y -l/2 :
456 y_ref_sign < 0 ? (-phone -bumper)[1] +y +l/2 :
459 translate([0, eff_y, 0])
463 module LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
464 $button_leg_only = true;
465 SideButton(y, y_ref_sign, l) children();
469 Flip_rhs(1) SideButton(15.580, +1, 8.9) children(); // power
470 Flip_rhs(1) SideButton(48.700, -1, 8.920) children(); // camera
471 Flip_rhs(0) SideButton(30.800, +1, 21.96) children(); // volume
472 Flip_rhs( ) LidButtonishLeg(14, -1) children();
473 // Flip_rhs(0) LidButtonishLeg(20, +1, 20) children();
476 module Struts(x_start, z_min, th){
477 // if th is negative, starts at z_min and works towards -ve z
478 // and object should then be printed other way up
479 for (i= [1 : 1 : case_struts_count]) {
483 mirror([0,0, th<0 ? 1 : 0])
485 -phone_height * i / (case_struts_count+1),
486 case_struts_solid_below])
487 linear_extrude(height= abs(th)
488 -(case_struts_solid_below+case_struts_solid_above))
489 rectfromto([ x_start, -0.5 * case_struts_width ],
490 [ phone_width - x_start, +0.5 * case_struts_width ]);
494 module OrdinaryRearAperture(rhs,bot, pos){
495 Flip_rhs(rhs) Flip_bot(bot)
498 translate(pos + bumper)
506 linextr(-epp2i[0], 60)
507 translate([0.5 * phone_width, 0, 0])
508 rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
509 [+microusb_width/2, epp0[1] + -microusb_above]);
513 module OrdinaryRearApertures(){
515 OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
516 rectfromto(-rearspeaker_gap,
517 rearspeaker_size + rearspeaker_gap);
519 // finger hole to remove phone
520 if (len(fingerpushhole_dias))
521 OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
523 scale(fingerpushhole_dias)
527 module RearCameraAperture(){
530 linear_extrude(height = 20)
533 rectfromto(camera_pos_tl, camera_pos_br);
536 module HingeLidProfile(){
538 circleat(hppT, hp_r1);
539 circleat(lpp12, lp_r12);
547 module HingeBaseProfile(){
550 circleat(hppB, hp_r1);
551 circleat(hppE, hp_r1);
552 circleat(epp2o, case_th_bottom);
553 circleat(hppB + [10,0], hp_r1);
555 polygon([epp5, epp1, epp2i, epp3, bppL]);
559 module HingeLeverOuterProfile(){
561 circleat(hppT, hp_r2);
562 circleat(hppB, hp_r2);
566 module HingeLeverInnerProfile(){
567 for (c = [hppT, hppB]) {
570 for (y=[0, c[1] - hppM[1]])
577 hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
578 translate(hinge_origin)
580 translate(-hinge_origin)
584 module HingePortion(x0,x1){
585 Flip_rhs() Flip_bot(1)
589 linear_extrude(height=x1-x0)
593 module CatchPortion(width){
594 translate([phone_width/2, 0,0])
596 linextr(-width/2, width/2)
601 AroundEdges(epp3[1], case_th_bottom, 1)
605 module Case(){ ////toplevel
610 // ledge (fixed keeper)
611 Flip_rhs(1-keeper_side) intersection(){
613 linear_extrude(height = phone_height + phone_cnr_rad * 2)
616 // outline of the whole case, to stop it protruding
617 translate([0,0, -25])
618 linear_extrude(height = 50)
621 circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
625 HingePortion(hex20, hex21) HingeBaseProfile();
627 // buildout for prop recess
629 linextr(case_bottom_z, epp2i[1])
632 circleat([ prop_x_pos + dxs * prop_caserecess_buildout_r,
634 r = epp2o[0] - prcp2[0]);
639 Flip_rhs(keeper_side)
640 translate([0, -phone_cnr_rad, 0])
642 linear_extrude(height = phone_height + phone_cnr_rad * 2)
645 rectfromto([ -keeper_gap_x, -keeper_gap_z_bot ],
646 [ keeper_gap_x_holes, +keeper_gap_z_top ]);
650 RearCameraAperture();
652 // struts (invisible, because they're buried in the case)
653 Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
658 if (!($button_leg_only && enable_support))
661 linear_extrude(height= 20)
662 ButtonPlan($button_l, 0,1);
663 if ($button_leg_only)
665 translate([phone_width/2, -400, kppe[1]])
666 mirror([1-abs($rhsflip - keeper_side),0,0])
667 cube([400, 800, 50]);
670 translate([-400, -400, kppd[1]])
674 translate([0,0, -bppR[0]])
675 linear_extrude(height= 20)
676 ButtonPlan($button_l, 1,1);
681 // apertures along top edge
682 CaseAperture(jack_pos, jack_dia, 8);
684 CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 8);
686 OrdinaryRearApertures();
690 // gaps for the lid's hinge arms
691 HingePortion(hex20 - hinge_x_arms_gap,
692 hex21 + hinge_x_arms_gap)
695 circle(r= hinge_r_arms_gap, $fn= 8);
698 // screw holes in the hinge arms
702 CatchPortion(catch_width + catch_side_gap*2)
707 translate([prop_x_pos,0,0])
709 linextr(-prop_recess_hw, +prop_recess_hw)
712 for (d=[ [0,0], [0,-1], [+1,-1/prop_caserecess_taper] ])
713 circleat(prcp1 + 20*d,
719 module Lid(){ ////toplevel
722 AroundEdges(lpp10[1], lpp13[1] - lpp10[1], 0)
730 linear_extrude(height= 20)
731 ButtonPlan($button_l, 1,0);
733 translate([0,0,-100])
734 linear_extrude(height= 200)
735 ButtonCoverProfile();
740 HingePortion(hex20, hex21) HingeLidProfile();
743 CatchPortion(catch_width)
746 Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
748 // screw holes in the hinge arms
753 module HingeLever(){ ////toplevel
755 // outer body, positive
756 HingePortion(hex22, hex22 + phone_width/2)
757 HingeLeverOuterProfile();
759 // space for the screws
760 HingePortion(hex23, hex24)
761 HingeLeverInnerProfile();
763 // bores for the screws
766 // space for the charging cable
768 Flip_hinge() MicroUSB();
772 module HingeLeverPrint(){ ////toplevel
777 module TestSelectLength(){
778 translate([-30, -200, -20])
779 cube([30 + 15, 250, 40]);
782 module TestLength(){ ////toplevel
789 module TestLengthRight(){ ////toplevel
797 module TestSelectWidth(){
798 translate([-30, -(phone_height - 25), -20])
803 module TestWidth(){ ////toplevel
810 module TestLidWidthPrint(){ ////toplevel
811 rotate([0,180.0]) intersection(){
817 module TestSelectRearAperture(){
821 cube([42, 2, 1], center=true);
825 module TestSelectCamera(){
827 TestSelectRearAperture()
828 RearCameraAperture();
829 cube([0.1, 50, 0.1]);
833 module TestSelectOrdinaryRearApertures(){
834 TestSelectRearAperture()
835 OrdinaryRearApertures();
838 module TestCamera(){ ////toplevel
845 module TestLidByCamera(){ ////toplevel
852 module TestLidByCameraPrint(){ ////toplevel
853 rotate([180,0,0]) TestLidByCamera();
856 module DemoByCamera(){ ////toplevel
857 color("blue") TestLidByCamera();
858 color("red") TestCamera();
861 module OneKeeper(){ ////toplevel
862 translate([0, -phone_cnr_rad, 0])
864 linear_extrude(height = phone_height - phone_cnr_rad * 2)
868 module OneKeeperPrint(){ ////toplevel
873 module LidPrint(){ ////toplevel
878 module TestSelectPropRecesses(posns){
880 translate([phone_width/2, -phone_height]){
881 square([ 3, 500 ], center=true);
884 for (dy=[ -prp5[0], -prp2[0] ])
886 square([prop_main_width+5, 5], center=true);
891 module TestSelectFrame(){
892 include = [1,-1] * (epp2i[0] + 4);
895 cube(1000, center=true);
896 translate([0,0, -100])
897 linear_extrude(height=200)
898 rectfromto(include, inside_br - include);
902 module TestSelectLidFrame(){
904 TestSelectPropRecesses(prop_lid_posns);
907 module TestFrameCase(){ ////toplevel
913 TestSelectOrdinaryRearApertures();
918 module TestFrameLidPrint(){ ////toplevel
919 rotate([0,180,0]) intersection(){
921 TestSelectLidFrame();
925 module ButtonPlanForDemo(z, deep, cut){
927 ButtonPlan(8, deep, cut);
930 module HingeScrews(){
931 Flip_rhs() Flip_bot(1){
932 for (c= [ hppT, hppB ])
938 cylinder( r= hingescrew_shaft_dia/2,
939 h = hingescrew_shaft_len+0.2 );
942 cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
947 module DemoFrame(){ ////toplevel
948 color("red") TestFrameCase();
949 color("blue") intersection(){ Lid(); TestSelectLidFrame(); }
950 color("black") HingeScrews();
954 module DemoHingedFrame(){ ///toplevel
955 color("red") TestFrameCase();
956 translate([0,0, -2*hp_k])
957 color("blue") intersection(){ Lid(); TestSelectLidFrame(); }
960 color("orange") HingeLever();
961 color("black") HingeScrews();
965 module DemoHinge(){ ////toplevel
967 translate([0,0, -hp_k*3])
971 module DemoProfiles(){ ////toplevel
975 translate([0,0,-1]) color("black") KeeperProfile(1);
981 demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
983 color("blue") ButtonCoverProfile();
985 rectfromto(bppQ, demopoint_QR);
986 rectfromto(bppR, demopoint_QR);
991 color("black") ButtonPlanForDemo(-2, 0,1);
992 color("red" ) ButtonPlanForDemo(-4, 1,1);
993 color("blue") ButtonPlanForDemo(-6, 1,0);
996 translate([0, -30]) {
999 color("blue") HingeLidProfile();
1000 color("red") HingeBaseProfile();
1001 color("black") translate([0,0,-2]) HingeLeverOuterProfile();
1002 color("orange") translate([0,0,-1]) HingeLeverInnerProfile();
1005 translate([20,-30]) {
1008 //translate([0,0,1]) CatchCutProfile();
1009 color("blue") CatchCatchProfile();
1010 color("red") difference(){ EdgeProfile(); CatchCutProfile(); }