arcade-panel: more hinge stuff, misc fixes
[clinton/3d-models.git] / ble arcade controller / arcade-box.scad
CommitLineData
ee49ff3d
CE
1// arcade controller thing
2// Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org>
3// GPLv3 or (at your option) any later version
4// .. insert license text here ...
5
9571d749
CE
6// todo:
7// - hinge
8// - screw holes + captive nut to mount
9// - internal mount for mcu and battery
10// - hole for usb panel mount
11// - bevel lid
12
13// maybe/wishlist:
14// - wire routing clips on panel?
15// - buttons on side for pinball?
16// - vent under mcu/battery?
17// - slant panel toward player?
18
19// bugs:
20// - hinge is not aligned -- either male arm length or connector placement is wrong
21
ee49ff3d 22use <obiscad/bcube.scad>
c3a57278 23use <obiscad/attach.scad>
7db674d2
CE
24use <joints.scad>
25
c3a57278 26// PREVIEW
7db674d2 27preview();
9571d749 28
7db674d2 29module preview () {
c3a57278
CE
30 rotate ([-10, 0, 0]) translate ([0, 0, box_h+20]) panel ();
31 case ();
9571d749 32 for (i = [2 ,4]) translate ([panel_w+hinge_joint_width*i, 0, 0]) hinge_male ();
c3a57278 33
9571d749 34}
c3a57278
CE
35
36// CONFIGURATION
37
38panel_w = 250;
9571d749 39panel_h = 130;
c3a57278
CE
40
41box_h = 80; // fixme: box_d.
42box_wall = 2;
43base_h = 5; //fixme: thickness?
44
9571d749 45$button_d = 30; // I think this should be special
ee49ff3d 46
9571d749 47// fixme: names (js -> joystick)
c3a57278
CE
48js_width = 85;
49js_height = 40;
50
9571d749 51// fixme: these are a bit confused
7db674d2
CE
52hinge_joint_width = 4;
53hinge_joint_thickness = 5;
54hinge_base_height = 10;
9571d749
CE
55hinge_joint_height = 10;
56hinge_arm_length = 50;
57
58
59// gunk that should be elsewhere...
60// bcube parameters, clean up
61cr = box_wall*2;
62cres = 0;
7db674d2 63
c3a57278 64// PANEL COMPONENTS
ee49ff3d
CE
65
66module button (bezel = $button_d+4) {
67 circle (d=$button_d);
68 %circle(d=bezel);
69}
70
ee49ff3d
CE
71module joystick () {
72 bolt_d = 8;
73 center_hole_d = 24;
74
c3a57278 75 for (x = [-js_width/2, js_width/2], y = [-js_height/2, js_height/2]) {
ee49ff3d
CE
76 translate ([x, y, 0]) circle (d=bolt_d); // need slot instead
77 }
c3a57278 78 circle (d=center_hole_d);
c3a57278 79 %square ([js_width, js_height], center=true); // not right...
ee49ff3d
CE
80}
81
ee49ff3d 82
c3a57278 83// CASE
ee49ff3d 84
c3a57278
CE
85module case_base (h=base_h) {
86 bcube([panel_w, panel_h, h], cr, cres);
ee49ff3d
CE
87}
88
c3a57278 89module case_walls () {
9571d749
CE
90 difference () {
91 union () {
92 difference() {
93 bcube([panel_w, panel_h, box_h-base_h], cr, cres);
94 bcube([panel_w-box_wall*2, panel_h-box_wall*2, box_h+1], cr, cres);
95 }
96 attach (case_connector_wall (x=10), hinge_connector_back ()) hinge_female_base ();
97 }
98 attach (case_connector_wall (x=10), hinge_connector_back ()) hinge_female_cut ();
ee49ff3d 99 }
7db674d2 100 %connector (case_connector_wall (x=10));
ee49ff3d
CE
101}
102
c3a57278
CE
103module case () {
104 case_base ();
7db674d2
CE
105 translate ([0, 0, box_h/2]) case_walls ();
106}
107
108
109// todo:
9571d749
CE
110// specify which wall (rear, front, left, right). vector addition may help...
111// offset from center of wall, as vector (and use vector subtraction!)
7db674d2
CE
112// optional: inside/outside
113function case_connector_wall (x=0, y=0, z=0) = [ [panel_w/2-x, panel_h/2-y, (box_h-base_h)/2-z], [0,-1, 0], 0 ];
114
115// HINGE
116
9571d749
CE
117// hinge todo:
118// calculate z offset so that hinge will align when closed
119// calculate offset into panel surface for length of peg
120// attach to case, calculating offset from wall as fixed value + width
121
122// add connector for pin to socket so that can easily be test fit in
123// software instead of guessing
124
125// should panel connector be on its side? Limits motion to 90⁰ Or
126// maybe just walls only + fillet with no base...
127
7db674d2
CE
128function hinge_connector_back (th=hinge_joint_thickness*2, h=hinge_base_height) = [ [0, th/2, h/2], [0,1, 0], 0 ];
129
9571d749
CE
130// todo:
131// gusset support underneath
132// split into base and negative so that a hole can be punched into case wall
133
134module hinge_female_base () {
135 w = hinge_joint_width * 2;
136 th = hinge_joint_thickness * 2;
137
138 %connector (hinge_connector_back ());
139 cube ([w, th, hinge_base_height], center=true);
140}
141
142module hinge_female_cut () {
7db674d2
CE
143 w = hinge_joint_width * 2;
144 th = hinge_joint_thickness * 2;
9571d749
CE
145
146 // cruft from earlier hacking, remove...
7db674d2
CE
147 jt = hinge_joint_thickness;
148 jw = hinge_joint_width;
7db674d2 149
9571d749
CE
150 joint_male_negative(male_joint_width=jw, male_joint_thickness=jt, forward_rom=90, backward_rom=90, male_joint_height=hinge_joint_height);
151}
7db674d2 152
9571d749 153module hinge_female () {
7db674d2 154 difference () {
9571d749
CE
155 hinge_female_base ();
156 hinge_female_cut ();
7db674d2 157 }
ee49ff3d
CE
158}
159
9571d749
CE
160module hinge_male () {
161 for (i=[0,1]) mirror ([0, i, 0]) translate ([0, -hinge_arm_length/4, 0])
162 joint_male(male_joint_width=hinge_joint_width, male_joint_thickness=hinge_joint_thickness, male_joint_height=hinge_arm_length/2, side=true);
163
164}
165
166
167// hinge to panel...
168// mount hinge on panel arm_length back from edge
169
170// fixme: wall thickness is not taken into account
ee49ff3d 171
c3a57278 172// PANEL
ee49ff3d 173
9571d749
CE
174
175// cleanup after general case_connector_wall() is done
176panel_c = [ [panel_w/2-10, panel_h/2-hinge_arm_length, -base_h/2+0.01], [0,0, 1], 180 ];
177
ee49ff3d
CE
178module panel () {
179 difference () {
c3a57278
CE
180 case_base ();
181 linear_extrude (base_h*2,center=true) panel_layout ();
ee49ff3d 182 }
9571d749
CE
183 %connector (panel_c);
184 attach (panel_c, hinge_connector_back ()) hinge_female ();
ee49ff3d
CE
185}
186
c3a57278
CE
187module panel_attach (position, angle=0) {
188 x = position[0];
189 y = position[1];
7db674d2 190 c1 = [ [x, y, base_h/2], [0,0,1], angle ];
c3a57278 191 a1 = [ [0,0, 0], [0,0,0], 0 ];
7db674d2 192// %connector (c1); // fixme: don't use 2d for layout
c3a57278
CE
193 attach (c1, a1) children ();
194}
ee49ff3d 195
c3a57278 196// panel layout inspired by the Neo Geo layout
ee49ff3d 197module panel_layout () {
c3a57278
CE
198 translate ([-panel_w/2 + 40, 0, 0]) {
199 panel_attach ([0, 0], 90) joystick ();
200
201 // p1, coin (floating off in the distance...)
9571d749 202 translate ([140, 0, 0]) {
7db674d2 203 $button_d=16;
c3a57278 204 for (x = [0, $button_d+10]) {
7db674d2 205 panel_attach ([x, 42]) button ();
c3a57278
CE
206 }
207 }
ee49ff3d 208
c3a57278 209 // a, b, c, d
7db674d2
CE
210 translate ([60, -20, 0]) {
211 panel_attach ([0, 0]) button ();
c3a57278 212 for (i = [ 1 : 3 ]) {
7db674d2 213 panel_attach ([i*($button_d+10)-10, $button_d]) button ();
c3a57278 214 }
ee49ff3d
CE
215 }
216 }
217}