chiark / gitweb /
b1a126bccc8623312a7989b94997a34495d4a65a
[reprap-play.git] / simplephone-case.scad
1 // -*- C -*-
2
3 psz = [
4        120,
5        56 + 5,
6        15 + 3,
7        ];
8
9 thick = [
10          2,
11          2,
12          2.5,
13          ];
14
15 btn_x = 58;
16 btn_dia = 13;
17 btn_yprop = 0.23;
18
19 abtn_x = 45;
20 abtn_sz = [ 11, 13 ];
21
22 screen_xbot = 67;
23 screen_sz = [ 45, 46 ];
24
25 thumb_xbot = 90;
26 thumb_dia = 25;
27
28 rail_ysz = 2.5;
29 rail_zsz = 2.5;
30
31 case_x_less = 0; //case_x_less = 10;
32
33 inner_cnr_rad = 3.0;
34
35 // calculated
36
37 ym = psz[1]/2;
38 outer_cnr_rad = inner_cnr_rad + thick[2];
39
40 module RoundedProfile(sz, cnr_rad){
41   hull(){
42     for (x=[ cnr_rad, sz[0]-cnr_rad ])
43       for (y=[ cnr_rad, sz[1]-cnr_rad ])
44         translate([x,y])
45           circle(r= cnr_rad, $fn=20);
46   }
47 }
48
49 module RoundedCube(sz, cnr_rad){
50   hull(){
51     for (x=[ cnr_rad, sz[0]-cnr_rad ])
52       for (y=[ cnr_rad, sz[1]-cnr_rad ])
53         for (z=[ cnr_rad, sz[2]-cnr_rad ])
54           translate([x,y,z])
55             sphere(r= cnr_rad, $fn=20);
56   }
57 }
58
59 module Case(){
60   difference(){
61     mirror([1,0,0])
62       translate(-thick)
63       RoundedCube(psz
64                   + 2*thick
65                   - [1,0,0] * (thick[0])
66                   - [case_x_less, 0, 0],
67                   outer_cnr_rad);
68
69     for (yp= [ btn_yprop, 1-btn_yprop ])
70       translate([ -btn_x,
71                   yp * psz[1],
72                   0.5 * psz[2] ])
73         cylinder(r= btn_dia/2, h=20);
74
75     translate([ -abtn_x,
76                 btn_yprop * psz[1],
77                 psz[2] ])
78       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
79
80     mirror([1,0,0])
81       translate([ screen_xbot,
82                   (psz[1] - screen_sz[1])/2,
83                   psz[2]-1 ])
84       cube(concat(screen_sz, [ thick[2]+2 ]));
85
86     hull(){
87       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
88         translate([ -x,
89                     ym,
90                     -thick[2]-1 ])
91           cylinder(r= thumb_dia/2,
92                    h= thick[2] + 2,
93                    $fn= 20);
94     }
95
96     //translate([ thick[0] - 
97     //cube([
98
99     mirror([1,0,0])
100       difference(){
101         RoundedCube(psz + [1,0,0],
102                     inner_cnr_rad);
103
104         if (0) for (m=[0,1]) {
105           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
106             translate([-1,-1, psz[2]-rail_zsz])
107             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
108         }
109       }
110   }
111 }
112
113 Case();
114 //RoundedCube(psz, inner_cnr_rad);