5 phone = [ 75.0, 145.0 ];
7 bumper = [ 0.250, -0.025 ];
8 // ^ One side. Overall size is increased by twice this.
9 // If no bumpers, is the gap around the phone.
15 button_cutout_depth = 9;
17 phone_edge_thick = 9.0;
18 phone_total_thick = 12.0;
19 phone_backside_slope_inner = 1.5; // larger means shallower
20 phone_backside_slope_outer = 1.0; // larger means shallower
22 camera_pos_tl = [ 6.450, 12.750 ]; // measured from tl corner
23 camera_pos_br = [ 22.300, 37.600 ]; // tl/br as seen from back
25 jack_pos = [ 14.38, 7.96 ];
26 jack_dia = 10.64 + .5; // some jack I had lying around
28 noisecancelmic_pos = [ 19.54, 7.37 ]; // from rhs
29 noisecancelmic_dia = 4.00;
31 //fingerpushhole_dias = [ 15, 18 ];
32 fingerpushhole_dias = [];
34 rearspeaker_pos_bl = [ 12.64, 18.72 ];
35 rearspeaker_size = [ 3.76, 7.36 ];
37 microusb_above = 3.27 - 0.25;
39 microusb_width = 16.12 + 1.25;
46 case_struts_count = 6;
47 case_struts_solid_below = 1.00;
48 case_struts_solid_above = 0.75;
49 case_struts_width = 0.10;
53 keeper_inner_width = 2.75;
54 keeper_inner_height = 2.75;
55 keeper_slant_slope = 2; // larger means steeper
57 keeper_gap_z_top = 0.25;
58 keeper_gap_z_bot = 0.75;
60 keeper_gap_x_holes = 0.75;
62 keeper_side = 0; // 0 = lhs; 1 = rhs
73 foldover_lever_gap = 0.50;
75 hingescrew_shaft_dia = 2.0 + 0.25; // M2 x 12mm machine screw
76 hingescrew_shaft_len = 12;
77 hingescrew_nut_thick = 1.93 + 0.20; // incl. washer
78 hingescrew_nut_dia = 4.72 + 0.50; // washer, actually
79 hingescrew_head_th = 1.38 + 0.75;
80 hingescrew_head_dia = 3.92;
81 lever_cover_th = 0.75;
88 buttonishleg_default_l_is_fudge = 10;
90 hinge_base_slope = 1.5; // bigger is steeper
92 strut_min_at_end = 1.5;
95 hinge_x_postscrew_gap = 0.75;
96 hinge_x_arms_gap = 0.35;
97 hinge_r_arms_gap = 0.55;
99 rearspeaker_gap = [ 2.0, 2.0 ]; // each side
103 catch_thickness = 1.0;
104 catch_side_gap = 0.75; // each side
108 catch_finger_height = 1.5;
109 catch_finger_depth = 2.5;
111 // ---------- calculated ----------
113 phone_width = (phone + bumper*2)[0];
114 phone_height = (phone + bumper*2)[1];
116 inside_br = [phone_width, -phone_height];
118 //echo(camera_pos_tl + bumper,
119 // camera_pos_br + bumper);
121 // ----- could be changed -----
122 lid_buttoncover_gap = lid_gap_x;
123 lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
125 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
127 //lid_lip_overlap_width xxx bad name = ;
128 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
131 epp1 = [0, -phone_edge_thick];
132 epp2i = epp1 + phone_backside_slope_thick * [ phone_backside_slope_inner, -1 ];
133 epp2o = epp1 + phone_backside_slope_thick * [ phone_backside_slope_outer, -1 ];
134 epp3 = epp2i + [10, 0];
135 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
136 epp4 = epp5 + [-1,0] * case_th_side;
139 kppd = kppe + [1,0] * keeper_inner_width;
140 kppc = kppd + [0,1] * keeper_th_z;
141 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
142 kppf = kppe - [0,1] * keeper_inner_height;
143 kppa = [ kppb[0], kppf[1] ];
145 lpp10 = [ epp5[0] + lid_gap_x, kppc[1] + lid_gap_z ];
146 lpp11 = [ lpp10[0], epp5[1] + lid_gap_z ];
148 lp_r12 = case_th_lid - (lpp11[1] - lpp10[1]);
150 lpp12 = [ epp4[0] + lp_r12, lpp11[1] ];
151 lpp13 = [ lpp12[0], lpp12[1] + lp_r12 ];
155 bppN = [ 0.5 * (epp0[0] + epp4[0]), bppM[1] ];
156 bppR = [ bppN[0] + lid_buttoncover_gap, -button_cutout_depth ];
157 bppS = [ epp1[0], bppR[1] ];
158 bppQ = [ bppM[0], bppR[1] - lid_buttoncover_overlap ];
159 bppP = bppQ + [0,1] * lid_buttoncover_gap;
160 bppO = [ bppN[0], bppP[1] ];
161 bppL = lpp10 + [5,0];
162 bppK = [ bppL[0], bppN[1] ];
163 bppJ = [ bppN[0], bppL[1] ];
166 hp_rn = hingescrew_nut_dia/2;
167 hp_r2_min = hp_rn + lever_cover_th;
168 hp_rs = hingescrew_shaft_dia/2;
169 hp_r1_min = hp_rs + hingemount_th;
171 hp_r1 = max(hp_r1_min, hp_r2_min);
175 hppS = epp2o + [0,-1] * case_th_bottom;
176 hp_k = 0.5 * (hppU[1] - hppS[1] + foldover_gap);
178 hppM = [ epp4[0] - foldover_lever_gap - hp_r2,
179 0.5 * (hppU + hppS)[1] ];
180 hppT = [ hppM[0], hppU[1] - hp_r1 ];
181 hppB = hppT + [0,-1] * hp_k;
183 hppE_y = epp2o[1] - case_th_bottom + hp_r1;
184 hppE_x = hppB[0] + (hppB[1] - hppE_y) * hinge_base_slope;
185 hppE = [ hppE_x, hppE_y ];
187 // hinge elevation x coords
189 hingescrew_portion_len =
190 0.5* (hingescrew_shaft_len - hingescrew_nut_thick - hinge_x_gap);
192 hex20 = max(epp2o[0],
194 kppd[0] + hingescrew_head_th + keeper_gap_x_holes);
195 hex21 = hex20 + hingescrew_portion_len;
196 hex22 = hex21 + hinge_x_gap;
197 hex23 = hex22 + hingescrew_portion_len
198 - hingescrew_nut_thick; // bodge, need to divvy this up more sensibly
199 hex24 = hex20 + hingescrew_shaft_len + hinge_x_postscrew_gap;
200 echo(hex20, hex21, hex22, hex23, hex24);
201 echo(hingescrew_portion_len);
205 cppJ = [ epp4[0] + catch_thickness, lpp10[1] ];
206 cppA = cppJ + [lid_gap_x, -lid_gap_z];
207 cppB = [ epp0[0], cppA[1] ];
208 cppP = [ epp4[0], cppJ[1] ];
210 cppS = cppJ + [0,-1] * catch_len;
211 cppD = [ cppA[0], cppS[1] + catch_slop ];
212 cppC = [ cppB[0], cppD[1] ];
213 cppT = cppS + [1,0] * catch_depth;
214 cppU = cppT + [0,-1] * catch_height;
215 cppV = [ cppS[0], cppU[1] - catch_depth ];
217 cppR = 0.5*(cppP + cppJ);
219 cp_rQ = 0.5 * (cppJ[0] - cppP[0]);
221 cppV[1] - (catch_finger_height - cp_rQ) ];
222 cppF = [ cppV[0] + catch_finger_depth, cppC[1] ];
224 // ---------- modules ----------
226 module KeeperProfile(slant=0){
227 use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
228 polygon([use_e, kppd, kppc, kppb, kppa, kppf]);
231 module EdgeProfile(){
234 translate(epp3) square(case_th_bottom*2, center=true);
235 circleat(epp2o, r=case_th_bottom);
236 circleat(epp1, r=case_th_side);
237 rectfromto(epp0, epp4);
239 polygon([ epp5 + [0,10],
246 module LidEdgeProfile(){
255 circleat(lpp12, r=lp_r12);
256 rectfromto( lpp12 + [-10, 0],
257 lpp12 + [+10, +10] );
261 module ButtonCoverProfile(){
263 polygon([ bppM, bppP, bppO, bppJ, bppL, bppK ]);
271 module ButtonPlan(l, deep, cut){
273 (cut ? 0 : lid_buttoncover_gap);
276 (deep ? lid_buttoncover_overlap : 0);
278 C = [0,0]; // by definition
282 B0 = C + [0,-1] * button_cutout_depth;
283 B1 = B0 + [0,1] * epsilon;
285 r0 = 0.5 * (T[1] - B0[1]);
286 A = [ -(l + button_l_fudge)/2 + r0, 0.5 * (T[1] + B0[1]) ];
287 H = A + [0,-1] * delta;
293 E1 = E0 + [1,0] * epsilon;
295 I0 = [ E0[0], H[1] ];
296 I1 = [ E1[0], H[1] ];
299 for (m=[0,1]) mirror([m,0])
300 circleat(H, r0 - epsilon);
302 for (m=[0,1]) mirror([m,0]) {
312 circleat(D, r0 + epsilon);
317 module CatchCatchProfile(){
319 for (c=[ cppR, cppQ ])
323 circleat(lpp12, lp_r12);
324 circleat(lpp12 + [5,0], lp_r12);
325 rectfromto(cppP, cppP + [5,0.1]);
327 polygon([cppJ, cppS, cppT, cppU, cppV, cppQ, cppR]);
330 module CatchCutProfile(){
342 module Flip_rhs(yn=[0,1]) {
344 translate([phone_width/2, 0, 0])
345 mirror([$rhsflip,0,0])
346 translate([-phone_width/2, 0, 0])
351 module Flip_bot(yn=[0,1]) {
353 translate([0, -phone_height/2, 0])
354 mirror([0, $botflip, 0])
355 translate([0, phone_height/2, 0])
360 module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
363 translate([0, -phone_cnr_rad, 0])
365 linear_extrude(height = phone_height - phone_cnr_rad*2)
369 Flip_rhs() Flip_bot() {
370 translate([+1,-1] * phone_cnr_rad)
375 translate([-1,0] * phone_cnr_rad)
377 rectfromto([0,-20],[10,20]);
379 translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
385 translate([ phone_width - phone_cnr_rad, 0,0 ])
387 linear_extrude(height = phone_width - phone_cnr_rad*2)
391 translate([0,0, fill_zstart])
392 mirror([0,0, fill_downwards])
393 linear_extrude(height = fill_th)
394 rectfromto([+1,-1] * phone_cnr_rad,
395 [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
398 module CaseAperture(pos, dia, $fn) {
400 translate([ pos[0] + bumper[0],
403 rotate([-90, theta, 0])
404 cylinder(r = dia/2 / cos(theta),
408 module SideButton(y, y_ref_sign, l){
410 // +1 measured from top of actual phone to top of button
411 // -1 measured from bottom of actual phone to bottom of button
412 // 0 y is centre of button in coordinate system
414 eff_y = y_ref_sign > 0 ? -bumper [1] -y -l/2 :
415 y_ref_sign < 0 ? (-phone -bumper)[1] +y +l/2 :
418 translate([0, eff_y, 0])
422 module LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
423 $button_leg_only = true;
424 SideButton(y, y_ref_sign, l) children();
428 Flip_rhs(1) SideButton(15.580, +1, 8.9) children(); // power
429 Flip_rhs(1) SideButton(48.700, -1, 8.920) children(); // camera
430 Flip_rhs(0) SideButton(30.800, +1, 21.96) children(); // volume
431 Flip_rhs( ) LidButtonishLeg(14, -1) children();
432 // Flip_rhs(0) LidButtonishLeg(20, +1, 20) children();
435 module Struts(x_start, z_min, th){
436 // if th is negative, starts at z_min and works towards -ve z
437 // and object should then be printed other way up
438 for (i= [1 : 1 : case_struts_count]) {
442 mirror([0,0, th<0 ? 1 : 0])
444 -phone_height * i / (case_struts_count+1),
445 case_struts_solid_below])
446 linear_extrude(height= abs(th)
447 -(case_struts_solid_below+case_struts_solid_above))
448 rectfromto([ x_start, -0.5 * case_struts_width ],
449 [ phone_width - x_start, +0.5 * case_struts_width ]);
453 module OrdinaryRearAperture(rhs,bot, pos){
454 Flip_rhs(rhs) Flip_bot(bot)
457 translate(pos + bumper)
465 linextr(-epp2i[0], 60)
466 translate([0.5 * phone_width, 0, 0])
467 rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
468 [+microusb_width/2, epp0[1] + -microusb_above]);
472 module OrdinaryRearApertures(){
474 OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
475 rectfromto(-rearspeaker_gap,
476 rearspeaker_size + rearspeaker_gap);
478 // finger hole to remove phone
479 if (len(fingerpushhole_dias))
480 OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
482 scale(fingerpushhole_dias)
486 module RearCameraAperture(){
489 linear_extrude(height = 20)
492 rectfromto(camera_pos_tl, camera_pos_br);
495 module HingeLidProfile(){
497 circleat(hppT, hp_r1);
498 circleat(lpp12, lp_r12);
506 module HingeBaseProfile(){
509 circleat(hppB, hp_r1);
510 circleat(hppE, hp_r1);
511 circleat(epp2o, case_th_bottom);
512 circleat(hppB + [10,0], hp_r1);
514 polygon([epp5, epp1, epp2i, epp3, bppL]);
518 module HingeLeverOuterProfile(){
520 circleat(hppT, hp_r2);
521 circleat(hppB, hp_r2);
525 module HingeLeverInnerProfile(){
526 for (c = [hppT, hppB]) {
529 for (y=[0, c[1] - hppM[1]])
536 hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
537 translate(hinge_origin)
539 translate(-hinge_origin)
543 module HingePortion(x0,x1){
544 Flip_rhs() Flip_bot(1)
548 linear_extrude(height=x1-x0)
552 module CatchPortion(width){
553 translate([phone_width/2, 0,0])
555 linextr(-width/2, width/2)
560 AroundEdges(epp3[1], case_th_bottom, 1)
564 module Case(){ ////toplevel
569 // ledge (fixed keeper)
570 Flip_rhs(1-keeper_side) intersection(){
572 linear_extrude(height = phone_height + phone_cnr_rad * 2)
575 // outline of the whole case, to stop it protruding
576 translate([0,0, -25])
577 linear_extrude(height = 50)
580 circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
584 HingePortion(hex20, hex21) HingeBaseProfile();
588 Flip_rhs(keeper_side)
589 translate([0, -phone_cnr_rad, 0])
591 linear_extrude(height = phone_height + phone_cnr_rad * 2)
594 rectfromto([ -keeper_gap_x, -keeper_gap_z_bot ],
595 [ keeper_gap_x_holes, +keeper_gap_z_top ]);
599 RearCameraAperture();
601 // struts (invisible, because they're buried in the case)
602 Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
607 if (!($button_leg_only && enable_support))
610 linear_extrude(height= 20)
611 ButtonPlan($button_l, 0,1);
612 if ($button_leg_only)
614 translate([phone_width/2, -400, kppe[1]])
615 mirror([1-abs($rhsflip - keeper_side),0,0])
616 cube([400, 800, 50]);
619 translate([-400, -400, kppd[1]])
623 translate([0,0, -bppR[0]])
624 linear_extrude(height= 20)
625 ButtonPlan($button_l, 1,1);
629 // apertures along top edge
630 CaseAperture(jack_pos, jack_dia, 8);
632 CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 8);
634 OrdinaryRearApertures();
638 // gaps for the lid's hinge arms
639 HingePortion(hex20 - hinge_x_arms_gap,
640 hex21 + hinge_x_arms_gap)
643 circle(r= hinge_r_arms_gap, $fn= 8);
646 // screw holes in the hinge arms
650 CatchPortion(catch_width + catch_side_gap*2)
655 module Lid(){ ////toplevel
658 AroundEdges(lpp10[1], lpp13[1] - lpp10[1], 0)
666 linear_extrude(height= 20)
667 ButtonPlan($button_l, 1,0);
669 translate([0,0,-100])
670 linear_extrude(height= 200)
671 ButtonCoverProfile();
676 HingePortion(hex20, hex21) HingeLidProfile();
679 CatchPortion(catch_width)
682 Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
684 // screw holes in the hinge arms
689 module HingeLever(){ ////toplevel
691 // outer body, positive
692 HingePortion(hex22, hex22 + phone_width/2)
693 HingeLeverOuterProfile();
695 // space for the screws
696 HingePortion(hex23, hex24)
697 HingeLeverInnerProfile();
699 // bores for the screws
702 // space for the charging cable
704 Flip_hinge() MicroUSB();
708 module HingeLeverPrint(){ ////toplevel
713 module TestSelectLength(){
714 translate([-30, -200, -20])
715 cube([30 + 15, 250, 40]);
718 module TestLength(){ ////toplevel
725 module TestLengthRight(){ ////toplevel
733 module TestSelectWidth(){
734 translate([-30, -(phone_height - 25), -20])
739 module TestWidth(){ ////toplevel
746 module TestLidWidthPrint(){ ////toplevel
747 rotate([0,180.0]) intersection(){
753 module TestSelectRearAperture(){
757 cube([42, 2, 1], center=true);
761 module TestSelectCamera(){
763 TestSelectRearAperture()
764 RearCameraAperture();
765 cube([0.1, 50, 0.1]);
769 module TestSelectOrdinaryRearApertures(){
770 TestSelectRearAperture()
771 OrdinaryRearApertures();
774 module TestCamera(){ ////toplevel
781 module TestLidByCamera(){ ////toplevel
788 module TestLidByCameraPrint(){ ////toplevel
789 rotate([180,0,0]) TestLidByCamera();
792 module DemoByCamera(){ ////toplevel
793 color("blue") TestLidByCamera();
794 color("red") TestCamera();
797 module OneKeeper(){ ////toplevel
798 translate([0, -phone_cnr_rad, 0])
800 linear_extrude(height = phone_height - phone_cnr_rad * 2)
804 module OneKeeperPrint(){ ////toplevel
809 module LidPrint(){ ////toplevel
814 module TestSelectFrame(){
815 include = [1,-1] * (epp2i[0] + 4);
818 cube(1000, center=true);
819 translate([0,0, -100])
820 linear_extrude(height=200)
821 rectfromto(include, inside_br - include);
825 module TestFrameCase(){ ////toplevel
831 TestSelectOrdinaryRearApertures();
836 module TestFrameLidPrint(){ ////toplevel
837 rotate([0,180,0]) intersection(){
843 module ButtonPlanForDemo(z, deep, cut){
845 ButtonPlan(8, deep, cut);
848 module HingeScrews(){
849 Flip_rhs() Flip_bot(1){
850 for (c= [ hppT, hppB ])
856 cylinder( r= hingescrew_shaft_dia/2,
857 h = hingescrew_shaft_len+0.2 );
860 cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
865 module DemoFrame(){ ////toplevel
866 color("red") TestFrameCase();
867 color("blue") intersection(){ Lid(); TestSelectFrame(); }
868 color("black") HingeScrews();
872 module DemoHingedFrame(){ ///toplevel
873 color("red") TestFrameCase();
874 translate([0,0, -2*hp_k])
875 color("blue") intersection(){ Lid(); TestSelectFrame(); }
878 color("orange") HingeLever();
879 color("black") HingeScrews();
883 module DemoHinge(){ ////toplevel
885 translate([0,0, -hp_k*3])
889 module DemoProfiles(){ ////toplevel
893 translate([0,0,-1]) color("black") KeeperProfile(1);
899 demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
901 color("blue") ButtonCoverProfile();
903 rectfromto(bppQ, demopoint_QR);
904 rectfromto(bppR, demopoint_QR);
909 color("black") ButtonPlanForDemo(-2, 0,1);
910 color("red" ) ButtonPlanForDemo(-4, 1,1);
911 color("blue") ButtonPlanForDemo(-6, 1,0);
914 translate([0, -30]) {
917 color("blue") HingeLidProfile();
918 color("red") HingeBaseProfile();
919 color("black") translate([0,0,-2]) HingeLeverOuterProfile();
920 color("orange") translate([0,0,-1]) HingeLeverInnerProfile();
923 translate([20,-30]) {
926 //translate([0,0,1]) CatchCutProfile();
927 color("blue") CatchCatchProfile();
928 color("red") difference(){ EdgeProfile(); CatchCutProfile(); }