3 // Hard case for Fairphone 2
5 // Copyright 2018 Ian Jackson. There is NO WARRANTY.
6 // See below for full licensing and disclaimer.
10 // 1. You will want to git clone this repository.
14 // 3. use "make" to generate the necessary files:
16 // make -j8 fairphone-case.auto.scads `for f in \
21 // ; do echo fairphone-case,$f.auto.stl; done`
23 // 4. Print them. Case and OneKeeperPrint should probably be
26 // 5. Assemble the hinge.
28 // Cut short bits of wire
29 // Push in with long bit of wire
30 // Use gas flame to melt end of 2.85mm PLA
35 // - To put the phone in, drop its RH side into the RH side of
36 // the case. Then feed the keeper through the small hole.
37 // Feed it right through.
39 // - The optional prop can be used to prop the phone up (in
40 // portrait orientation only right now). See
41 // openscad fairphone-case,DemoPropAngles.auto.scad
45 // It might well be possible to adapt this file for other phones.
46 // If you do, let me know how you get on.
49 // AUTHORSHIP, COPYRIGHT, LICENCE, AND LACK OF WARRANTY
51 // Copyright (C) 2018-2022 Ian Jackson.
53 // This program for generating a 3D model is free software: you can
54 // redistribute it and/or modify it under the terms of the GNU
55 // General Public License as published by the Free Software
56 // Foundation, either version 3 of the License, or (at your option)
59 // This program is distributed in the hope that it will be useful,
60 // but WITHOUT ANY WARRANTY; without even the implied warranty of
61 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62 // GNU General Public License for more details.
64 // You should have received a copy of the GNU General Public
65 // License along with this program. If not, see
66 // <http://www.gnu.org/licenses/>.
68 // In particular DO NOT BLAME ME IF THIS CASE DOES NOT ADEQUATELY
69 // PROTECT YOUR PHONE ! It is your responsibility to decide whether
70 // this case will meet your needs.
75 phone = [ 75.86, 162.0 ];
77 prop_buildout_less = 3;
79 prop_angles = [ 15, 30, 45, 60 ];
81 bumper = [ 0.250, -0.025 ];
82 // ^ One side. Overall size is increased by twice this.
83 // If no bumpers, is the gap around the phone.
89 // 1: simply an opening
90 // 2: opening with separate cover model, for printing in clear (two colour)
91 // 3: like 2 but one-layer window for ad-hoc multi-colour
93 initial_layer_thick = 0.400; // ^ needed for mode 3 only
94 initial_layer_width = 0.750; // ^ needed for mode 3 only
95 multicolour_gap = 0.15; // each side
97 phone_cnr_rad = 7.0; // actuall 8.mumble, but smaller is fine
98 phone_rim_depth = 0.01; // includes allowance for a screen protector
100 button_cutout_depth = 9;
102 phone_edge_thick = 11.25;
104 camera_pos_tl = [ 5.600, 5.750 ]; // from tl corner (as seen from back)
105 camera_edge_rad = 9.750 + 0.700;
106 camera_sz = 32.920 + .750 + 1.000;
108 // this is disabled, FP4 doesn't have one
109 jack_pos = [ 13.83, 8.485 ];
110 jack_dia = 10.64 + .5; // some jack I had lying around
112 // this led stuff, is irrelevant, we have disabled it as it doesn't have one
113 led_pos = []; // [ 13.98, 10.00 ];
115 led_window_ledge = 0.75; // each side
117 noisecancelmic_pos = [ 15.08 + .720, 4.35 ]; // from rhs, from top edge
118 noisecancelmic_dia = 4.00;
120 mainmic_pos = [ 21.0, 4.65 ]; // from lhs, from top edge
123 lhshole_pos = [ phone[1]/2 + 0.40, 4.35 ];
125 // fingerpushhole_dias = [];
126 fingerpushhole_dias = [ 15, 18 ]; // this is for testing
128 lanyard_half_dia = 1.15;
129 lanyard_entry_rel_breadth = 2;
130 lanyard_channel_len = 8;
131 //rearspeaker_pos_bl = [ 12.64, 18.72 ];
132 //rearspeaker_size = [ 3.76, 7.36 ];
134 bottomspeaker_size = [ 11.35, 1.90 ] + [1,1] * 0.5;
135 bottomspeaker_pos = [ 17.55, 5.17 ]; // from rhs, from top
137 microusb_above = 1.64 - 0.25;
138 microusb_below = 2.42;
139 microusb_width = 12.16 + 2.0 + 1.25;
141 case_th_bottom = 2.5;
146 lid_screen_gap_extra = .66;
148 case_struts_count = 6;
149 case_struts_solid_below = 1.00;
150 case_struts_solid_above = 0.75;
151 case_struts_width = 0.10;
155 keeper_inner_width = 2.75;
156 keeper_inner_height = 2.75;
157 keeper_slant_slope = 2; // larger means steeper
159 keeper_gap_z_top = 0.25;
160 keeper_gap_z_bot = 0.75;
162 keeper_gap_x_holes = 0.75;
163 keeper_fatter = 0.45;
164 keeper_fatter_hole = 1.20;
166 keeper_side = 0; // 0 = lhs; 1 = rhs
173 lid_edgepart_width = 5.0;
174 lid_buttoncover_thick = 1.3;
175 lid_buttoncover_reinf = 0.65;
178 foldover_lever_gap = 0.50;
180 // properties of the hinge fasteners
181 hingescrew_shaft_dia = 1.600 + 0.45; // beading wire
182 hingescrew_shaft_len = 10;
183 hingescrew_fasteners_extra_thick = 0.40;
184 // ^ amount of thread protruding if everything was completely nominal
185 // and we are using two nuts
186 hingescrew_nut_access_dia = 4.72 + 0.50;
187 // ^ washer is 4.72 dia
188 // also, want to get pliers or tiny spanner in to do up locknut
189 hingescrew_nut_across = 3.92 + 0.25; // incl. slop around recess slop
190 hingescrew_nut_thick = 1.93;
191 hingescrew_head_th = 1.38 + 0.75;
192 hingescrew_head_dia = 3.92;
194 hingescrew_nut_recess_portion = 2/3; // portion of nut in recess
196 lever_cover_th = 0.75;
198 hingemount_wd = 4.8725;
203 button_l_fudge = 4.4;
204 buttonishleg_default_l_is_fudge = 10;
206 hinge_base_slope = 1.5; // bigger is steeper
208 strut_min_at_end = 1.5;
211 hinge_x_postscrew_gap = 0.75;
212 hinge_x_arms_gap = 0.35;
213 hinge_r_arms_gap = 0.55;
214 hinge_over_nut_plate = -0.50; // bodge apropos slope
216 // there isn't one of these, speaker is by hinge
217 // rearspeaker_gap = [ 2.0, 2.0 ]; // each side
219 thumbrecess_depth = 1.3;
220 thumbrecess_width = 16.5;
221 thumbrecess_topcurve_r = 5.0;
223 prop_recess_under = 0.50;
224 prop_recess_slop = 0.200; // each side
229 prop_side_gap = 0.75; // each side
230 prop_lidrecess_behind = 0.75;
231 prop_caserecess_behind = 0.75;
232 prop_caserecess_taper = 0.45; // one side only
234 prop_prong_heel_slope = 0.5;
236 lid_fold_clearance_antislop = 0.5;
238 $button_leg_only = false;
239 $suppress_forward_holes = false;
241 // ---------- calculated ----------
243 phone_total_thick = phone_edge_thick;
245 phone_width = (phone + bumper*2)[0];
246 phone_height = (phone + bumper*2)[1];
248 inside_br = [phone_width, -phone_height];
250 prop_prong_h = prop_main_th;
252 //echo(camera_pos_tl + bumper,
253 // camera_pos_br + bumper);
255 // ----- could be changed -----
256 lid_buttoncover_gap = lid_gap_x;
257 lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
259 //prop_lidrecess_depth = case_th_lid - prop_recess_under;
261 //prop_nose_len = case_th_lid - prop_recess_under;
262 //prop_recess_slope = tan(prop_max_angle); // bigger means steeper
263 //prop_recess_width = prop_main_th / cos(prop_max_angle) + prop_backfwd_gap;
267 epp1 = [0, -phone_edge_thick];
268 epp2i = epp1; // conflated for FP4
270 epp3 = epp2i + [10, 0];
271 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
272 epp4 = epp5 + [-1,0] * case_th_side;
275 kppd = kppe + [1,0] * keeper_inner_width;
276 kppc = kppd + [0,1] * keeper_th_z;
277 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
278 kppf = kppe - [0,1] * keeper_inner_height;
279 kppa = [ kppb[0], kppf[1] ];
281 lpp10 = [ epp5[0] + lid_gap_x, kppc[1] + lid_gap_z ];
282 lpp11 = [ lpp10[0], epp5[1] + lid_gap_z ];
284 lpp14 = lpp10 + [1,0] * max(keeper_inner_width, lid_edgepart_width);
285 // exact x posn not very important; must extend past end of keeper
288 epp0[1] - phone_rim_depth + 1/2.5 * case_th_lid
289 + lid_screen_gap_extra ];
290 // ^ beam theory says to maximise force before contact,
291 // the gap below the `beam' (the lid) must be 1/3
292 // the thickness (ie the lid thickness) if the beam
293 // is solid, or 1/2 if it has a top and bottom only.
294 // ours is mostly solid.
296 lp_r12 = max(case_th_lid - (lpp11[1] - lpp15[1]),
299 lpp12 = [ epp4[0] + lp_r12, lpp11[1] ];
300 lpp13 = [ lpp12[0], lpp12[1] + lp_r12 ];
302 case_bottom_z = epp2o[1] - case_th_bottom;
306 bppN = [ bppM[0] + lid_buttoncover_thick, bppM[1] ];
307 bppR = [ bppN[0] + lid_buttoncover_gap, -button_cutout_depth ];
308 bppS = [ epp1[0], bppR[1] ];
309 bppQ = [ bppM[0], bppR[1] - lid_buttoncover_overlap ];
310 bppP = bppQ + [0,1] * lid_buttoncover_gap;
311 bppO = [ bppN[0], bppP[1] ];
312 bppL = lpp10 + [5,0];
313 bppK = [ bppL[0], bppN[1] ];
314 bppJ = [ bppN[0], bppL[1] ];
315 bppU = [ bppJ[0], lpp12[1] ];
319 echo("BUTTON COVER TH", bppO[0] - bppP[0]);
321 // notification led aperture
323 nla_r0 = led_aperture/2;
324 nla_r1 = nla_r0 + led_window_ledge;
325 nla_r2 = nla_r1 + multicolour_gap;
327 led_window_style >= 3 ? initial_layer_thick :
328 led_window_style >= 2 ? led_window_ledge : 0;
332 hp_rn = hingescrew_nut_access_dia/2;
333 hp_r2_min = hp_rn + lever_cover_th;
334 hp_rs = hingescrew_shaft_dia/2;
335 hp_r1_min = hp_rs + hingemount_th;
337 hp_r1 = max(hp_r1_min, hp_r2_min);
341 hppS = epp2o + [0,-1] * case_th_bottom;
342 hp_k = 0.5 * (hppU[1] - hppS[1] + foldover_gap);
344 hppM = [ epp4[0] - foldover_lever_gap - hp_r2,
345 0.5 * (hppU + hppS)[1] ];
346 hppT = [ hppM[0], hppU[1] - hp_r1 ];
347 hppB = hppT + [0,-1] * hp_k;
349 hppE_y = epp2o[1] - case_th_bottom + hp_r1;
350 hppE_x = hppB[0] + (hppB[1] - hppE_y) * hinge_base_slope;
351 hppE = [ hppE_x, hppE_y ];
353 // hinge elevation x coords
355 hex20 = max(epp2o[0],
357 kppd[0] + hingescrew_head_th + keeper_gap_x_holes);
358 hex21 = hex20 + hingemount_wd;
359 hex22 = hex21 + hinge_x_gap;
360 hex27 = hex20 + hingescrew_shaft_len;
361 hex24 = hex27 + hinge_x_postscrew_gap;
362 hex23 = hex27 - (hingescrew_nut_thick*2
363 + hingescrew_fasteners_extra_thick);
364 hex26 = hex23 + hingescrew_nut_thick * 2/3;
366 //echo(hex20, hex21, hex22, hex23, hex24);
367 //// 6, 10.8725, 10.9975, 13.74, 18.75
368 //module chk(act,exp) {
369 // if (abs(act-exp) > 1e-9) echo("WRONG", act, exp);
370 // else echo("ok", act);
373 //chk(hex21, 10.8725);
374 //chk(hex22, 10.9975);
378 lid_fold_clearance_skew =
379 (lpp10[1] - hppB[1]) /
380 (lpp10[0] - hppB[0]);
382 echo("SK",lid_fold_clearance_skew);
384 // thumb recess (used to be "catch" hence cpp*
386 cppA = epp4 + [thumbrecess_depth, 0];
387 cppB = [ cppA[0], epp1[1] ];
391 ly_r = lanyard_half_dia / 2;
395 ly_o = epp2i + 3 * ly_r * [0,1];
397 max_case_bottom_edge_thickness =
400 ly_q_z = -(ly_rc + ly_r);
401 ly_re = max_case_bottom_edge_thickness - (-ly_q_z);
403 ly_oec_y = lanyard_entry_rel_breadth * ly_r;
405 // prop recess in case
407 prop_x_pos = phone_width/2;
409 prop_recess_hw = 0.5 * prop_main_width + prop_side_gap;
411 prc_r1 = prop_end_dia/2;
412 prc_r3 = prc_r1 + prop_recess_slop;
414 prcp2 = [ epp4[0] + prop_buildout_less,
417 prop_caserecess_buildout_r = -1; // prcp2[0] - epp2o[0];
419 prcp1 = [ epp2o[0] + prc_r3 + prop_caserecess_behind,
420 epp2i[1] - prc_r3 - prop_recess_under];
422 // prop recess in lid
424 prl_r10 = prop_end_dia/2;
425 prl_r10o = prl_r10 + prop_recess_slop;
427 prlp10 = lpp10 + [1,1] * prl_r10o
428 + [1,0] * prop_lidrecess_behind
429 + [0,1] * prop_recess_under;
434 $prpp11 = [0, prop_taper_len];
438 // ---------- modules ----------
440 module AdhocMultiprintFrame(phase, z0, zs) {
441 // from z0 to z0 + zs*layer
442 extra = phase * (initial_layer_width + multicolour_gap) + 5;
443 xextra = extra + -epp4[0];
444 xrange = [ 0, phone_width ] + [-1,+1] * xextra;
445 yextra = extra + -epp4[0];
446 yrange = [ -phone_height + +hppB[0] - hp_r2, 0 ] + [-1,+1] * yextra;
447 p0 = [ xrange[0], yrange[0] ];
448 p1 = [ xrange[1], yrange[1] ];
451 mirror([0,0, zs<0 ? 1 : 0])
452 linear_extrude(height= initial_layer_thick)
454 rectfromto(p0 - [1,1] * initial_layer_width,
455 p1 + [1,1] * initial_layer_width);
460 module KeeperProfile(fatter, slant=0){
461 use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
462 polygon([use_e + [+1,-1] * fatter,
463 kppd + [ 0,-1] * fatter,
467 kppf + [+1, 0] * fatter
471 module EdgeProfile(){
474 translate(epp3) square(case_th_bottom*2, center=true);
475 circleat(epp2o, r=case_th_bottom);
476 circleat(epp1, r=case_th_side);
477 rectfromto(epp0, epp4);
479 polygon([ epp5 + [0,10],
485 module LanyardLanyardProfile(entry=false){
487 for (xs=[-1,+1] * (entry ? lanyard_entry_rel_breadth : 1))
488 translate(xs * 0.5 * lanyard_half_dia * [1,0])
489 circle(r= lanyard_half_dia/2);
493 module LanyardCurveChannelProfile(){
494 translate([0, -ly_r])
495 LanyardLanyardProfile();
498 module LanyardEntryChannelProfile(){
499 LanyardLanyardProfile(true);
502 module LanyardMainChannelProfile(){
503 LanyardCurveChannelProfile();
505 square(center=true, ly_r * [6, 2]);
507 translate(ly_r * [3 * xs, -1])
512 module LanyardEntryOuterProfile(){
513 circleat([ly_re + ly_r, 0], ly_re);
516 module LanyardEntry(){
522 translate([d_x, 0, q_z]) {
525 rotate_extrude(convexity=10)
528 LanyardCurveChannelProfile();
536 linear_extrude(height=20)
538 LanyardEntryChannelProfile();
540 translate([0, ly_r*2, 0])
542 linear_extrude(height = ly_r*4){
544 rectfromto([d_x, q_z], [ly_r, 0]);
545 circleat([d_x, q_z], ly_rc);
549 translate([0,0,q_z]){
552 translate([0, oec_y, 0]){
554 translate(ly_re * [-1,0,-2])
555 cube(ly_re * [2,1,2]);
556 rotate_extrude(convexity=10)
557 LanyardEntryOuterProfile();
562 translate([-ly_re, -(oec_y + 0.01), -2*ly_re])
563 cube([ly_re*2, 2*(oec_y + 0.01), 2*ly_re]);
568 linear_extrude(height=20)
569 LanyardEntryOuterProfile();
574 module LanyardCutout(l){
576 linear_extrude(height=l)
578 LanyardMainChannelProfile();
581 translate(ee * l * [-1,0])
587 module LidEdgeProfile(){
598 circleat(lpp12, r=lp_r12);
599 rectfromto( lpp12 + [-10, 0],
600 lpp12 + [+10, +10] );
604 module LidEdgeFoldClearanceProfile(){
605 translate([-lid_fold_clearance_antislop, 0])
614 module ButtonCoverProfile(){
616 polygon(concat([ bppM, bppP, bppO, bppJ ],
617 (enable_support && !$button_suppress_over_keeper
618 ? [ bppU, bppV, bppW ] : []),
627 module ButtonPlan(l, deep, cut){
629 (cut ? 0 : lid_buttoncover_gap);
632 (deep ? lid_buttoncover_overlap : 0);
634 C = [0,0]; // by definition
638 B0 = C + [0,-1] * button_cutout_depth;
639 B1 = B0 + [0,1] * epsilon;
641 r0 = 0.5 * (T[1] - B0[1]);
642 A = [ -(l + button_l_fudge)/2 + r0, 0.5 * (T[1] + B0[1]) ];
643 H = A + [0,-1] * delta;
649 E1 = E0 + [1,0] * epsilon;
651 I0 = [ E0[0], H[1] ];
652 I1 = [ E1[0], H[1] ];
655 for (m=[0,1]) mirror([m,0])
656 circleat(H, r0 - epsilon);
658 for (m=[0,1]) mirror([m,0]) {
668 circleat(D, r0 + epsilon);
673 module ButtonCoverReinf(){ ////toplevel
676 linear_extrude(height=0.01)
678 ButtonCoverProfile();
679 translate([bppJ[0] + 0.1, -50]) mirror([1,0])
682 mirror([0,0,1]) linear_extrude(height=0.01) intersection(){
683 circle(r= lid_buttoncover_reinf);
684 translate([-20,0]) square(40, center=true);
689 module ThumbRecessCutProfile(){
691 polygon([ cppA + [-10,0],
695 circleat(epp1, r=case_th_side);
699 module Flip_rhs(yn=[0,1]) {
701 translate([phone_width/2, 0, 0])
702 mirror([$rhsflip,0,0])
703 translate([-phone_width/2, 0, 0])
708 module Flip_bot(yn=[0,1]) {
710 translate([0, -phone_height/2, 0])
711 mirror([0, $botflip, 0])
712 translate([0, phone_height/2, 0])
717 module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
720 translate([0, -phone_cnr_rad, 0])
722 linear_extrude(height = phone_height - phone_cnr_rad*2)
726 Flip_rhs() Flip_bot() {
727 translate([+1,-1] * phone_cnr_rad)
732 translate([-1,0] * phone_cnr_rad)
734 rectfromto([0,-20],[10,20]);
736 translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
742 translate([ phone_width - phone_cnr_rad, 0,0 ])
744 linear_extrude(height = phone_width - phone_cnr_rad*2)
748 translate([0,0, fill_zstart])
749 mirror([0,0, fill_downwards])
750 linear_extrude(height = fill_th)
751 rectfromto([+1,-1] * phone_cnr_rad,
752 [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
755 module CaseAperture(pos, dia, $fn, topbottom=0) {
757 translate([ bumper[0],
760 rotate([0,0, 90*topbottom])
761 translate([ pos[0] * (topbottom>0 ? -1 : +1), 0, -pos[1] ])
762 rotate([-90, theta, 0])
763 cylinder(r = dia/2 / cos(theta),
767 module SideButton(y, y_ref_sign, l, suppress_over_keeper=0){
769 // +1 measured from top of actual phone to top of button
770 // -1 measured from bottom of actual phone to bottom of button
771 // 0 y is centre of button in coordinate system
773 $button_suppress_over_keeper= suppress_over_keeper;
774 eff_y = y_ref_sign > 0 ? -bumper [1] -y -l/2 :
775 y_ref_sign < 0 ? (-phone -bumper)[1] +y +l/2 :
778 translate([0, eff_y, 0])
782 module LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
783 $button_leg_only = true;
784 SideButton(y, y_ref_sign, l) children();
788 Flip_rhs(1) SideButton(30.320, +1, 22.960 ) children(); // volume
789 Flip_rhs(1) SideButton(64.220, +1, 14.500 ) children(); // power
790 Flip_rhs(1) LidButtonishLeg(14, -1) children();
791 Flip_rhs(0) LidButtonishLeg(21, -1) children();
792 Flip_rhs(0) LidButtonishLeg(21, +1) children();
795 module Struts(x_start, z_min, th){
796 // if th is negative, starts at z_min and works towards -ve z
797 // and object should then be printed other way up
798 for (i= [1 : 1 : case_struts_count]) {
802 mirror([0,0, th<0 ? 1 : 0])
804 -phone_height * i / (case_struts_count+1),
805 case_struts_solid_below])
806 linear_extrude(height= abs(th)
807 -(case_struts_solid_below+case_struts_solid_above))
808 rectfromto([ x_start, -0.5 * case_struts_width ],
809 [ phone_width - x_start, +0.5 * case_struts_width ]);
813 module OrdinaryRearAperture(rhs,bot, pos){
814 Flip_rhs(rhs) Flip_bot(bot)
817 translate(pos + bumper)
821 module MicroUSBEtc(){
825 linextr(-epp2i[0], 60)
826 translate([0.5 * phone_width, 0, 0])
827 rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
828 [+microusb_width/2, epp0[1] + -microusb_above]);
832 module OrdinaryBottomEdgeApertures(){
834 CaseAperture(mainmic_pos, mainmic_dia, 8);
836 Flip_bot(1) Flip_rhs(1) {
837 linextr_y_xz(-epp2i[0], 60)
840 translate([ -bottomspeaker_pos[0], -bottomspeaker_pos[1] ] +
841 [ 0.5 * x * bottomspeaker_size[0] - bottomspeaker_size[1],
844 circle(r = bottomspeaker_size[1], $fn = 8);
849 module OrdinaryRearApertures(){
851 // OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
852 // rectfromto(-rearspeaker_gap,
853 // rearspeaker_size + rearspeaker_gap);
856 module NotInTestFrameRearApertures(){
857 // finger hole to remove phone
858 if (len(fingerpushhole_dias))
859 OrdinaryRearAperture(0,0, [ fingerpushhole_dias[0] + epp2i[0],
861 scale(fingerpushhole_dias)
865 module RearCameraAperture(){
869 hull() // there is some kind of bug if hull() is done in 2D here!
870 linear_extrude(height = 20)
873 translate(camera_pos_tl)
874 for (xy = [ [0,0], [0,1], [1,0] ]) {
876 camera_edge_rad * [1,1] +
877 xy * (camera_sz - camera_edge_rad * 2)
879 circle(r = camera_edge_rad);
883 module HingeLidProfile(){
885 circleat(hppT, hp_r1);
886 circleat(lpp12, lp_r12);
894 module HingeBaseProfile(){
897 circleat(hppB, hp_r1);
898 circleat(hppE, hp_r1);
899 circleat(epp2o, case_th_bottom);
900 circleat(hppB + [10,0], hp_r1);
902 polygon([epp5, epp1, epp3, bppL]);
906 module HingeLeverOuterProfile(){
908 circleat(hppT, hp_r2);
909 circleat(hppB, hp_r2);
913 module HingeLeverInnerProfile(){
915 c = s > 0 ? hppT : hppB;
917 mirror([0,0, s>0 ? 1 : 0])
918 rotate(s<0 ? -40 : 0)
927 module HingeLeverNutProfile(){
928 for (c= [hppB, hppT]) {
930 circle($fn=6, r= 0.5 * hingescrew_nut_across / cos(30));
934 module Flip_hinge(doflip=1){
935 hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
936 translate(hinge_origin)
937 rotate([doflip*180,0,0])
938 translate(-hinge_origin)
942 module HingePortion(x0,x1){
943 Flip_rhs() Flip_bot(1)
947 linear_extrude(height=x1-x0)
951 module ThumbRecessApply(ztop){
952 width = thumbrecess_width;
953 w = width + thumbrecess_topcurve_r*2 + 1;
954 translate([phone_width/2, 0,0]){
959 translate([0, 50, 0])
961 linear_extrude(height=100){
962 for (m=[0,1]) mirror([m,0,0]) {
964 translate([w/2, ztop - thumbrecess_topcurve_r])
965 circle(thumbrecess_topcurve_r);
966 translate([w/2, -50])
967 square(thumbrecess_topcurve_r*2, center=true);
976 AroundEdges(epp3[1], case_th_bottom, 1)
980 function prop_x(gamma) = hp_k / (2 * sin(gamma/2)) - hppT[0];
982 module PropProfileAssignments(gamma){
983 // https://en.wikipedia.org/wiki/Solution_of_triangles#Two_sides_and_the_included_angle_given_(SAS)
985 p = phone_height + prlp10[0] - hppB[0];
988 q = phone_height - hppT[0] - prcp1[0]; // $prpp7[0] is 0 by definition
990 c = sqrt(a*a + b*b - 2*a*b*cos(gamma));
991 $prp_alpha = acos( (b*b + c*c - a*a) / (2*b*c) );
993 $prp_theta = 90 - $prp_alpha;
994 beta = 180 - $prp_alpha - gamma;
997 //echo("abc", a,b,c);
999 v1 = [ [ cos(psi), -sin(psi) ], // x
1000 [ sin(psi), cos(psi) ] ]; // y
1002 $prpp7 = [0, c + (lpp13[1] - $prpp10[1] - hp_k) ];
1005 $prp_r11 = prop_main_th/2;
1007 $prpp1 = $prpp7 + [1,0] *
1008 // this is approximate, but will do
1009 (prop_main_th/2 + prop_prop_gap + prcp1[0] - cppA[0]);
1012 v1[1] * ((prcp2[1] - prcp1[1]) - prop_prop_gap);
1013 $prpp12 = $prpp3 + v1[0] *
1014 (prop_end_dia + prop_caserecess_taper * ($prpp1[1] - $prpp3[1]));
1015 $prp_r8 = prop_main_th;
1016 $prpp4 = [ prop_main_th/2, $prpp3[1] ];
1018 $prpp5 = [ $prpp12[0] - $prp_r5,
1019 $prpp3[1] - prop_prong_h + $prp_r5 ];
1020 $prpp6 = $prpp4 + [0,-1] * (prop_prong_h +
1021 prop_prong_heel_slope * ($prpp5[0] - $prpp4[0]));
1022 $prpp8 = $prpp4 + [0,-1] * $prp_r8;
1023 $prpp9 = $prpp8 + [-1,0] * $prp_r8;
1028 module PropProfile(gamma, cut=0, rot=0){
1029 PropProfileAssignments(gamma){
1031 //#circleat($prpp3,1);
1032 //#circleat($prpp12,1);
1039 polygon([[-20,-0], [20,20], [0,0]]);
1041 rectfromto($prpp6, $prpp9);
1042 translate($prpp5) intersection(){
1044 polygon([[-10,-10], [0,0], [10,0]]);
1046 rectfromto($prpp12 + [0,-0.1], $prpp3);
1049 circleat($prpp1, $prp_r1);
1050 rectfromto($prpp12 + [0,-0.1], $prpp3);
1054 rotate([0,0, rot*-$prp_theta]){
1056 extra = cut ? prop_recess_slop : 0;
1057 rectfromto($prpp6, $prpp9);
1058 circleat($prpp11, $prp_r11 + extra);
1059 circleat($prpp10, $prp_r10 + extra);
1065 module PropAggregateProfile(){
1066 for (angle = prop_angles)
1067 PropProfile(angle, 0,0);
1070 module Prop(){ ////toplevel
1071 hw = prop_main_width/2;
1073 PropAggregateProfile();
1076 module Case(){ ////toplevel
1081 // ledge (fixed keeper)
1082 Flip_rhs(1-keeper_side) intersection(){
1084 linear_extrude(height = phone_height + phone_cnr_rad * 2)
1085 KeeperProfile(fatter=0, slant=1);
1087 // outline of the whole case, to stop it protruding
1088 translate([0,0, -25])
1089 linear_extrude(height = 50)
1092 circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
1096 HingePortion(hex20, hex21) HingeBaseProfile();
1098 // buildout for prop recess
1099 if (prop_caserecess_buildout_r > 0) Flip_rhs(1)
1100 linextr(case_bottom_z, epp2i[1])
1103 circleat([ prop_x_pos + dxs * prop_caserecess_buildout_r,
1105 r = epp2o[0] - prcp2[0]);
1110 Flip_rhs(keeper_side)
1111 translate([0, -phone_cnr_rad, 0])
1113 linear_extrude(height = phone_height + phone_cnr_rad * 2)
1115 KeeperProfile(fatter=keeper_fatter_hole);
1116 rectfromto([ -keeper_gap_x, -keeper_gap_z_bot ],
1117 [ keeper_gap_x_holes, +keeper_gap_z_top ]);
1121 RearCameraAperture();
1123 // struts (invisible, because they're buried in the case)
1124 Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
1129 if (!($button_leg_only && enable_support))
1131 translate([0,0,-10])
1132 linear_extrude(height= 20)
1133 ButtonPlan($button_l, 0,1);
1134 if ($button_leg_only)
1136 translate([phone_width/2, -400, kppe[1]])
1137 mirror([1-abs($rhsflip - keeper_side),0,0])
1138 cube([400, 800, 50]);
1139 if (enable_support && !$button_suppress_over_keeper)
1141 translate([-400, -400, kppd[1]])
1143 cube([800,800,100]);
1145 translate([0,0, -bppR[0]])
1146 linear_extrude(height= 20)
1147 ButtonPlan($button_l, 1,1);
1152 // apertures along top edge
1153 if (!$suppress_forward_holes) {
1154 // CaseAperture(jack_pos, jack_dia, 8);
1156 CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 8);
1157 CaseAperture(lhshole_pos, noisecancelmic_dia, 8, 1);
1160 OrdinaryBottomEdgeApertures();
1162 OrdinaryRearApertures();
1163 NotInTestFrameRearApertures();
1167 // gaps for the lid's hinge arms
1168 HingePortion(hex20 - hinge_x_arms_gap,
1169 hex21 + hinge_x_arms_gap)
1172 circle(r= hinge_r_arms_gap, $fn= 8);
1175 // screw holes in the hinge arms
1179 ThumbRecessApply(epp4[1])
1180 ThumbRecessCutProfile();
1184 translate([ly_o[0], -(phone_cnr_rad + ly_re), ly_o[1]])
1185 rotate([0, ly_theta, 0])
1187 LanyardCutout(lanyard_channel_len);
1191 translate([prop_x_pos,0,0])
1194 linextr(-prop_recess_hw, +prop_recess_hw)
1196 for (d=[ [0,0], [0,-1], [+1,-1/prop_caserecess_taper] ])
1197 circleat(prcp1 + 20*d,
1203 module LidAdhocMultiprintFrame(phase){
1204 if (led_window_style >= 3) {
1205 AdhocMultiprintFrame(phase, lpp13[1], -1);
1209 module LidAroundEdges(){
1210 AroundEdges(lpp15[1], lpp13[1] - lpp15[1], 0)
1214 module Lid(){ ////toplevel
1215 skew_centre = [0, lpp11[0], lpp11[1]];
1222 translate(skew_centre)
1223 multmatrix([[ 1, 0, 0, 0 ],
1224 [ 0, 1, -lid_fold_clearance_skew, 0 ],
1227 translate(-skew_centre)
1229 LidEdgeFoldClearanceProfile();
1236 translate([0,0,-10])
1237 linear_extrude(height= 20)
1238 ButtonPlan($button_l, 1,0);
1241 translate([0,0,-100])
1242 linear_extrude(height= 200)
1243 ButtonCoverProfile();
1245 for (y= [-1,+1] * (($button_l + button_l_fudge)/2
1246 - lid_buttoncover_reinf))
1254 HingePortion(hex20, hex21) {
1259 Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
1261 // screw holes in the hinge arms
1265 translate([prop_x_pos, -prlp10[0], prlp10[1]])
1268 linextr(-prop_recess_hw, +prop_recess_hw)
1270 for (pa = prop_angles)
1271 PropProfile(pa, 1,1);
1273 // notification led aperture
1274 if (led_window_style)
1275 translate([led_pos[0], -led_pos[1], lpp13[1]]) {
1276 translate([0,0,-10])
1277 cylinder(r=nla_r0, h=20);
1278 if (led_window_style >= 2)
1279 translate([0,0, -nla_t])
1280 cylinder(r=nla_r2, height=20);
1285 LidAdhocMultiprintFrame(1);
1288 module HingeLever(){ ////toplevel
1290 // outer body, positive
1291 HingePortion(hex22, hex22 + phone_width/2)
1292 HingeLeverOuterProfile();
1294 // space for the screws
1295 // HingePortion(hex26, hex24)
1296 // HingeLeverInnerProfile();
1298 // recesses for the nuts
1299 // HingePortion(hex23, hex26+1)
1300 // HingeLeverNutProfile();
1302 // bores for the screws
1305 // space for the charging cable and speaker and micc apertures
1311 * ( (hex24 + hinge_over_nut_plate) -
1312 (phone_width/2 - microusb_width/2)
1314 / ( (epp0[1] - microusb_above)
1316 (hppB[1] - hp_r2) ),
1318 x * (epp0[1] - microusb_above)
1325 Flip_hinge() MicroUSBEtc();
1333 module LidWindow(){ ////toplevel
1334 translate([led_pos[0], -led_pos[1], lpp13[1]])
1336 cylinder(r= nla_r1, h=nla_t);
1337 LidAdhocMultiprintFrame(0);
1340 module LidWindowPrint(){ ////toplevel
1345 module DemoLidWindowSelect(){
1346 translate([led_pos[0], led_pos[1], -100]) {
1347 translate([0, -30, 0]) cube([400, 400, 200]);
1351 module DemoLidWindow(){ ////toplevel
1354 translate([0,40,0]){
1355 color("blue") intersection(){ Lid(); DemoLidWindowSelect(); }
1356 color("red") intersection(){ LidWindow(); DemoLidWindowSelect(); }
1360 module HingeLeverPrint(){ ////toplevel
1362 translate([-phone_width/2, phone_height, 0])
1366 module TestSelectLength(){
1367 translate([-30, -200, -20])
1368 cube([30 + 15, 250, 40]);
1371 module TestLength(){ ////toplevel
1378 module TestLengthRight(){ ////toplevel
1386 module TestSelectWidth(){
1387 translate([-30, -(phone_height - 25), -20])
1389 cube([200, 50, 40]);
1392 module TestWidth(){ ////toplevel
1399 module TestLidWidthPrint(){ ////toplevel
1400 rotate([0,180.0]) intersection(){
1406 module TestSelectRearAperture(){
1409 translate([20, 0,0])
1410 cube([42, 2, 1], center=true);
1414 module TestSelectCamera(){
1416 TestSelectRearAperture()
1417 RearCameraAperture();
1418 cube([0.1, 50, 0.1]);
1422 module TestSelectOrdinaryRearApertures(){
1423 TestSelectRearAperture()
1424 OrdinaryRearApertures();
1427 module TestCamera(){ ////toplevel
1434 module TestLidByCamera(){ ////toplevel
1441 module TestLidByCameraPrint(){ ////toplevel
1442 rotate([180,0,0]) TestLidByCamera();
1445 module DemoByCamera(){ ////toplevel
1446 color("blue") TestLidByCamera();
1447 color("red") TestCamera();
1450 module OneKeeper(){ ////toplevel
1451 translate([0, -phone_cnr_rad, 0])
1453 linear_extrude(height = phone_height - phone_cnr_rad * 2)
1454 KeeperProfile(fatter=keeper_fatter);
1457 module OneKeeperPrint(){ ////toplevel
1462 module LidPrint(){ ////toplevel
1467 module TestSelectFrame(){
1468 include = [1,-1] * (epp2i[0] + 4);
1471 cube(1000, center=true);
1472 translate([0,0, -100])
1473 linear_extrude(height=200)
1474 rectfromto(include, inside_br - include);
1478 translate([ 0, -phone[1] * i/3, 0 ])
1479 cube(center=true, [1000, 4, 100]);
1483 module TestSelectLidFrame(){
1486 translate([led_pos[0], -led_pos[1], -50])
1487 cylinder(r= nla_r2+3, h=100);
1490 module TestFrameCase(){ ////toplevel
1496 TestSelectOrdinaryRearApertures();
1501 module TestSelectTopApertures(){
1502 translate([-100, -35, -100])
1503 cube([400, 100, 200]);
1504 LidAdhocMultiprintFrame(0);
1505 LidAdhocMultiprintFrame(1);
1508 module TestTopApertures(){ ////toplevel
1512 TestSelectTopApertures();
1516 module TestLidTopAperturesPrint(){ ////toplevel
1517 rotate([0,180,0]) intersection(){
1519 TestSelectLidFrame();
1520 TestSelectTopApertures();
1524 module TestLidWindowTopAperturesPrint(){ ////toplevel
1525 rotate([0,180,0]) intersection(){
1527 TestSelectTopApertures();
1531 module TestFrameLidPrint(){ ////toplevel
1532 rotate([0,180,0]) intersection(){
1534 TestSelectLidFrame();
1538 module ButtonPlanForDemo(z, deep, cut){
1540 ButtonPlan(8, deep, cut);
1543 module HingeScrews(){
1544 Flip_rhs() Flip_bot(1){
1545 for (c= [ hppT, hppB ])
1550 translate([0,0,-.2])
1551 cylinder( r= hingescrew_shaft_dia/2,
1552 h = hingescrew_shaft_len+0.2 );
1554 translate([0,0,+.1])
1555 cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
1560 module DemoPropAngleSelect(c){
1561 color(c) difference(){
1562 union(){ children(); }
1563 translate([ prop_x_pos, -400, -200 ])
1564 cube([ 400,800,400 ]);
1568 module DemoPropAngle(ang){
1569 hL = [0, -(phone_height - hppT[0]), hppT[1] - hp_k*2];
1570 hC = [0, -(phone_height - hppB[0]), hppB[1]];
1578 DemoPropAngleSelect("red") Case();
1581 translate([prop_x_pos, -prcp1[0], prcp1[1]])
1582 PropProfileAssignments(ang) {
1584 rotate([-$prp_theta, 0, 0])
1585 translate([0, $prpp1[0], -$prpp1[1]])
1591 translate([0,0, -hp_k*2])
1592 DemoPropAngleSelect("blue")
1596 module DemoPropAngles(){ ////toplevel
1597 for (i=[0 : len(prop_angles)-1])
1598 translate(i * [0, -100, 100])
1599 DemoPropAngle(prop_angles[i]);
1602 module DemoHingeAngle(ang1,ang2){
1603 hL = [0, -(phone_height - hppT[0]), hppT[1]];
1604 hC = [0, -(phone_height - hppB[0]), hppB[1]];
1615 color("blue") intersection(){
1618 translate([bppJ[0], -400, -200])
1620 cube([400, 800, 400]);
1621 translate([10, -400, -200])
1622 cube([10, 800, 400]);
1627 module DemoHingeAngles(){ ////toplevel
1628 angles = [ 0, 4, 8, 12 ];
1629 echo("angles",angles);
1630 for (i=[0 : len(angles)-1]) {
1631 translate(i * [0, 0, 30]) {
1632 DemoHingeAngle(0,angles[i]);
1633 translate([0, 200, 0])
1634 DemoHingeAngle(angles[i],0);
1639 module DemoSelectAdhocLeftRight(right=0) {
1640 translate([phone_width/2, -400, -100]) // , -15, -100 to cross-section
1641 mirror([1-right, 0,0])
1642 cube([400, 800, 200]);
1645 module DemoLeft(){ ////toplevel
1646 color("red") intersection(){ Case(); DemoSelectAdhocLeftRight(); }
1647 color("blue") intersection(){ Lid(); DemoSelectAdhocLeftRight(); }
1650 module DemoFrame(){ ////toplevel
1651 color("red") render() TestFrameCase();
1652 color("blue") render() intersection(){ Lid(); TestSelectLidFrame(); }
1653 color("black") render() HingeScrews();
1654 %render() HingeLever();
1657 module DemoLanyardCutout(){ ////toplevel
1661 module DemoHingedFrame(){ ///toplevel
1662 color("red") render() TestFrameCase();
1663 translate([0,0, -2*hp_k])
1664 color("blue") render() intersection(){ Lid(); TestSelectLidFrame(); }
1667 color("orange") render() HingeLever();
1668 color("black") render() HingeScrews();
1672 module DemoHinge(){ ////toplevel
1673 translate([ -0.5*phone_width, phone_height, hp_k*3 ]) {
1675 translate([0,0, -hp_k*3])
1680 module DemoProfiles(){ ////toplevel
1684 translate([0,0,-1]) color("black") KeeperProfile(1);
1687 translate([0,0,+1]) color("purple") LanyardMainChannelProfile();
1688 translate([0,0,+2]) color("red") LanyardCurveChannelProfile();
1689 translate([0, ly_q_z]){
1690 translate([0,0,-1]) color("blue") LanyardEntryChannelProfile();
1691 translate([ly_oec_y,0,-2]) color("black") LanyardEntryOuterProfile();
1695 translate([0,0,-5]) color("white") translate(epp2i)
1697 rectfromto([-15, 0],
1698 [+15, -max_case_bottom_edge_thickness]);
1701 LanyardMainChannelProfile();
1702 translate([0,0,1]) color("purple") LanyardCurveChannelProfile();
1703 translate([0,0,-1]) color("red") LanyardEntryChannelProfile();
1710 demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
1712 color("blue") ButtonCoverProfile();
1714 rectfromto(bppQ, demopoint_QR);
1715 rectfromto(bppR, demopoint_QR);
1719 translate([-20,0]) {
1720 color("black") ButtonPlanForDemo(-2, 0,1);
1721 color("red" ) ButtonPlanForDemo(-4, 1,1);
1722 color("blue") ButtonPlanForDemo(-6, 1,0);
1725 translate([0, -30]) {
1728 color("blue") HingeLidProfile();
1729 color("red") HingeBaseProfile();
1730 color("black") translate([0,0,-2]) HingeLeverOuterProfile();
1734 translate([-30, -60 + 30*f]) {
1735 translate([0,0,-4]) EdgeProfile();
1736 %translate([0,0,-10]) HingeBaseProfile();
1737 translate([0,-2] * f * hp_k) {
1738 translate([0,0,-4]) LidEdgeProfile();
1739 %translate([0,0,-10]) %HingeLidProfile();
1741 translate(+hppB) rotate([0,0,180*f]) translate(-hppB) {
1742 translate([0,0,-2]) color("black") HingeLeverOuterProfile();
1743 translate([0,0,0]) color("red") difference(){
1744 HingeLeverOuterProfile();
1745 HingeLeverInnerProfile();
1747 translate([0,0,3]) color("yellow") HingeLeverNutProfile();
1752 translate([20,-30]) {
1755 //translate([0,0,1]) ThumbRecessCutProfile();
1756 translate([0,0,+1]) color("red")
1757 difference(){ EdgeProfile(); ThumbRecessCutProfile(); }
1760 translate([40,-30]) {
1764 PropProfile(10, 1, 0);
1769 translate([60,-30]) {
1770 PropAggregateProfile();