chiark / gitweb /
fairphone-case: introduce MicroUSB
[reprap-play.git] / fairphone-case.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 phone = [ 75.0, 145.0 ];
6
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.
10
11 phone_cnr_rad = 6.0;
12
13 button_cutout_depth = 9;
14
15 phone_edge_thick = 9.0;
16 phone_total_thick = 12.0;
17 phone_backside_slope_inner = 1.5; // larger means shallower
18 phone_backside_slope_outer = 1.0; // larger means shallower
19
20 camera_pos_tl = [  6.450, 12.750 ]; // measured from tl corner
21 camera_pos_br = [ 22.300, 37.600 ]; // tl/br as seen from back
22
23 jack_pos = [ 13.92, 7.96 ];
24 jack_dia = 9.1 + .5; // some jack I had lying around
25
26 noisecancelmic_pos = [ 19.54, 7.37 ];   // from rhs
27 noisecancelmic_dia = 1.75;
28
29 fingerpushhole_dias = [ 14, 17 ];
30
31 rearspeaker_pos_bl = [ 12.64, 18.72 ];
32 rearspeaker_size   = [  3.76,  7.36 ];
33
34 microusb_above = 4.48 + 0.50;
35 microusb_below = 1.82 + 0.50;
36 microusb_width = 10.60 + 1.00;
37
38 case_th_bottom = 2.5;
39 case_th_lid = 2.5;
40 case_th_side = 2;
41 case_th_lip = 1.2;
42
43 case_struts_count = 6;
44 case_struts_solid_below = 1.00;
45 case_struts_solid_above = 0.75;
46 case_struts_width = 0.10;
47
48 keeper_th_z = 0.75;
49 keeper_th_x = 0.75;
50 keeper_inner_width = 2.75;
51 keeper_inner_height = 2.75;
52 keeper_slant_slope = 2; // larger means steeper
53
54 keeper_gap_z_top = 0.25;
55 keeper_gap_z_bot = 0.75;
56 keeper_gap_x     = 0.25;
57 keeper_gap_x_holes = 0.75;
58
59 case_lip = 1.25;
60
61 lid_gap_x = 0.25;
62 lid_gap_z = 0.25;
63 lid_lip = 1.75;
64
65 foldover_gap = 0.50;
66 foldover_lever_gap = 0.50;
67
68 hingescrew_shaft_dia = 2.0 + 0.25; // M2 x 12mm machine screw
69 hingescrew_shaft_len = 12;
70 hingescrew_nut_thick = 1.93 + 0.20; // incl. washer
71 hingescrew_nut_dia = 4.72 + 0.50; // washer, actually
72 hingescrew_head_th = 1.38 + 0.75;
73 hingescrew_head_dia = 3.92;
74 lever_cover_th = 0.75;
75 hingemount_th = 2.5;
76
77 $fa = 5;
78 $fs = 0.1;
79
80 button_l_fudge = 4.4;
81 buttonishleg_default_l_is_fudge = 10;
82
83 strut_min_at_end = 1.5;
84
85 hinge_x_gap = 0.125;
86 hinge_x_postscrew_gap = 0.75;
87 hinge_x_arms_gap = 0.35;
88 hinge_r_arms_gap = 0.55;
89
90 rearspeaker_gap    = [ 1.0, 1.0 ]; // each side
91
92 // ---------- calculated ----------
93
94 phone_width =  (phone + bumper*2)[0];
95 phone_height = (phone + bumper*2)[1];
96
97 inside_br = [phone_width, -phone_height];
98
99 //echo(camera_pos_tl + bumper,
100 //     camera_pos_br + bumper);
101
102 // ----- could be changed -----
103 lid_buttoncover_gap = lid_gap_x;
104 lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
105
106 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
107
108 //lid_lip_overlap_width xxx bad name = ;
109 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
110
111 epp0 = [0,0];
112 epp1 = [0, -phone_edge_thick];
113 epp2i = epp1 + phone_backside_slope_thick * [ phone_backside_slope_inner, -1 ];
114 epp2o = epp1 + phone_backside_slope_thick * [ phone_backside_slope_outer, -1 ];
115 epp3 = epp2i + [10, 0];
116 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
117 epp4 = epp5 + [-1,0] * case_th_side;
118
119 kppe = [0,0];
120 kppd = kppe + [1,0] * keeper_inner_width;
121 kppc = kppd + [0,1] * keeper_th_z;
122 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
123 kppf = kppe - [0,1] * keeper_inner_height;
124 kppa = [ kppb[0], kppf[1] ];
125
126 lpp10 = [ epp5[0] + lid_gap_x, kppc[1] + lid_gap_z ];
127 lpp11 = [ lpp10[0],            epp5[1] + lid_gap_z ];
128
129 lp_r12 = case_th_lid - (lpp11[1] - lpp10[1]);
130
131 lpp12 = [ epp4[0] + lp_r12,    lpp11[1] ];
132 lpp13 = [ lpp12[0],            lpp12[1] + lp_r12 ];
133
134 // button profile
135 bppM = epp4 + [0,5];
136 bppN = [ 0.5 * (epp0[0] + epp4[0]), bppM[1] ];
137 bppR = [ bppN[0] + lid_buttoncover_gap, -button_cutout_depth ];
138 bppS = [ epp1[0], bppR[1] ];
139 bppQ = [ bppM[0], bppR[1] - lid_buttoncover_overlap ];
140 bppP = bppQ + [0,1] * lid_buttoncover_gap;
141 bppO = [ bppN[0], bppP[1] ];
142 bppL = lpp10 + [5,0];
143 bppK = [ bppL[0], bppN[1] ];
144 bppJ = [ bppN[0], bppL[1] ];
145
146 // hinge plan
147 hp_rn = hingescrew_nut_dia/2;
148 hp_r2 = hp_rn + lever_cover_th;
149 hp_rs = hingescrew_shaft_dia/2;
150 hp_r1 = hp_rs + hingemount_th;
151
152 hppU = lpp13;
153 hppS = epp2o + [0,-1] * case_th_bottom;
154 hp_k = 0.5 * (hppU[1] - hppS[1] + foldover_gap);
155
156 hppM = [ epp4[0] - foldover_lever_gap - hp_r2,
157          0.5 * (hppU + hppS)[1] ];
158 hppT = hppM + 0.5 * [0,+1] * hp_k;
159 hppB = hppM + 0.5 * [0,-1] * hp_k;
160
161 // hinge elevation x coords
162
163 hingescrew_portion_len =
164   0.5* (hingescrew_shaft_len - hingescrew_nut_thick - hinge_x_gap);
165
166 hex20 = max(epp2o[0],
167             phone_cnr_rad,
168             kppd[0] + hingescrew_head_th + keeper_gap_x_holes);
169 hex21 = hex20 + hingescrew_portion_len;
170 hex22 = hex21 - hinge_x_gap;
171 hex23 = hex22 + hingescrew_portion_len;
172 hex24 = hex20 + hingescrew_shaft_len + hinge_x_postscrew_gap;
173 echo(hex20, hex21, hex22, hex23, hex24);
174 echo(hingescrew_portion_len);
175
176 // ---------- modules ----------
177
178 module KeeperProfile(slant=0){
179   use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
180   polygon([use_e, kppd, kppc, kppb, kppa, kppf]);
181 }
182
183 module EdgeProfile(){
184   difference(){
185     hull(){
186       translate(epp3) square(case_th_bottom*2, center=true);
187       circleat(epp2o, r=case_th_bottom);
188       circleat(epp1, r=case_th_side);
189       rectfromto(epp0, epp4);
190     }
191     polygon([ epp5 + [0,10],
192               epp1,
193               epp2i,
194               epp3 + [10,0] ]);
195   }
196 }
197
198 module LidEdgeProfile(){
199   polygon([ lpp10,
200             lpp11,
201             lpp12,
202             lpp13,
203             lpp13 + [10, 0],
204             lpp10 + [10, 0]
205             ]);
206   intersection(){
207     circleat(lpp12, r=lp_r12);
208     rectfromto( lpp12 + [-10,   0],
209                 lpp12 + [+10, +10] );
210   }
211 }
212
213 module ButtonCoverProfile(){
214   intersection(){
215     polygon([ bppM, bppP, bppO, bppJ, bppL, bppK ]);
216     hull(){
217       EdgeProfile();
218       LidEdgeProfile();
219     }
220   }
221 }
222
223 module ButtonPlan(l, deep, cut){
224   epsilon =
225     (cut  ? 0 : lid_buttoncover_gap);
226
227   delta =
228     (deep ? lid_buttoncover_overlap : 0);
229
230   C = [0,0]; // by definition
231   T = [ 0, epp4[1] ];
232   G = T + [0,10];
233
234   B0 = C + [0,-1] * button_cutout_depth;
235   B1 = B0 + [0,1] * epsilon;
236
237   r0 = 0.5 * (T[1] - B0[1]);
238   A = [  -(l + button_l_fudge)/2 + r0, 0.5 * (T[1] + B0[1]) ];
239   H = A + [0,-1] * delta;
240
241   D = A + [-2,0] * r0;
242   F = D + [0,10];
243
244   E0 = 0.5 * (D + A);
245   E1 = E0 + [1,0] * epsilon;
246
247   I0 = [ E0[0], H[1] ];
248   I1 = [ E1[0], H[1] ];
249
250   hull(){
251     for (m=[0,1]) mirror([m,0])
252       circleat(H, r0 - epsilon);
253   }
254   for (m=[0,1]) mirror([m,0]) {
255     difference(){
256       polygon([ E1,
257                 I1,
258                 H,
259                 B1,
260                 G,
261                 F,
262                 D
263                 ]);
264       circleat(D, r0 + epsilon);
265     }
266   }
267 }
268
269 module Flip_rhs(yn=[0,1]) {
270   for ($rhsflip=yn) {
271     translate([phone_width/2, 0, 0])
272       mirror([$rhsflip,0,0])
273       translate([-phone_width/2, 0, 0])
274       children();
275   }
276 }
277
278 module Flip_bot(yn=[0,1]) {
279   for ($botflip=yn) {
280     translate([0, -phone_height/2, 0])
281       mirror([0, $botflip, 0])
282       translate([0, phone_height/2, 0])
283       children();
284   }
285 }  
286
287 module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
288   // sides
289   Flip_rhs(){
290     translate([0, -phone_cnr_rad, 0])
291       rotate([90,0,0])
292       linear_extrude(height = phone_height - phone_cnr_rad*2)
293       children(0);
294   }
295   // corners
296   Flip_rhs() Flip_bot() {
297     translate([+1,-1] * phone_cnr_rad)
298       intersection(){
299         rotate_extrude()
300           intersection(){
301             mirror([1,0,0])
302               translate([-1,0] * phone_cnr_rad)
303               children(0);
304             rectfromto([0,-20],[10,20]);
305           }
306         translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
307           cube([10,10,40]);
308       }
309   }
310   // top and bottom
311   Flip_bot(){
312     translate([ phone_width - phone_cnr_rad, 0,0 ])
313       rotate([90,0,-90])
314       linear_extrude(height = phone_width - phone_cnr_rad*2)
315       children(0);
316   }
317   // fill
318   translate([0,0, fill_zstart])
319     mirror([0,0, fill_downwards])
320     linear_extrude(height = fill_th)
321     rectfromto([+1,-1] * phone_cnr_rad,
322                [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
323 }
324
325 module CaseAperture(pos, dia, $fn) {
326   theta = 180/$fn;
327   translate([ pos[0] + bumper[0],
328               -epp2i[0],
329               -pos[1] ])
330     rotate([-90, theta, 0])
331     cylinder(r = dia/2 / cos(theta),
332              h = 60);
333 }
334
335 module SideButton(y, y_ref_sign, l){
336   // y_ref_sign:
337   //   +1  measured from top    of actual phone to top    of button
338   //   -1  measured from bottom of actual phone to bottom of button
339   //    0  y is centre of button in coordinate system
340   $button_l= l;
341   eff_y = y_ref_sign > 0 ?         -bumper [1] -y -l/2 :
342           y_ref_sign < 0 ? (-phone -bumper)[1] +y +l/2 :
343           y;
344   //echo(eff_y);
345   translate([0, eff_y, 0])
346     children();
347 }
348
349 module LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
350   $button_leg_only = true;
351   SideButton(y, y_ref_sign, l) children();
352 }
353
354 module Buttons(){
355   Flip_rhs(1) SideButton(15.580, +1, 8.9) children(); // power
356   Flip_rhs(1) SideButton(48.700, -1, 8.920) children(); // camera
357   Flip_rhs(0) SideButton(30.800, +1, 21.96) children(); // volume
358   Flip_rhs(   ) LidButtonishLeg(20, -1) children();
359 //  Flip_rhs(0) LidButtonishLeg(20, +1, 20) children();
360 }
361
362 module Struts(x_start, z_min, th){
363   // if th is negative, starts at z_min and works towards -ve z
364   // and object should then be printed other way up
365   for (i= [1 : 1 : case_struts_count]) {
366     translate([0,
367                0,
368                z_min])
369       mirror([0,0, th<0 ? 1 : 0])
370       translate([0,
371                  -phone_height * i / (case_struts_count+1),
372                  case_struts_solid_below])
373       linear_extrude(height= abs(th)
374                      -(case_struts_solid_below+case_struts_solid_above))
375       rectfromto([               x_start, -0.5 * case_struts_width ],
376                  [ phone_width - x_start, +0.5 * case_struts_width ]);
377   }
378 }
379
380 module OrdinaryRearAperture(rhs,bot, pos){
381   Flip_rhs(rhs) Flip_bot(bot)
382     linextr(-20, 20)
383     mirror([0,1])
384     translate(pos + bumper)
385     children();
386 }
387
388 module MicroUSB(){
389   Flip_bot(1){
390     rotate([90,0,0])
391       mirror([0,0,1])
392       linextr(-epp2i[0], 60)
393       translate([0.5 * phone_width, 0, 0])
394       rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
395                  [+microusb_width/2, epp0[1] + -microusb_above]);
396   }
397 }
398
399 module OrdinaryRearApertures(){
400   // rear speaker
401   OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
402     rectfromto(-rearspeaker_gap,
403                rearspeaker_size + rearspeaker_gap);
404
405   // finger hole to remove phone
406   OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
407                               phone[1]/2 ])
408     scale(fingerpushhole_dias)
409     circle(r= 0.5 );
410 }
411
412 module RearCameraAperture(){
413   Flip_rhs(1)
414     mirror([0, 0, 1])
415     linear_extrude(height = 20)
416     mirror([0, 1, 0])
417     translate(bumper)
418     rectfromto(camera_pos_tl, camera_pos_br);
419 }
420
421 module HingeLidProfile(){
422   hull(){
423     circleat(hppT, hp_r1);
424     circleat(lpp12, lp_r12);
425     polygon([lpp10,
426              lpp13 + [2,0],
427              lpp12,
428              hppT]);
429   }
430 }
431
432 module HingeBaseProfile(){
433   difference(){
434     hull(){
435       circleat(hppB, hp_r1);
436       circleat(epp2o, case_th_bottom);
437       circleat(hppB + [10,0], hp_r1);
438     }
439     polygon([epp5, epp1, epp2i, epp3, bppL]);
440   }
441 }
442
443 module HingeLeverOuterProfile(){
444   hull(){
445     circleat(hppT, hp_r2);
446     circleat(hppB, hp_r2);
447   }
448 }
449
450 module HingeLeverInnerProfile(){
451   for (c = [hppT, hppB]) {
452     hull()
453       for (x=[0,20])
454         translate([x,0])
455           circleat(c, hp_rn);
456         circleat(hppB, hp_rn);
457   }
458 }
459
460 module HingePortion(x0,x1){
461   Flip_rhs() Flip_bot(1)
462     translate([x0,0,0])
463     mirror([1,0,0])
464     rotate([90,0,-90])
465     linear_extrude(height=x1-x0)
466     children(0);
467 }
468
469 module CaseBase(){
470   AroundEdges(epp3[1], case_th_bottom, 1)
471     EdgeProfile();
472 }
473
474 module Case(){ ////toplevel
475   difference(){
476     union(){
477       CaseBase();
478
479       // ledge (fixed keeper)
480       intersection(){
481         rotate([90, 0, 0])
482           linear_extrude(height = phone_height + phone_cnr_rad * 2)
483           KeeperProfile(1);
484
485         // outline of the whole case, to stop it protruding
486         translate([0,0, -25])
487           linear_extrude(height = 50)
488           hull()
489           // Flip_rhs() // actually, we only care about the LH
490           Flip_bot()
491           circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
492       }
493
494       // hinge
495       HingePortion(hex20, hex21) HingeBaseProfile();
496     }
497
498     // slot for keeper
499     Flip_rhs(1)
500       translate([0, -phone_cnr_rad, 0])
501       rotate([90, 0, 0])
502       linear_extrude(height = phone_height + phone_cnr_rad * 2)
503       minkowski(){
504         KeeperProfile();
505         rectfromto([ -keeper_gap_x,    -keeper_gap_z_bot ],
506                    [ keeper_gap_x_holes,    +keeper_gap_z_top ]);
507       }
508
509     // front camera
510     RearCameraAperture();
511
512     // struts (invisible, because they're buried in the case)
513     Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
514
515     Buttons(){
516       mirror([1,0,0])
517         rotate([90,0,90]) {
518           intersection(){
519             translate([0,0,-10])
520               linear_extrude(height= 20)
521               ButtonPlan($button_l, 0,1);
522             if ($button_leg_only)
523               rotate([-90,90,0])
524                 translate([phone_width/2, -400, kppe[1]])
525                 mirror([$rhsflip,0,0]) cube([400, 800, 50]);
526           }
527           translate([0,0, -bppR[0]])
528             linear_extrude(height= 20)
529             ButtonPlan($button_l, 1,1);
530         }
531     }
532
533     // apertures along top edge
534     CaseAperture(jack_pos, jack_dia, 8);
535     Flip_rhs(1)
536       CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 20);
537
538     OrdinaryRearApertures();
539
540     MicroUSB();
541
542     // gaps for the lid's hinge arms
543     HingePortion(hex20 - hinge_x_arms_gap,
544                  hex21 + hinge_x_arms_gap)
545       minkowski(){
546         HingeLidProfile();
547         circle(r= hinge_r_arms_gap, $fn= 8);
548       }
549
550     // screw holes in the hinge arms
551     HingeScrews();
552   }
553 }
554
555 module Lid(){ ////toplevel
556   difference(){
557     union(){
558       AroundEdges(lpp10[1], lpp13[1] - lpp10[1], 0)
559         LidEdgeProfile();
560
561       // button covers
562       Buttons(){
563         intersection(){
564           rotate([90,0,90])
565             translate([0,0,-10])
566             linear_extrude(height= 20)
567             ButtonPlan($button_l, 1,0);
568           rotate([90,0,0])
569              translate([0,0,-100])
570             linear_extrude(height= 200)
571             ButtonCoverProfile();
572         }
573       }
574
575       // hinge arms
576       HingePortion(hex20, hex21) HingeLidProfile();
577     }
578     Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
579
580     // screw holes in the hinge arms
581     HingeScrews();
582   }
583 }
584
585 module HingeLever(){ ////toplevel
586   difference() {
587     // outer body, positive
588     HingePortion(hex22, hex22 + phone_width/2)
589       HingeLeverOuterProfile();
590
591     // space for the screws
592     HingePortion(hex23, hex24)
593       HingeLeverInnerProfile();
594
595     // bores for the screws
596     HingeScrews();
597   }
598 }
599
600 module HingeLeverPrint(){ ////toplevel
601   rotate([90,0,0])
602     HingeLever();
603 }
604
605 module TestSelectLength(){
606   translate([-30, -200, -20])
607     cube([30 + 15, 250, 40]);
608 }
609
610 module TestLength(){ ////toplevel
611   intersection(){
612     Case();
613     TestSelectLength();
614   }
615 }
616
617 module TestLengthRight(){ ////toplevel
618   intersection(){
619     Case();
620     Flip_rhs(1)
621       TestSelectLength();
622   }
623 }
624
625 module TestSelectWidth(){
626   translate([-30, -(phone_height - 25), -20])
627     mirror([0, 1, 0])
628     cube([200, 50, 40]);
629 }
630
631 module TestWidth(){ ////toplevel
632   intersection(){
633     Case();
634     TestSelectWidth();
635   }
636 }
637
638 module TestLidWidthPrint(){ ////toplevel
639   rotate([0,180.0]) intersection(){
640     Lid();
641     TestSelectWidth();
642   }
643 }
644
645 module TestSelectRearAperture(){
646   minkowski(){
647     union() children();
648     translate([20, 0,0])
649       cube([42, 2, 1], center=true);
650   }
651 }
652
653 module TestSelectCamera(){
654   minkowski(){
655     TestSelectRearAperture()
656       RearCameraAperture();
657     cube([0.1, 50, 0.1]);
658   }
659 }
660
661 module TestSelectOrdinaryRearApertures(){
662   TestSelectRearAperture()
663     OrdinaryRearApertures();
664 }
665
666 module TestCamera(){ ////toplevel
667   intersection(){
668     Case();
669     TestSelectCamera();
670   }
671 }
672
673 module TestLidByCamera(){ ////toplevel
674   intersection(){
675     Lid();
676     TestSelectCamera();
677   }
678 }
679
680 module TestLidByCameraPrint(){ ////toplevel
681   rotate([180,0,0]) TestLidByCamera();
682 }
683
684 module DemoByCamera(){ ////toplevel
685   color("blue") TestLidByCamera();
686   color("red")  TestCamera();
687 }
688
689 module OneKeeper(){ ////toplevel
690   translate([0, -phone_cnr_rad, 0])
691     rotate([90, 0, 0])
692     linear_extrude(height = phone_height - phone_cnr_rad * 2)
693     KeeperProfile();
694 }
695
696 module OneKeeperPrint(){ ////toplevel
697   rotate([0,180,0])
698     OneKeeper();
699 }
700
701 module LidPrint(){ ////toplevel
702   rotate([0,180,0])
703     Lid();
704 }
705
706 module TestSelectFrame(){
707   include = [1,-1] * (epp2i[0] + 4);
708
709   difference(){
710     cube(1000, center=true);
711     translate([0,0, -100])
712       linear_extrude(height=200)
713       rectfromto(include,  inside_br - include);
714   }
715 }
716
717 module TestFrameCase(){ ////toplevel
718   intersection(){
719     Case();
720     union(){
721       TestSelectFrame();
722       TestSelectCamera();
723       TestSelectOrdinaryRearApertures();
724     }
725   }
726 }
727
728 module TestFrameLidPrint(){ ////toplevel
729   rotate([0,180,0]) intersection(){
730     Lid();
731     TestSelectFrame();
732   }
733 }
734
735 module Keeper(){ ////toplevel
736   Flip_rhs()
737     OneKeeper();
738 }
739
740 module ButtonPlanForDemo(z, deep, cut){
741   translate([0,0,z])
742     ButtonPlan(8, deep, cut);
743 }
744
745 module HingeScrews(){
746   Flip_rhs() Flip_bot(1){
747     for (c= [ hppT, hppB ])
748       translate([ hex20,
749                   -c[0],
750                   c[1] ]){
751         rotate([0,90,0])
752           translate([0,0,-.2])
753           cylinder( r= hingescrew_shaft_dia/2,
754                     h = hingescrew_shaft_len+0.2 );
755         rotate([0,-90,0])
756           translate([0,0,+.1])
757           cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
758       }
759   }
760 }
761
762 module DemoFrame(){ ////toplevel
763   color("red") TestFrameCase();
764   color("blue") intersection(){ Lid(); TestSelectFrame(); }
765   color("black") HingeScrews();
766   %HingeLever();
767 }
768
769 module DemoHingedFrame(){ ///toplevel
770   hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
771
772   color("red") TestFrameCase();
773   translate([0,0, -2*hp_k])
774   color("blue") intersection(){ Lid(); TestSelectFrame(); }
775   
776   translate(hinge_origin)
777     rotate([180,0,0])
778     translate(-hinge_origin) {
779       color("orange") HingeLever();
780       color("black") HingeScrews();
781     }
782 }
783
784 module DemoHinge(){ ////toplevel
785   DemoFrame();
786   translate([0,0, -hp_k*3])
787     DemoHingedFrame();
788 }
789
790 module DemoProfiles(){ ////toplevel
791   LidEdgeProfile();
792   %EdgeProfile();
793   KeeperProfile();
794   translate([0,0,-1]) color("black") KeeperProfile(1);
795
796   translate([20,0]) {
797     LidEdgeProfile();
798     %EdgeProfile();
799
800     demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
801   
802     color("blue") ButtonCoverProfile();
803     color("red") {
804       rectfromto(bppQ, demopoint_QR);
805       rectfromto(bppR, demopoint_QR);
806     }
807   }
808
809   translate([-20,0]) {
810     color("black") ButtonPlanForDemo(-2, 0,1);
811     color("red" )  ButtonPlanForDemo(-4, 1,1);
812     color("blue")  ButtonPlanForDemo(-6, 1,0);
813   }
814
815   translate([0, -30]) {
816     %LidEdgeProfile();
817     %EdgeProfile();
818     color("blue") HingeLidProfile();
819     color("red")  HingeBaseProfile();
820     color("black") translate([0,0,-2]) HingeLeverOuterProfile();
821     color("orange") translate([0,0,-1]) HingeLeverInnerProfile();
822   }
823 }
824
825 //EdgeProfile();
826 //KeeperProfile();
827 //CaseBase();
828 //%Case();
829 //Keeper();
830 //LidEdgeProfile();
831 //KeeperProfile();
832 //DemoProfiles();