Pip-Boy inspired phone holder built around the PINE64 PinePhone
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

429 líneas
13 KiB

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