chiark / gitweb /
fairphone-battery-case: PushHolePlan better
[reprap-play.git] / fairphone-battery-case.scad
1 // -*- C -*-
2
3 mainwall_th = 3.0;
4 smallwall_th = 2.0;
5
6 seal_th = 0.3 + 0.6 + 0.6 - 0.4 - 0.4 + 0.2; // total gap for seal etc.
7 behind_recess = 1.5;
8
9 recess_gap_end = 0.4;
10
11 lid_edge_th = 0.5;
12
13 battery_len = 66.55 + 1.25 -.55;
14 battery_th = 6.55 + 0.75 - .60;
15 battery_wdth = 44.38 + 0.75 -.55;
16
17 battery_base_indent = 0.94 + 0.50;
18 battery_base_indent_fromside_outside = 4;
19 battery_base_indent_fromside_inside = 10;
20
21 handle_height = 3.5;
22 handle_inward = 10;
23 handle_len = 5;
24
25 pushhole_ell_sz = 3.75;
26 pushhole_ell_th = 1.75;
27 pushhole_circle_dia = 2.5;
28
29 // for testing:
30 battery_len = 3;
31 //battery_wdth = 15;
32 //battery_base_indent_fromside_inside = 6;
33
34 // calculated
35
36 bpp0 = [0,0];
37 bpp1 = bpp0 + [ 0, mainwall_th - behind_recess ];
38 lppA = bpp1 + [ seal_th, -recess_gap_end ];
39 lppB = lppA + [ lid_edge_th, 0 ];
40 bpp2 = [ lppB[0], bpp1[1] ];
41 bpp3 = [ bpp2[0] + (bpp1 - bpp0)[1], bpp0[1] ];
42 bpp4 = [ bpp3[0], bpp0[1] + mainwall_th ];
43 lppC = bpp3 + [ 0, -recess_gap_end ];
44
45 lppF = lppC + [ handle_height, 0 ];
46
47 s0 = battery_wdth/2;
48 s0i = s0 - battery_th/2;
49 s1 = s0 + smallwall_th;
50
51 l1 = s1 - handle_inward;
52 l0 = l1 - handle_len;
53
54 echo(
55      bpp0,
56      bpp1,
57      bpp2,
58      bpp3,
59      bpp4,
60      bpp5,
61      bpp6,
62      bpp7,
63      bpp8
64 );
65
66 echo(
67      lppA,
68      lppB,
69      lppC,
70      lppD,
71      lppE
72 );
73
74 bpp8 = bpp0 + [ -battery_len,0 ];
75 bpp5 = [ bpp8[0] - smallwall_th, bpp4[1] ];
76 bpp9 = [ bpp0[0], bpp0[1] - battery_th/2 - 1.0 ];
77 bpp7 = [ bpp8[0], bpp9[1] ];
78 bpp6 = [ bpp5[0], bpp9[1] ];
79 lppE = [ lppA[0], bpp9[1] ];
80 lppD = [ lppC[0], bpp9[1] ];
81
82 module BaseHalfPlan(indent=0){
83   polygon([ bpp0,
84             bpp1,
85             bpp2,
86             bpp3,
87             bpp4,
88             bpp5,
89             bpp6,
90             bpp7 + indent * [1,0],
91             bpp8 + indent * [1,0]
92             ]);
93 }
94
95 module SideHalfPlan(){
96   polygon([ bpp5,
97             bpp6,
98             bpp9,
99             bpp1
100             ]);
101 }
102
103 module LidHalfPlan(){
104   polygon([ lppA,
105             lppE,
106             lppD,
107             lppC,
108             lppB
109             ]);
110 }
111
112 module HandleHalfPlan(){
113   translate(lppE)
114     square(lppF - lppE);
115 }
116
117 module ExtrudePlan(from,to){
118   rotate([0,-90,0])
119   for (mj=[0,1]) {
120     mirror([0,0,mj]) translate([0,0,from]){
121       linear_extrude(height= to-from){
122         for (mi=[0,1]) {
123           mirror([0,mi])
124             translate([0, battery_th/2])
125             children(0);
126         }
127       }
128     }
129   }
130 }
131
132 module PushHolePlan(){ ////toplevel
133   translate(-pushhole_ell_th * 0.5 * [1,1]) {
134     for (r=[0,90])
135       rotate(r)
136         translate(-pushhole_ell_th * 0.5 * [1,1])
137         square([ pushhole_ell_sz, pushhole_ell_th ]);
138     circle(pushhole_circle_dia/2, $fn=20);
139   }
140 }
141
142 module PlanDemo(){ ////toplevel
143   color("blue") BaseHalfPlan();
144   color("red") LidHalfPlan();
145   translate([0,0,-1]) color("lightblue") SideHalfPlan();
146 }
147
148 module Base(){ ////toplevel
149   ExtrudePlan(0,s1) BaseHalfPlan();
150   difference(){
151     union(){
152       ExtrudePlan(s0i, s1) SideHalfPlan();
153       ExtrudePlan(s0 - battery_base_indent_fromside_inside,
154                   s0 - battery_base_indent_fromside_outside
155                   ) BaseHalfPlan(indent = battery_base_indent);
156     }
157     for (m=[0,1])
158       mirror([m,0,0])
159         translate([s0i, 0, bpp7[0] - 0.1])
160         cylinder(r= battery_th/2, h=100, $fs=0.5);
161   }
162 }
163
164 module BaseHalfTest(){ ////toplevel
165   intersection(){
166     Base();
167     translate([-100,0,-100])
168       cube([200,200,200]);
169   }
170 }
171
172 module Lid(){ ////toplevel
173   ExtrudePlan(0,s1) LidHalfPlan();
174   ExtrudePlan(l0,l1) HandleHalfPlan();
175 }
176
177 module Demo(){ ////toplevel
178   %Base();
179   Lid();
180 }
181
182 //PlanDemo();
183 //Demo();
184 //Base();