Pip-Boy inspired phone holder built around the PINE64 PinePhone
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

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