Pip-Boy inspired phone holder built around the PINE64 PinePhone
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 regels
12 KiB

  1. // dependency: https://github.com/revarbat/BOSL
  2. include <BOSL/constants.scad>
  3. use <BOSL/transforms.scad>
  4. use <BOSL/shapes.scad>
  5. use <BOSL/masks.scad>
  6. use <BOSL/sliders.scad>
  7. // DEBUG:
  8. //validation = 1;
  9. XRAY_POSITIVE=1;
  10. XRAY_BACKPLANE=2;
  11. XRAY_BOTTOM=3;
  12. //xray = 2;
  13. // EXPORT:
  14. MODEL_HARNESS_LEFT=1;
  15. MODEL_HARNESS_RIGHT=2;
  16. MODEL_HARNESS_BOTTOM_PIP=3;
  17. MODEL_HARNESS_TOP=4;
  18. MODEL_HARNESS_SLIDER_FRONT=5;
  19. MODEL_HARNESS_SLIDER_BACK=6;
  20. MODEL_HARNESS_BUTTONS=7;
  21. export=0; // [0:7]
  22. function is_not_export() = is_undef(export) || export == 0;
  23. function is_export() = !is_not_export();
  24. function is_model_strict(m) = is_export() && export == m;
  25. function is_model(m) = is_not_export() || export == m;
  26. function get_phone_size() = [160, 76.7, 10];
  27. backplane_pip_slideout=10;
  28. module cubi(s, fillet=0, edges=EDGES_ALL) {
  29. if ($preview) {
  30. cube(s, center=true);
  31. } else {
  32. cuboid(s, fillet=fillet, edges=edges);
  33. }
  34. }
  35. module phone() {
  36. s=get_phone_size();
  37. color("gray")
  38. cubi(s, fillet=5);
  39. }
  40. module arm() {
  41. $fn=6;
  42. s=[210, 55, 50];
  43. color("SaddleBrown")
  44. down(s.z/2 + get_phone_size().z/2) cubi(s, fillet=20);
  45. }
  46. module phone_harness() {
  47. ops=get_phone_size();
  48. ps=[ops.x+0.2, ops.y+0.2, ops.z+0.2];
  49. shell_wall=3;
  50. shell_rim_wall=3;
  51. rim_edge_thickness=1.5;
  52. rim_edge_tolerance=0.4;
  53. expose_back_camera=true;
  54. screwmount_screw=3;
  55. harness_divider=[1, 0, 1.3];
  56. harness_size=[ps.x+shell_wall*2, ps.y+shell_wall*2, ps.z+shell_wall*2];
  57. rim_size=[harness_size.x+2*shell_rim_wall, harness_size.y+2*shell_rim_wall, 8];
  58. w=shell_wall;
  59. f=2;
  60. rf=5;
  61. hs=harness_size;
  62. backplane_rim_size=[40, ps.y*0.95, shell_wall/2];
  63. backplane_teeth=6;
  64. // ==== SHELL ====
  65. module shell() {
  66. $fn = $preview ? 6 : 30;
  67. difference() {
  68. cubi(hs, fillet=f);
  69. cubi(ps, fillet=f);
  70. }
  71. shell_rim();
  72. shell_screwmounts();
  73. }
  74. module shell_rim() {
  75. $fn = $preview ? 6 : 30;
  76. w=shell_rim_wall;
  77. s=rim_size;
  78. intersection() {
  79. difference() {
  80. cubi(s, fillet=rf, edges=EDGES_Z_ALL);
  81. cubi(ps, fillet=f, edges=EDGES_Z_ALL);
  82. }
  83. cubi(s, fillet=1);
  84. }
  85. rail_extension=10;
  86. fwd(hs.y/2) xrot(90) harness_rail(slider_len_front+rail_extension);
  87. back(hs.y/2) xrot(-90) harness_rail(slider_len_back+rail_extension);
  88. }
  89. module shell_rim_edge(thickness, groove, tolerance=rim_edge_tolerance) {
  90. $fn = $preview ? 6 : 30;
  91. w=thickness + (groove ? tolerance : 0);
  92. offset=(groove ? 0 : tolerance/2);
  93. res=[hs.x+2*(w+offset), hs.y+2*(w+offset), 3];
  94. resi=[hs.x+2*offset, hs.y+2*offset, res.z+1];
  95. up(0.0) difference() {
  96. intersection() {
  97. cubi(res, fillet=rf, edges=EDGES_Z_ALL);
  98. cubi(res, fillet=(groove?1:1.5), edges=EDGES_BOTTOM);
  99. }
  100. cubi(resi, fillet=rf, edges=EDGES_Z_ALL);
  101. }
  102. }
  103. module foreach_screwmount() {
  104. for(x = [0:1]) for (y = [0:1]) {
  105. translate([(-0.5+x)*ps.x, (-0.5+y)*ps.y, -hs.z/2])
  106. children();
  107. }
  108. }
  109. module shell_screwmounts() {
  110. $fn = $preview ? 6 : 30;
  111. r=3;
  112. foreach_screwmount() {
  113. cylinder(r=r, h=hs.z);
  114. }
  115. }
  116. module shell_screwmounts_holes() {
  117. $fn = $preview ? 6 : 30;
  118. foreach_screwmount() {
  119. up(w) cylinder(d2=screwmount_screw, d1=screwmount_screw*0.5, h=hs.z+1);
  120. up(hs.z-1) cylinder(d=screwmount_screw+1.5, h=5);
  121. }
  122. }
  123. module shell_backplane(groove) {
  124. module groove_scale() { scale([groove?1.05:1, groove?1.05:1, groove?1.2:1]) children(); }
  125. down(hs.z/2 - shell_wall/3) up(backplane_rim_size.z/2) right(harness_divider.x) {
  126. back(backplane_rim_size.y/2) {
  127. teeth=backplane_teeth;
  128. segment=backplane_rim_size.y/teeth;
  129. tooth_size=[backplane_rim_size.x, segment/2, backplane_rim_size.z];
  130. joiner_base=5;
  131. joiner_size=[joiner_base + (groove?backplane_pip_slideout:0), segment*1.5, backplane_rim_size.z];
  132. for (i = [0:teeth-1]) {
  133. fwd(i*segment) fwd(tooth_size.y) {
  134. groove_scale() cubi(tooth_size, fillet=0.5, edges=EDGES_X_ALL);
  135. if (i%2 == 0) {
  136. left(backplane_rim_size.x/2 + joiner_base/2) fwd(joiner_size.y/3) left(-joiner_size.x/2) groove_scale() cubi(joiner_size, fillet=2, edges=EDGES_Z_ALL);
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. // ==== SHELL SLIDER AND RAIL ====
  144. rail_angle=36;
  145. rail_wall=1;
  146. slider_slop=0.1;
  147. slider_len_back=hs.x*0.3;
  148. slider_len_front=hs.x*0.15;
  149. module harness_slider(l) {
  150. base=2;
  151. ss=[l, shell_rim_wall, rim_size.z+rail_wall*2];
  152. up(ss.y + base) xrot(180) difference() {
  153. slider(l=ss.x, w=ss.z, h=ss.y, base=base, chamfer=0.9, wall=2, ang=rail_angle, slop=slider_slop, orient=ORIENT_X, align=V_UP);
  154. screws=2;
  155. screws_area_l=0.7*l;
  156. for (i=[0:screws-1]) {
  157. $fn=$preview ? 6 : 16;
  158. right(-screws_area_l/2 + screws_area_l/(screws-1) * i) cylinder(d2=screwmount_screw*0.5, d1=screwmount_screw, h=ss.y*0.7);
  159. }
  160. }
  161. }
  162. module harness_rail(l) {
  163. sw=2;
  164. ss=[l, shell_rim_wall, rim_size.z+rail_wall*2];
  165. rail(l=ss.x, w=ss.z, h=ss.y, chamfer=0.5, ang=rail_angle, orient=ORIENT_X, align=V_UP);
  166. }
  167. // ==== SHELL CUTOUTS ====
  168. module shell_cutouts() {
  169. top_cutout();
  170. bottom_cutout();
  171. left_cutout();
  172. right_cutout();
  173. front_cutout();
  174. shell_screwmounts_holes();
  175. }
  176. // -- TOP --
  177. module screen_cutout() {
  178. $fn=$preview ? 4 : 12;
  179. s=[138, 69, 12];
  180. b = 10;
  181. s1=[s.x, s.y];
  182. s2=[s.x+b, s.y+b];
  183. h=s.z;
  184. up(5) rounded_prismoid(size1=s1, size2=s2, h=h, r1=1, r2=15);
  185. }
  186. top_offset=6.5;
  187. module top_speaker_cutout() {
  188. s=[3, 12, 100];
  189. right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) cubi(s, fillet=1);
  190. }
  191. module front_camera_cutout() {
  192. $fn = $preview ? 6 : 30;
  193. d=5;
  194. s=[d, d, 100];
  195. right(ps.x/2 - top_offset) fwd(11.5) cylinder(d=s.x, h=s.z);
  196. }
  197. module leds_cutout() {
  198. s=[4, 14, 100];
  199. right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) back(23) cubi(s, fillet=1);
  200. }
  201. module top_cutout() {
  202. screen_cutout();
  203. top_speaker_cutout();
  204. front_camera_cutout();
  205. leds_cutout();
  206. }
  207. // -- BOTTOM --
  208. module back_camera_cutout() {
  209. s=[13, 25, expose_back_camera ? 100 : 11];
  210. right(ps.x/2 - 7.5) fwd(ps.y/2 - 23) down(s.z/2 - ps.z/3) cubi(s, fillet=6, edges=EDGES_Z_ALL);
  211. }
  212. module bottom_speaker_cutout() {
  213. s=[8, 49, 100];
  214. left(ps.x/2 - 13)
  215. difference() {
  216. down(s.z/2 - ps.z/3) cubi(s, fillet=1);
  217. bars=8;
  218. down(ps.z/2)
  219. for (i = [0:bars-1]) {
  220. bs=[s.x+2, 1, 2];
  221. step=s.y/bars;
  222. fwd(i*step - s.y/2 + step/2) down(w) cube(bs, center=true);
  223. }
  224. }
  225. }
  226. module bottom_cutout() {
  227. back_camera_cutout();
  228. bottom_speaker_cutout();
  229. }
  230. // -- RIGHT --
  231. module headphones_cutout() {
  232. $fn = $preview ? 10 : 30;
  233. d1=8.8;
  234. d2=14;
  235. p=[ps.x/2, ps.y/2-24, -0.88];
  236. h=22;
  237. translate(p) yrot(90) down(10) cylinder(h=h, d1=d1, d2=d2);
  238. }
  239. module right_cutout() {
  240. headphones_cutout();
  241. }
  242. // -- LEFT --
  243. module usbc_cutout() {
  244. s=[20, 20, 7];
  245. left(ps.x/2) down(2) cubi(s, fillet=1);
  246. }
  247. module left_cutout() {
  248. usbc_cutout();
  249. }
  250. // -- FRONT --
  251. buttons_cutout_size=[42, 100, 4.5];
  252. buttons_cutout_pos=[ps.x/2 - 44.5, -ps.y/2 - 3, 0.25];
  253. module buttons_cutout() {
  254. s=buttons_cutout_size;
  255. p=buttons_cutout_pos;
  256. translate(p) cubi(s, fillet=1);
  257. }
  258. module front_cutout() {
  259. buttons_cutout();
  260. }
  261. module front_buttons(socket) {
  262. s=[buttons_cutout_size.x-2, 4, buttons_cutout_size.z-0.5];
  263. p=buttons_cutout_pos;
  264. t=socket ? 0.2 : 0;
  265. pin_size=[3 + t, 3 + t, s.z+2 + t/2];
  266. touch_size=[2, s.y, 2];
  267. touch_power_size=[3, touch_size.y, touch_size.z];
  268. translate(p) {
  269. cs=[4, s.y, s.z];
  270. left(5) {
  271. bs=[13, s.y, s.z];
  272. left(bs.x/6) cubi(pin_size);
  273. left(bs.x/2) {
  274. difference() {
  275. cubi(bs);
  276. back(2) cubi(cs);
  277. }
  278. }
  279. fwd(1) left(bs.x*0.8) cubi(touch_power_size, fillet=1);
  280. }
  281. right(8) {
  282. bs=[18, s.y, s.z];
  283. cubi(pin_size);
  284. difference() {
  285. cubi(bs);
  286. back(2) {
  287. left(bs.x/4) cubi(cs);
  288. right(bs.x/4) cubi(cs);
  289. }
  290. }
  291. fwd(1) {
  292. left(bs.x*0.4) cubi(touch_size, fillet=1);
  293. right(bs.x*0.4) cubi(touch_size, fillet=1);
  294. }
  295. }
  296. }
  297. }
  298. // ==== MODEL ====
  299. divider=harness_divider;
  300. module model_harness_left() {
  301. intersection() {
  302. intersection() {
  303. translate(divider) downcube([1000, 1000, 1000]);
  304. translate(divider) leftcube([1000, 1000, 1000]);
  305. }
  306. difference() {
  307. shell();
  308. shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance);
  309. shell_cutouts();
  310. shell_backplane(groove=true);
  311. }
  312. }
  313. }
  314. module model_harness_right() {
  315. intersection() {
  316. intersection() {
  317. translate(divider) downcube([1000, 1000, 1000]);
  318. translate(divider) rightcube([1000, 1000, 1000]);
  319. }
  320. difference() {
  321. shell();
  322. shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance);
  323. shell_cutouts();
  324. front_buttons(socket=true);
  325. }
  326. }
  327. shell_backplane(groove=false);
  328. }
  329. module model_harness_top() {
  330. intersection() {
  331. translate(divider) upcube([1000, 1000, 1000]);
  332. difference() {
  333. shell();
  334. shell_cutouts();
  335. front_buttons(socket=true);
  336. }
  337. }
  338. difference() {
  339. shell_rim_edge(rim_edge_thickness, groove=false);
  340. shell_cutouts();
  341. front_buttons(socket=true);
  342. }
  343. }
  344. module model_harness_slider_front() {
  345. difference() {
  346. fwd(hs.y/2) xrot(90) harness_slider(slider_len_front);
  347. front_cutout();
  348. }
  349. }
  350. module model_harness_slider_back() {
  351. back(hs.y/2) xrot(-90) harness_slider(slider_len_back);
  352. }
  353. module model_harness_buttons() {
  354. front_buttons(socket=false);
  355. }
  356. if (is_model(MODEL_HARNESS_LEFT)) model_harness_left();
  357. if (is_model(MODEL_HARNESS_RIGHT)) model_harness_right();
  358. if (is_model_strict(MODEL_HARNESS_BOTTOM_PIP)) {
  359. model_harness_left();
  360. right(backplane_pip_slideout) model_harness_right();
  361. }
  362. if (is_model(MODEL_HARNESS_TOP)) model_harness_top();
  363. if (is_model(MODEL_HARNESS_SLIDER_FRONT)) model_harness_slider_front();
  364. if (is_model(MODEL_HARNESS_SLIDER_BACK)) model_harness_slider_back();
  365. if (is_model(MODEL_HARNESS_BUTTONS)) model_harness_buttons();
  366. }
  367. module model() {
  368. phone_harness();
  369. }
  370. if (!is_undef(validation)) {
  371. intersection() {
  372. phone();
  373. model();
  374. }
  375. } else {
  376. intersection() {
  377. if (!is_undef(xray)) {
  378. if (xray == XRAY_POSITIVE) {
  379. span_cube([0,1000], [0,1000], [-1000,1000]);
  380. } else if (abs(xray) == XRAY_BACKPLANE) {
  381. span_cube([-1000,1000], [-1000,1000], [-1000*sign(xray),-6]);
  382. } else if (xray == XRAY_BOTTOM) {
  383. span_cube([-1000,1000], [-1000,1000], [-1000,0]);
  384. }
  385. }
  386. union() {
  387. if (is_not_export()) {
  388. //phone();
  389. //arm();
  390. }
  391. model();
  392. }
  393. }
  394. }