chiark / gitweb /
fairphone-case: wip new slide lock thing
[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_width = 2.5;
20 keeper_height = 2.5;
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 module rectfromto(a,b) {
46   ab = b - a;
47   translate([min(a[0], b[0]), min(a[1], b[1])])
48     square([abs(ab[0]), abs(ab[1])]);
49 }
50 module circleat(c,r) { translate(c) circle(r); }
51
52 module EdgeProfile(){
53   difference(){
54     hull(){
55       circleat(epp3, r=case_th_bottom);
56       circleat(epp2, r=case_th_bottom);
57       circleat(epp1, r=case_th_side);
58       rectfromto(epp0, epp4);
59     }
60     %polygon([ epp5 + [0,10],
61                epp1,
62                epp2,
63                epp3 + [10,0] ]);
64   }
65 }
66
67 module CaseBase_rhsflip() {
68   for (rhs=[0,1]) {
69     translate([phone_width/2, 0, 0])
70       mirror([rhs,0,0])
71       translate([-phone_width/2, 0, 0])
72       children();
73   }
74 }
75
76 module CaseBase_botflip() {
77   for (bot=[0,1]) {
78     translate([0, -phone_height/2, 0])
79       mirror([0, bot, 0])
80       translate([0, phone_height/2, 0])
81       children();
82   }
83 }  
84
85 module CaseBase(){
86   CaseBase_rhsflip(){
87     translate([0, -phone_cnr_rad, 0])
88       rotate([90,0,0])
89       linear_extrude(height = phone_height - phone_cnr_rad*2)
90       EdgeProfile();
91   }
92   CaseBase_rhsflip() CaseBase_botflip() {
93     translate([+1,-1] * phone_cnr_rad)
94       intersection(){
95         rotate_extrude()
96           intersection(){
97             mirror([1,0,0])
98               translate([-1,0] * phone_cnr_rad)
99               EdgeProfile();
100             rectfromto([0,-20],[10,20]);
101           }
102         translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
103           cube([10,10,40]);
104       }
105   }
106   CaseBase_botflip(){
107     translate([ phone_width - phone_cnr_rad, 0,0 ])
108       rotate([90,0,-90])
109       linear_extrude(height = phone_width - phone_cnr_rad*2)
110       EdgeProfile();
111   }
112 }
113
114 EdgeProfile();
115 //CaseBase();