chiark / gitweb /
fairphone-case: adjust fingerpushhole
[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 = [ 15, 18 ];
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], hppU[1] - hp_r1 ];
159 hppB = hppT + [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 Flip_hinge(){
461   hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
462   translate(hinge_origin)
463     rotate([180,0,0])
464     translate(-hinge_origin)
465     children();
466 }
467
468 module HingePortion(x0,x1){
469   Flip_rhs() Flip_bot(1)
470     translate([x0,0,0])
471     mirror([1,0,0])
472     rotate([90,0,-90])
473     linear_extrude(height=x1-x0)
474     children(0);
475 }
476
477 module CaseBase(){
478   AroundEdges(epp3[1], case_th_bottom, 1)
479     EdgeProfile();
480 }
481
482 module Case(){ ////toplevel
483   difference(){
484     union(){
485       CaseBase();
486
487       // ledge (fixed keeper)
488       intersection(){
489         rotate([90, 0, 0])
490           linear_extrude(height = phone_height + phone_cnr_rad * 2)
491           KeeperProfile(1);
492
493         // outline of the whole case, to stop it protruding
494         translate([0,0, -25])
495           linear_extrude(height = 50)
496           hull()
497           // Flip_rhs() // actually, we only care about the LH
498           Flip_bot()
499           circleat([+1,-1] * phone_cnr_rad, phone_cnr_rad + case_th_side/2);
500       }
501
502       // hinge
503       HingePortion(hex20, hex21) HingeBaseProfile();
504     }
505
506     // slot for keeper
507     Flip_rhs(1)
508       translate([0, -phone_cnr_rad, 0])
509       rotate([90, 0, 0])
510       linear_extrude(height = phone_height + phone_cnr_rad * 2)
511       minkowski(){
512         KeeperProfile();
513         rectfromto([ -keeper_gap_x,    -keeper_gap_z_bot ],
514                    [ keeper_gap_x_holes,    +keeper_gap_z_top ]);
515       }
516
517     // front camera
518     RearCameraAperture();
519
520     // struts (invisible, because they're buried in the case)
521     Struts(epp2i[0], epp2i[1] - case_th_bottom, case_th_bottom);
522
523     Buttons(){
524       mirror([1,0,0])
525         rotate([90,0,90]) {
526           intersection(){
527             translate([0,0,-10])
528               linear_extrude(height= 20)
529               ButtonPlan($button_l, 0,1);
530             if ($button_leg_only)
531               rotate([-90,90,0])
532                 translate([phone_width/2, -400, kppe[1]])
533                 mirror([$rhsflip,0,0]) cube([400, 800, 50]);
534           }
535           translate([0,0, -bppR[0]])
536             linear_extrude(height= 20)
537             ButtonPlan($button_l, 1,1);
538         }
539     }
540
541     // apertures along top edge
542     CaseAperture(jack_pos, jack_dia, 8);
543     Flip_rhs(1)
544       CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 20);
545
546     OrdinaryRearApertures();
547
548     MicroUSB();
549
550     // gaps for the lid's hinge arms
551     HingePortion(hex20 - hinge_x_arms_gap,
552                  hex21 + hinge_x_arms_gap)
553       minkowski(){
554         HingeLidProfile();
555         circle(r= hinge_r_arms_gap, $fn= 8);
556       }
557
558     // screw holes in the hinge arms
559     HingeScrews();
560   }
561 }
562
563 module Lid(){ ////toplevel
564   difference(){
565     union(){
566       AroundEdges(lpp10[1], lpp13[1] - lpp10[1], 0)
567         LidEdgeProfile();
568
569       // button covers
570       Buttons(){
571         intersection(){
572           rotate([90,0,90])
573             translate([0,0,-10])
574             linear_extrude(height= 20)
575             ButtonPlan($button_l, 1,0);
576           rotate([90,0,0])
577              translate([0,0,-100])
578             linear_extrude(height= 200)
579             ButtonCoverProfile();
580         }
581       }
582
583       // hinge arms
584       HingePortion(hex20, hex21) HingeLidProfile();
585     }
586     Struts(lpp10[0] + strut_min_at_end, lpp13[1], -case_th_lid);
587
588     // screw holes in the hinge arms
589     HingeScrews();
590   }
591 }
592
593 module HingeLever(){ ////toplevel
594   difference() {
595     // outer body, positive
596     HingePortion(hex22, hex22 + phone_width/2)
597       HingeLeverOuterProfile();
598
599     // space for the screws
600     HingePortion(hex23, hex24)
601       HingeLeverInnerProfile();
602
603     // bores for the screws
604     HingeScrews();
605
606     // space for the charging cable
607     MicroUSB();
608     Flip_hinge() MicroUSB();
609   }
610 }
611
612 module HingeLeverPrint(){ ////toplevel
613   rotate([90,0,0])
614     HingeLever();
615 }
616
617 module TestSelectLength(){
618   translate([-30, -200, -20])
619     cube([30 + 15, 250, 40]);
620 }
621
622 module TestLength(){ ////toplevel
623   intersection(){
624     Case();
625     TestSelectLength();
626   }
627 }
628
629 module TestLengthRight(){ ////toplevel
630   intersection(){
631     Case();
632     Flip_rhs(1)
633       TestSelectLength();
634   }
635 }
636
637 module TestSelectWidth(){
638   translate([-30, -(phone_height - 25), -20])
639     mirror([0, 1, 0])
640     cube([200, 50, 40]);
641 }
642
643 module TestWidth(){ ////toplevel
644   intersection(){
645     Case();
646     TestSelectWidth();
647   }
648 }
649
650 module TestLidWidthPrint(){ ////toplevel
651   rotate([0,180.0]) intersection(){
652     Lid();
653     TestSelectWidth();
654   }
655 }
656
657 module TestSelectRearAperture(){
658   minkowski(){
659     union() children();
660     translate([20, 0,0])
661       cube([42, 2, 1], center=true);
662   }
663 }
664
665 module TestSelectCamera(){
666   minkowski(){
667     TestSelectRearAperture()
668       RearCameraAperture();
669     cube([0.1, 50, 0.1]);
670   }
671 }
672
673 module TestSelectOrdinaryRearApertures(){
674   TestSelectRearAperture()
675     OrdinaryRearApertures();
676 }
677
678 module TestCamera(){ ////toplevel
679   intersection(){
680     Case();
681     TestSelectCamera();
682   }
683 }
684
685 module TestLidByCamera(){ ////toplevel
686   intersection(){
687     Lid();
688     TestSelectCamera();
689   }
690 }
691
692 module TestLidByCameraPrint(){ ////toplevel
693   rotate([180,0,0]) TestLidByCamera();
694 }
695
696 module DemoByCamera(){ ////toplevel
697   color("blue") TestLidByCamera();
698   color("red")  TestCamera();
699 }
700
701 module OneKeeper(){ ////toplevel
702   translate([0, -phone_cnr_rad, 0])
703     rotate([90, 0, 0])
704     linear_extrude(height = phone_height - phone_cnr_rad * 2)
705     KeeperProfile();
706 }
707
708 module OneKeeperPrint(){ ////toplevel
709   rotate([0,180,0])
710     OneKeeper();
711 }
712
713 module LidPrint(){ ////toplevel
714   rotate([0,180,0])
715     Lid();
716 }
717
718 module TestSelectFrame(){
719   include = [1,-1] * (epp2i[0] + 4);
720
721   difference(){
722     cube(1000, center=true);
723     translate([0,0, -100])
724       linear_extrude(height=200)
725       rectfromto(include,  inside_br - include);
726   }
727 }
728
729 module TestFrameCase(){ ////toplevel
730   intersection(){
731     Case();
732     union(){
733       TestSelectFrame();
734       TestSelectCamera();
735       TestSelectOrdinaryRearApertures();
736     }
737   }
738 }
739
740 module TestFrameLidPrint(){ ////toplevel
741   rotate([0,180,0]) intersection(){
742     Lid();
743     TestSelectFrame();
744   }
745 }
746
747 module Keeper(){ ////toplevel
748   Flip_rhs()
749     OneKeeper();
750 }
751
752 module ButtonPlanForDemo(z, deep, cut){
753   translate([0,0,z])
754     ButtonPlan(8, deep, cut);
755 }
756
757 module HingeScrews(){
758   Flip_rhs() Flip_bot(1){
759     for (c= [ hppT, hppB ])
760       translate([ hex20,
761                   -c[0],
762                   c[1] ]){
763         rotate([0,90,0])
764           translate([0,0,-.2])
765           cylinder( r= hingescrew_shaft_dia/2,
766                     h = hingescrew_shaft_len+0.2 );
767         rotate([0,-90,0])
768           translate([0,0,+.1])
769           cylinder( r= hingescrew_head_dia/2, h = hingescrew_head_th );
770       }
771   }
772 }
773
774 module DemoFrame(){ ////toplevel
775   color("red") TestFrameCase();
776   color("blue") intersection(){ Lid(); TestSelectFrame(); }
777   color("black") HingeScrews();
778   %HingeLever();
779 }
780
781 module DemoHingedFrame(){ ///toplevel
782   color("red") TestFrameCase();
783   translate([0,0, -2*hp_k])
784   color("blue") intersection(){ Lid(); TestSelectFrame(); }
785
786   Flip_hinge(){
787     color("orange") HingeLever();
788     color("black") HingeScrews();
789   }
790 }
791
792 module DemoHinge(){ ////toplevel
793   DemoFrame();
794   translate([0,0, -hp_k*3])
795     DemoHingedFrame();
796 }
797
798 module DemoProfiles(){ ////toplevel
799   LidEdgeProfile();
800   %EdgeProfile();
801   KeeperProfile();
802   translate([0,0,-1]) color("black") KeeperProfile(1);
803
804   translate([20,0]) {
805     LidEdgeProfile();
806     %EdgeProfile();
807
808     demopoint_QR = [ bppS[0], bppQ[1] - 0.1];
809   
810     color("blue") ButtonCoverProfile();
811     color("red") {
812       rectfromto(bppQ, demopoint_QR);
813       rectfromto(bppR, demopoint_QR);
814     }
815   }
816
817   translate([-20,0]) {
818     color("black") ButtonPlanForDemo(-2, 0,1);
819     color("red" )  ButtonPlanForDemo(-4, 1,1);
820     color("blue")  ButtonPlanForDemo(-6, 1,0);
821   }
822
823   translate([0, -30]) {
824     %LidEdgeProfile();
825     %EdgeProfile();
826     color("blue") HingeLidProfile();
827     color("red")  HingeBaseProfile();
828     color("black") translate([0,0,-2]) HingeLeverOuterProfile();
829     color("orange") translate([0,0,-1]) HingeLeverInnerProfile();
830   }
831 }
832
833 //EdgeProfile();
834 //KeeperProfile();
835 //CaseBase();
836 //%Case();
837 //Keeper();
838 //LidEdgeProfile();
839 //KeeperProfile();
840 //DemoProfiles();