Pip-Boy inspired phone holder built around the PINE64 PinePhone
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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