Pip-Boy inspired phone holder built around the PINE64 PinePhone
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

413 linhas
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. $fn=$preview ? 4 : 12;
  174. s=[138, 69, 12];
  175. b = 10;
  176. s1=[s.x, s.y];
  177. s2=[s.x+b, s.y+b];
  178. h=s.z;
  179. up(5) rounded_prismoid(size1=s1, size2=s2, h=h, r1=1, r2=15);
  180. }
  181. top_offset=6.5;
  182. module top_speaker_cutout() {
  183. s=[3, 12, 100];
  184. right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) cubi(s, fillet=1);
  185. }
  186. module front_camera_cutout() {
  187. $fn = $preview ? 6 : 30;
  188. d=5;
  189. s=[d, d, 100];
  190. right(ps.x/2 - top_offset) fwd(11.5) cylinder(d=s.x, h=s.z);
  191. }
  192. module leds_cutout() {
  193. s=[4, 14, 100];
  194. right(ps.x/2 - top_offset) up(s.z/2 - ps.z/3) back(23) cubi(s, fillet=1);
  195. }
  196. module top_cutout() {
  197. screen_cutout();
  198. top_speaker_cutout();
  199. front_camera_cutout();
  200. leds_cutout();
  201. }
  202. // -- BOTTOM --
  203. module back_camera_cutout() {
  204. s=[13, 25, expose_back_camera ? 100 : 11];
  205. 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);
  206. }
  207. module bottom_speaker_cutout() {
  208. s=[8, 49, 100];
  209. left(ps.x/2 - 13)
  210. difference() {
  211. down(s.z/2 - ps.z/3) cubi(s, fillet=1);
  212. bars=8;
  213. down(ps.z/2)
  214. for (i = [0:bars-1]) {
  215. bs=[s.x+2, 1, 2];
  216. step=s.y/bars;
  217. fwd(i*step - s.y/2 + step/2) down(w) cube(bs, center=true);
  218. }
  219. }
  220. }
  221. module bottom_cutout() {
  222. back_camera_cutout();
  223. bottom_speaker_cutout();
  224. }
  225. // -- RIGHT --
  226. module headphones_cutout() {
  227. $fn = $preview ? 10 : 30;
  228. d1=8.8;
  229. d2=14;
  230. p=[ps.x/2, ps.y/2-24, -0.88];
  231. h=30;
  232. translate(p) yrot(90) down(10) cylinder(h=h, d1=d1, d2=d2);
  233. }
  234. module right_cutout() {
  235. headphones_cutout();
  236. }
  237. // -- LEFT --
  238. module usbc_cutout() {
  239. s=[20, 20, 7];
  240. left(ps.x/2) down(2) cubi(s, fillet=1);
  241. }
  242. module left_cutout() {
  243. usbc_cutout();
  244. }
  245. // -- FRONT --
  246. buttons_cutout_size=[42, 100, 4.5];
  247. buttons_cutout_pos=[ps.x/2 - 44.5, -ps.y/2 - 3, 0.25];
  248. module buttons_cutout() {
  249. s=buttons_cutout_size;
  250. p=buttons_cutout_pos;
  251. translate(p) cubi(s, fillet=1);
  252. }
  253. module front_cutout() {
  254. buttons_cutout();
  255. }
  256. module front_buttons(socket) {
  257. s=[buttons_cutout_size.x-2, 4, buttons_cutout_size.z-0.5];
  258. p=buttons_cutout_pos;
  259. t=socket ? 0.2 : 0;
  260. pin_size=[3 + t, 3 + t, s.z+1.4 + t/2];
  261. touch_size=[2, s.y, 2];
  262. touch_power_size=[3, touch_size.y, touch_size.z];
  263. translate(p) {
  264. cs=[4, s.y, s.z];
  265. left(5) {
  266. bs=[13, s.y, s.z];
  267. left(bs.x/6) cubi(pin_size);
  268. left(bs.x/2) {
  269. difference() {
  270. cubi(bs);
  271. back(2) cubi(cs);
  272. }
  273. }
  274. fwd(1) left(bs.x*0.8) cubi(touch_power_size, fillet=1);
  275. }
  276. right(8) {
  277. bs=[18, s.y, s.z];
  278. cubi(pin_size);
  279. difference() {
  280. cubi(bs);
  281. back(2) {
  282. left(bs.x/4) cubi(cs);
  283. right(bs.x/4) cubi(cs);
  284. }
  285. }
  286. fwd(1) {
  287. left(bs.x*0.4) cubi(touch_size, fillet=1);
  288. right(bs.x*0.4) cubi(touch_size, fillet=1);
  289. }
  290. }
  291. }
  292. }
  293. // ==== MODEL ====
  294. divider=harness_divider;
  295. module model_harness_left() {
  296. intersection() {
  297. intersection() {
  298. translate(divider) downcube([1000, 1000, 1000]);
  299. translate(divider) leftcube([1000, 1000, 1000]);
  300. }
  301. difference() {
  302. shell();
  303. shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance);
  304. shell_cutouts();
  305. shell_backplane(groove=true);
  306. }
  307. }
  308. }
  309. module model_harness_right() {
  310. intersection() {
  311. intersection() {
  312. translate(divider) downcube([1000, 1000, 1000]);
  313. translate(divider) rightcube([1000, 1000, 1000]);
  314. }
  315. difference() {
  316. shell();
  317. shell_rim_edge(rim_edge_thickness, groove=true, tolerance=rim_edge_tolerance);
  318. shell_cutouts();
  319. front_buttons(socket=true);
  320. }
  321. }
  322. shell_backplane(groove=false);
  323. }
  324. module model_harness_top() {
  325. intersection() {
  326. translate(divider) upcube([1000, 1000, 1000]);
  327. difference() {
  328. shell();
  329. shell_cutouts();
  330. front_buttons(socket=true);
  331. }
  332. }
  333. difference() {
  334. shell_rim_edge(rim_edge_thickness, groove=false);
  335. shell_cutouts();
  336. front_buttons(socket=true);
  337. }
  338. }
  339. module model_harness_slider_front() {
  340. difference() {
  341. fwd(hs.y/2) xrot(90) harness_slider(slider_len_front);
  342. front_cutout();
  343. }
  344. }
  345. module model_harness_slider_back() {
  346. back(hs.y/2) xrot(-90) harness_slider(slider_len_back);
  347. }
  348. module model_harness_buttons() {
  349. front_buttons(socket=false);
  350. }
  351. if (is_model(MODEL_HARNESS_LEFT)) model_harness_left();
  352. if (is_model(MODEL_HARNESS_RIGHT)) model_harness_right();
  353. if (is_model_strict(MODEL_HARNESS_BOTTOM_PIP)) {
  354. model_harness_left();
  355. right(backplane_pip_slideout) model_harness_right();
  356. }
  357. if (is_model(MODEL_HARNESS_TOP)) model_harness_top();
  358. if (is_model(MODEL_HARNESS_SLIDER_FRONT)) model_harness_slider_front();
  359. if (is_model(MODEL_HARNESS_SLIDER_BACK)) model_harness_slider_back();
  360. if (is_model(MODEL_HARNESS_BUTTONS)) model_harness_buttons();
  361. }
  362. module model() {
  363. phone_harness();
  364. }
  365. if (!is_undef(validation)) {
  366. intersection() {
  367. phone();
  368. model();
  369. }
  370. } else {
  371. intersection() {
  372. if (!is_undef(xray)) {
  373. if (xray == XRAY_POSITIVE) {
  374. span_cube([0,1000], [0,1000], [-1000,1000]);
  375. } else if (xray == XRAY_BACKPLANE) {
  376. span_cube([-1000,1000], [-1000,1000], [-1000,-7]);
  377. } else if (xray == XRAY_BOTTOM) {
  378. span_cube([-1000,1000], [-1000,1000], [-1000,0]);
  379. }
  380. }
  381. union() {
  382. if (is_not_export()) {
  383. //phone();
  384. //arm();
  385. }
  386. model();
  387. }
  388. }
  389. }