chiark / gitweb /
quacks-ingredients: -counts: Include spares in Base_White
[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 // for testing:
26 battery_len = 3;
27 //battery_wdth = 15;
28 //battery_base_indent_fromside_inside = 6;
29
30 // calculated
31
32 bpp0 = [0,0];
33 bpp1 = bpp0 + [ 0, mainwall_th - behind_recess ];
34 lppA = bpp1 + [ seal_th, -recess_gap_end ];
35 lppB = lppA + [ lid_edge_th, 0 ];
36 bpp2 = [ lppB[0], bpp1[1] ];
37 bpp3 = [ bpp2[0] + (bpp1 - bpp0)[1], bpp0[1] ];
38 bpp4 = [ bpp3[0], bpp0[1] + mainwall_th ];
39 lppC = bpp3 + [ 0, -recess_gap_end ];
40
41 lppF = lppC + [ handle_height, 0 ];
42
43 s0 = battery_wdth/2;
44 s0i = s0 - battery_th/2;
45 s1 = s0 + smallwall_th;
46
47 l1 = s1 - handle_inward;
48 l0 = l1 - handle_len;
49
50 echo(
51      bpp0,
52      bpp1,
53      bpp2,
54      bpp3,
55      bpp4,
56      bpp5,
57      bpp6,
58      bpp7,
59      bpp8
60 );
61
62 echo(
63      lppA,
64      lppB,
65      lppC,
66      lppD,
67      lppE
68 );
69
70 bpp8 = bpp0 + [ -battery_len,0 ];
71 bpp5 = [ bpp8[0] - smallwall_th, bpp4[1] ];
72 bpp9 = [ bpp0[0], bpp0[1] - battery_th/2 - 1.0 ];
73 bpp7 = [ bpp8[0], bpp9[1] ];
74 bpp6 = [ bpp5[0], bpp9[1] ];
75 lppE = [ lppA[0], bpp9[1] ];
76 lppD = [ lppC[0], bpp9[1] ];
77
78 module BaseHalfPlan(indent=0){
79   polygon([ bpp0,
80             bpp1,
81             bpp2,
82             bpp3,
83             bpp4,
84             bpp5,
85             bpp6,
86             bpp7 + indent * [1,0],
87             bpp8 + indent * [1,0]
88             ]);
89 }
90
91 module SideHalfPlan(){
92   polygon([ bpp5,
93             bpp6,
94             bpp9,
95             bpp1
96             ]);
97 }
98
99 module LidHalfPlan(){
100   polygon([ lppA,
101             lppE,
102             lppD,
103             lppC,
104             lppB
105             ]);
106 }
107
108 module HandleHalfPlan(){
109   translate(lppE)
110     square(lppF - lppE);
111 }
112
113 module ExtrudePlan(from,to){
114   rotate([0,-90,0])
115   for (mj=[0,1]) {
116     mirror([0,0,mj]) translate([0,0,from]){
117       linear_extrude(height= to-from){
118         for (mi=[0,1]) {
119           mirror([0,mi])
120             translate([0, battery_th/2])
121             children(0);
122         }
123       }
124     }
125   }
126 }
127
128 module PlanDemo(){ ////toplevel
129   color("blue") BaseHalfPlan();
130   color("red") LidHalfPlan();
131   translate([0,0,-1]) color("lightblue") SideHalfPlan();
132 }
133
134 module Base(){ ////toplevel
135   ExtrudePlan(0,s1) BaseHalfPlan();
136   difference(){
137     union(){
138       ExtrudePlan(s0i, s1) SideHalfPlan();
139       ExtrudePlan(s0 - battery_base_indent_fromside_inside,
140                   s0 - battery_base_indent_fromside_outside
141                   ) BaseHalfPlan(indent = battery_base_indent);
142     }
143     for (m=[0,1])
144       mirror([m,0,0])
145         translate([s0i, 0, bpp7[0] - 0.1])
146         cylinder(r= battery_th/2, h=100, $fs=0.5);
147   }
148 }
149
150 module BaseHalfTest(){ ////toplevel
151   intersection(){
152     Base();
153     translate([-100,0,-100])
154       cube([200,200,200]);
155   }
156 }
157
158 module Lid(){ ////toplevel
159   ExtrudePlan(0,s1) LidHalfPlan();
160   ExtrudePlan(l0,l1) HandleHalfPlan();
161 }
162
163 module Demo(){ ////toplevel
164   %Base();
165   Lid();
166 }
167
168 //PlanDemo();
169 //Demo();
170 //Base();