chiark / gitweb /
fairphone-case: keeper
[reprap-play.git] / fairphone-case.scad
1 // -*- C -*-
2
3 phone_height = 146.5;
4 phone_width = 76.75;
5
6 phone_cnr_rad = 4.0;
7
8 phone_edge_thick = 9.0;
9 phone_total_thick = 12.0;
10 phone_backside_slope = 1.0; // larger means shallower
11
12 case_th_bottom = 2;
13 case_th_lid = 2;
14 case_th_side = 2;
15 case_th_lip = 1.2;
16
17 keeper_th_z = 0.75;
18 keeper_th_x = 0.75;
19 keeper_inner_width = 1.75;
20 keeper_inner_height = 1.75;
21
22 keeper_gap_z_top = 0.25;
23 keeper_gap_z_bot = 0.25;
24 keeper_gap_x     = 0.25;
25
26 case_lip = 1.25;
27
28 $fa = 5;
29 $fs = 0.1;
30
31 // calculated
32
33 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
34
35 //lid_lip_overlap_width xxx bad name = ;
36 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
37
38 epp0 = [0,0];
39 epp1 = [0, -phone_edge_thick];
40 epp2 = epp1 + phone_backside_slope_thick * [ phone_backside_slope, -1 ];
41 epp3 = epp2 + [10, 0];
42 epp5 = epp0 + [0,1] * (keeper_th_z + keeper_gap_z_top + case_lip);
43 epp4 = epp5 + [-1,0] * case_th_side;
44
45 kppe = [0,0];
46 kppd = kppe + [1,0] * keeper_inner_width;
47 kppc = kppd + [0,1] * keeper_th_z;
48 kppb = [ kppe[0] - keeper_th_x, kppc[1] ];
49 kppf = kppe - [0,1] * keeper_inner_height;
50 kppa = [ kppb[0], kppf[1] ];
51
52 module rectfromto(a,b) {
53   ab = b - a;
54   translate([min(a[0], b[0]), min(a[1], b[1])])
55     square([abs(ab[0]), abs(ab[1])]);
56 }
57 module circleat(c,r) { translate(c) circle(r); }
58
59 module KeeperProfile(){
60   polygon([kppe, kppd, kppc, kppb, kppa, kppf]);
61 }
62
63 module EdgeProfile(){
64   difference(){
65     hull(){
66       circleat(epp3, r=case_th_bottom);
67       circleat(epp2, r=case_th_bottom);
68       circleat(epp1, r=case_th_side);
69       rectfromto(epp0, epp4);
70     }
71     polygon([ epp5 + [0,10],
72               epp1,
73               epp2,
74               epp3 + [10,0] ]);
75     minkowski(){
76       KeeperProfile();
77       rectfromto([ -keeper_gap_x,    -keeper_gap_z_bot ],
78                  [            10,    +keeper_gap_z_top ]);
79     }
80   }
81 }
82
83 module CaseBase_rhsflip() {
84   for (rhs=[0,1]) {
85     translate([phone_width/2, 0, 0])
86       mirror([rhs,0,0])
87       translate([-phone_width/2, 0, 0])
88       children();
89   }
90 }
91
92 module CaseBase_botflip() {
93   for (bot=[0,1]) {
94     translate([0, -phone_height/2, 0])
95       mirror([0, bot, 0])
96       translate([0, phone_height/2, 0])
97       children();
98   }
99 }  
100
101 module CaseBase(){
102   CaseBase_rhsflip(){
103     translate([0, -phone_cnr_rad, 0])
104       rotate([90,0,0])
105       linear_extrude(height = phone_height - phone_cnr_rad*2)
106       EdgeProfile();
107   }
108   CaseBase_rhsflip() CaseBase_botflip() {
109     translate([+1,-1] * phone_cnr_rad)
110       intersection(){
111         rotate_extrude()
112           intersection(){
113             mirror([1,0,0])
114               translate([-1,0] * phone_cnr_rad)
115               EdgeProfile();
116             rectfromto([0,-20],[10,20]);
117           }
118         translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
119           cube([10,10,40]);
120       }
121   }
122   CaseBase_botflip(){
123     translate([ phone_width - phone_cnr_rad, 0,0 ])
124       rotate([90,0,-90])
125       linear_extrude(height = phone_width - phone_cnr_rad*2)
126       EdgeProfile();
127   }
128 }
129
130 EdgeProfile();
131 //KeeperProfile();
132 //CaseBase();