chiark / gitweb /
simplephone-case: adjust width
[reprap-play.git] / simplephone-case.scad
1 // -*- C -*-
2
3 psz = [
4        120,
5        56 + 5 - 3.75,
6        15 + 3,
7        ];
8
9 thick = [
10          2,
11          2,
12          1.5,
13          ];
14
15 btn_x = 56.4;
16 btn_dia = 13;
17 btn_y = 14.03;
18
19 abtn_x = 43.15;
20 abtn_sz = [ 11, 13 ];
21
22 screen_xbot = 79;
23 screen_sz = [ 35, 46 ];
24
25 thumb_xbot = 90;
26 thumb_dia = 25;
27
28 vol_xbot = 87.4;
29 vol_xtop = 106.7;
30 vol_depth = 1.0;
31 vol_zsz = 9;
32 vol_zoff = 0;
33
34 rail_ysz = 2.5;
35 rail_zsz = 2.5;
36
37 case_x_less = 0; //case_x_less = 10;
38
39 inner_cnr_rad = 3.0;
40
41 // calculated
42
43 btn_yprop = btn_y / psz[1];
44 echo(btn_yprop);
45
46 ym = psz[1]/2;
47 outer_cnr_rad = inner_cnr_rad + thick[2];
48
49 x_sliced = outer_cnr_rad * (1-sin(45));
50
51 $screen = true;
52
53 module RoundedProfile(sz, cnr_rad){
54   hull(){
55     for (x=[ cnr_rad, sz[0]-cnr_rad ])
56       for (y=[ cnr_rad, sz[1]-cnr_rad ])
57         translate([x,y])
58           circle(r= cnr_rad, $fn=20);
59   }
60 }
61
62 module RoundedCube(sz, cnr_rad){
63   if ($test)
64     cube(sz);
65   else hull(){
66     for (x=[ cnr_rad, sz[0]-cnr_rad ])
67       for (y=[ cnr_rad, sz[1]-cnr_rad ])
68         for (z=[ cnr_rad, sz[2]-cnr_rad ])
69           translate([x,y,z])
70             sphere(r= cnr_rad, $fn=20);
71   }
72 }
73
74 module Case(){
75   difference(){
76     mirror([1,0,0])
77       translate(-thick +
78                 - [1,0,0] * x_sliced)
79       RoundedCube(psz
80                   + 2*thick
81                   - [1,0,0] * (thick[0])
82                   + [1,0,0] * (x_sliced)
83                   - [case_x_less, 0, 0],
84                   outer_cnr_rad);
85
86     for (yp= [ btn_yprop, 1-btn_yprop ])
87       translate([ -btn_x,
88                   yp * psz[1],
89                   0.5 * psz[2] ])
90         cylinder(r= btn_dia/2, h=20);
91
92     translate([ -abtn_x,
93                 btn_yprop * psz[1],
94                 psz[2] ])
95       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
96
97     if ($screen)
98       mirror([1,0,0])
99       translate([ screen_xbot,
100                   (psz[1] - screen_sz[1])/2,
101                   psz[2]-1 ])
102       cube(concat(screen_sz, [ thick[2]+2 ]));
103
104     hull(){
105       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
106         translate([ -x,
107                     ym,
108                     -thick[2]-1 ])
109           cylinder(r= thumb_dia/2,
110                    h= thick[2] + 2,
111                    $fn= 20);
112     }
113
114     mirror([1,0,0])
115       translate([ (vol_xbot+vol_xtop)/2, 0, psz[2]/2 + vol_zoff ])
116       cube([ vol_xtop-vol_xbot, vol_depth*2, vol_zsz ], center=true);
117
118     translate([ thick[0], -10, -10 ])
119       cube([ 10, psz[1]+20, psz[2]+20 ]);
120
121     //translate([-50,-50,10]) cube([100,100,100]);
122
123     mirror([1,0,0])
124       difference(){
125         RoundedCube(psz + [1,0,0],
126                     inner_cnr_rad);
127
128         if (0) for (m=[0,1]) {
129           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
130             translate([-1,-1, psz[2]-rail_zsz])
131             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
132         }
133       }
134   }
135 }
136
137 module TestLoop(){
138   intersection(){
139     Case($screen=false);
140     translate([ -vol_xbot, 0,0 ])
141       cube([ 4, 200,200 ], center=true);
142   }
143 }
144
145 Case();
146 //TestLoop();
147 //RoundedCube(psz, inner_cnr_rad);