Pip-Boy inspired phone holder built around the PINE64 PinePhone
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

348 řádky
12 KiB

  1. links_count=6; // [1..20]
  2. include_terminal=true; // [true,false]
  3. export=3; // [0:6]
  4. MODEL_DEMO=0;
  5. MODEL_LINKS=1;
  6. MODEL_CLIP_A=2;
  7. MODEL_CLIP_B=3;
  8. MODEL_CLIP_RATCHETING=4;
  9. MODEL_CLIP_RATCHETING_A=5;
  10. MODEL_CLIP_RATCHETING_B=6;
  11. //validation=1;
  12. VALIDATE_INTERSECTION=1;
  13. //xray=1;
  14. use <BOSL/transforms.scad>
  15. use <BOSL/shapes.scad>
  16. include <BOSL/constants.scad>
  17. function is_not_export() = is_undef(export) || export == 0;
  18. function is_export() = !is_not_export();
  19. function is_model_strict(m) = is_export() && export == m;
  20. function is_model(m) = is_not_export() || export == m;
  21. function get_link_segment_size() = [15, 30, 5];
  22. function get_link_pin_diameter() = 2;
  23. function get_link_socket_slack() = [1, 4, 1];
  24. function get_link_joiner_arm_size() = [get_link_segment_size().x - 2, 3, segment_size.z];
  25. function get_link_socket_size() = [get_link_segment_size().z,
  26. get_link_segment_size().y - get_link_joiner_arm_size().y*2,
  27. get_link_segment_size().z];
  28. function get_link_clip_size() = [get_link_pin_diameter()*5, get_link_segment_size().y - 5, get_link_segment_size().z];
  29. echo("===============================");
  30. echo(str("Strap length: ", (links_count * get_link_segment_size().x), " mm"));
  31. echo("===============================");
  32. assert(get_link_segment_size().x >= 10, "Link segment is too short.");
  33. assert(get_link_segment_size().z >= (get_link_pin_diameter() + get_link_socket_slack().z + 1), "Link segment is too thin.");
  34. module link(terminal=false) {
  35. segment_size=get_link_segment_size();
  36. module pin() {
  37. h=segment_size.y;
  38. d=get_link_pin_diameter();
  39. back(h/2) xrot(90) cylinder(h=h, d=d, $fn=$preview ? 10 : 30);
  40. }
  41. module pin_socket_area() {
  42. h=segment_size.y-get_link_socket_slack().y;
  43. d=segment_size.z;
  44. back(h/2) xrot(90) cylinder(h=h, d=d, $fn=$preview ? 10 : 30);
  45. }
  46. module pin_socket() {
  47. difference() {
  48. pin_socket_area();
  49. scaleup = [
  50. ((get_link_pin_diameter() + get_link_socket_slack().x) / get_link_pin_diameter()),
  51. ((get_link_pin_diameter() + get_link_socket_slack().y) / get_link_pin_diameter()),
  52. ((get_link_pin_diameter() + get_link_socket_slack().z) / get_link_pin_diameter())
  53. ];
  54. scale(scaleup) pin();
  55. }
  56. }
  57. module joiner() {
  58. gap=2;
  59. arm_size=get_link_joiner_arm_size();
  60. module arm() {
  61. fwd(segment_size.y/2 + arm_size.y/2 - 1) right(arm_size.x/2 - 1) cuboid(arm_size, fillet=1, edges=EDGES_FRONT + EDGES_Y_ALL);
  62. }
  63. module armFront() {
  64. arm();
  65. }
  66. module armBack() {
  67. scale([1, -1, 1]) arm();
  68. }
  69. module armJoiner() {
  70. joiner_size=[arm_size.x-get_link_socket_size().x, segment_size.y, segment_size.z];
  71. right(joiner_size.x/2 + get_link_socket_size().x/2 + gap) cuboid(joiner_size, fillet=1, edges=EDGES_Z_ALL + EDGES_BOTTOM);
  72. }
  73. module socketJoiner() {
  74. joiner_size=[segment_size.x-get_link_socket_size().x+get_link_socket_size().x*0.2,
  75. segment_size.y-4,
  76. segment_size.z];
  77. difference() {
  78. right(joiner_size.x/2 + 4.5) cuboid(joiner_size, fillet=1, edges=EDGES_Z_ALL + EDGES_BOTTOM);
  79. right(segment_size.x) scale([1, 2, 1]) pin_socket_area();
  80. }
  81. }
  82. module terminalArm() {
  83. left(5) {
  84. shift=arm_size.x - get_link_pin_diameter();
  85. right(segment_size.x + shift + gap/2) pin();
  86. right(segment_size.x + gap/2) {
  87. armFront();
  88. armBack();
  89. }
  90. right(arm_size.x - get_link_socket_size().x + gap) armJoiner();
  91. }
  92. }
  93. armFront();
  94. armBack();
  95. armJoiner();
  96. if (terminal) {
  97. terminalArm();
  98. } else {
  99. socketJoiner();
  100. }
  101. }
  102. pin();
  103. joiner();
  104. if (!terminal) {
  105. right(segment_size.x) pin_socket();
  106. }
  107. }
  108. module clip() {
  109. socket_size=get_link_socket_size();
  110. clip_size=get_link_clip_size();
  111. pin_diam=get_link_pin_diameter();
  112. slot_slack=get_link_socket_slack();
  113. size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z];
  114. slot_size=[clip_size.x+slot_slack.x, size.y+1, pin_diam+slot_slack.z];
  115. entry_size=[slot_size.x, clip_size.y+1, clip_size.z];
  116. entry_pos=[0, 0, 1.5];
  117. module socket_area() {
  118. $fn=$preview? 10 : 20;
  119. xrot(90) down(size.y/2) cylinder(d=size.z, h=size.y);
  120. }
  121. module socket_cutout() {
  122. $fn=$preview? 10 : 20;
  123. xrot(90) down(slot_size.y/2) cylinder(d=slot_size.z, h=slot_size.y);
  124. }
  125. module cover() {
  126. translate(entry_pos) cube(entry_size, center=true);
  127. }
  128. module joiner(groove) {
  129. slack=groove?0.5:0;
  130. joiner_size=[entry_size.x-6+slack, entry_size.y-6+slack, entry_size.z-4+slack];
  131. joiner_pos=[entry_pos.x, entry_pos.y, entry_pos.z - entry_size.z/2];
  132. translate(joiner_pos) cube(joiner_size, center=true);
  133. }
  134. module model() {
  135. difference() {
  136. union() {
  137. right(clip_size.x/2) socket_area();
  138. left(clip_size.x/2) socket_area();
  139. cube(clip_size, center=true);
  140. }
  141. right(clip_size.x/2) socket_cutout();
  142. left(clip_size.x/2) socket_cutout();
  143. }
  144. }
  145. right(clip_size.x/2)
  146. if (is_model(MODEL_CLIP_A)) {
  147. difference() {
  148. model();
  149. cover();
  150. }
  151. joiner(groove=false);
  152. } else if (is_model(MODEL_CLIP_B)) {
  153. difference() {
  154. intersection() {
  155. model();
  156. cover();
  157. }
  158. joiner(groove=true);
  159. }
  160. }
  161. }
  162. module clip_ratcheting(ratchet_length=30) {
  163. socket_size=get_link_socket_size();
  164. clip_size=get_link_clip_size();
  165. pin_diam=get_link_pin_diameter();
  166. slot_slack=get_link_socket_slack();
  167. size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z];
  168. slot_size=[clip_size.x+slot_slack.x + 0.2, size.y+1, pin_diam+slot_slack.z];
  169. entry_size=[slot_size.x-5, clip_size.y+1, clip_size.z];
  170. //right(clip_size.x/2)
  171. module hook() {
  172. intersection() {
  173. difference() {
  174. cuboid(size, fillet=1);
  175. cuboid(slot_size, fillet=1);
  176. up(entry_size.z/2) cube(entry_size, center=true);
  177. }
  178. translate([0, -50, -50]) cube([100, 100, 100]);
  179. }
  180. }
  181. module hookRight() {
  182. hook();
  183. }
  184. module hookLeft() {
  185. scale([-1, 1, 1]) hook();
  186. }
  187. wall=2;
  188. tooth_size=[4, 3, 3];
  189. module tooth() {
  190. s=[tooth_size.x, tooth_size.z, tooth_size.y];
  191. up(tooth_size.z/2) xrot(-90) right_triangle(s);
  192. }
  193. module teethFwd() {
  194. tooth_count = ratchet_length/tooth_size.x;
  195. fwd((clip_size.y-wall*2)/2)
  196. right(ratchet_length/2) {
  197. for (i=[1:tooth_count]) {
  198. left(i*tooth_size.x) tooth();
  199. }
  200. cap_size=[ratchet_length, tooth_size.y, 1];
  201. up(tooth_size.z/2 + cap_size.z/2) left(cap_size.x/2) back(tooth_size.y/2) {
  202. difference() {
  203. cube(cap_size, center=true);
  204. translate([0.1, 0.1, 0]) back(tooth_size.y/2) right(ratchet_length/2) zrot(180) tooth();
  205. }
  206. }
  207. }
  208. }
  209. module teethBack() {
  210. scale([1, -1, 1]) teethFwd();
  211. }
  212. module ratchetLeft() {
  213. right(ratchet_length/2) {
  214. difference() {
  215. cube([ratchet_length, clip_size.y, clip_size.z], center=true);
  216. up(wall/2) cube([ratchet_length, clip_size.y-wall*2, clip_size.z], center=true);
  217. right(ratchet_length/2+1) {
  218. slideRailGuide(groove=true);
  219. scale([1,-1,1]) slideRailGuide(groove=true);
  220. }
  221. }
  222. teethFwd();
  223. teethBack();
  224. }
  225. }
  226. ratchet_tooth_count=2;
  227. ratchet_wall=2.5;
  228. ratchet_slack=0.3;
  229. rail_slack=0.2;
  230. ratchet_tooth_scale_z=0.8;
  231. module ratchetTeethFront() {
  232. module ratchetButton() {
  233. size=[8,wall*4,4];
  234. up(size.z+1) fwd(wall*2 - ratchet_wall) cuboid(size, fillet=1, edges=EDGES_FRONT);
  235. up(2) back(ratchet_wall/2) cube([size.x, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z + size.z], center=true);
  236. }
  237. fwd((clip_size.y-wall*2)/2 - tooth_size.y - ratchet_slack)
  238. left(ratchet_length) {
  239. for (i=[0:ratchet_tooth_count-1]) {
  240. right(i*tooth_size.x) scale([-1,-1*(1-i/5),ratchet_tooth_scale_z]) tooth();
  241. }
  242. ratchetButton();
  243. }
  244. module ratchetWall() {
  245. up(tooth_size.z/2) left(ratchet_length/2 + wall - wall/2) fwd(clip_size.y/2-wall-tooth_size.y-ratchet_wall/2 - ratchet_slack)
  246. down(wall/2+0.5) cube([ratchet_length + wall, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z], center=true);
  247. }
  248. ratchetWall();
  249. }
  250. module ratchetTeethBack() {
  251. scale([1,-1,1]) ratchetTeethFront();
  252. }
  253. module ratchetRight() {
  254. left(wall) cube([wall*2, clip_size.y + rail_slack*2, clip_size.z], center=true);
  255. ratchetTeethFront();
  256. ratchetTeethBack();
  257. }
  258. module slideRailGuide(groove) {
  259. size=[ratchet_length, wall, wall];
  260. fwd(clip_size.y/2 + rail_slack)
  261. left(size.x/2) scale(groove?1.5:1) cuboid(size, fillet=0.5);
  262. }
  263. module slideRailLeft() {
  264. size=[ratchet_length, clip_size.y/2 - ratchet_wall*2 - wall/2 - ratchet_slack - tooth_size.y, clip_size.z];
  265. right(size.x/2) cube(size, center=true);
  266. }
  267. module slideRailRight() {
  268. size=[ratchet_length + 3, wall*1.5, clip_size.z];
  269. module railFront() {
  270. fwd(clip_size.y/2 + size.y/2 + rail_slack) left(size.x/2)
  271. cuboid(size, fillet=1, edges=EDGES_FRONT);
  272. slideRailGuide(groove=false);
  273. }
  274. module railBack() {
  275. scale([1, -1, 1]) railFront();
  276. }
  277. railFront();
  278. railBack();
  279. }
  280. if (is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING)) {
  281. left(ratchet_length + wall + 1) {
  282. hookLeft();
  283. left(0.1) {
  284. ratchetLeft();
  285. slideRailLeft();
  286. }
  287. }
  288. }
  289. if (is_model(MODEL_CLIP_RATCHETING_B) || is_model(MODEL_CLIP_RATCHETING)) {
  290. ratchetRight();
  291. hookRight();
  292. slideRailRight();
  293. }
  294. }
  295. // Export / Demo / Validation:
  296. segment_size=get_link_segment_size();
  297. if (!is_undef(validation)) {
  298. if (validation==VALIDATE_INTERSECTION) {
  299. intersection() {
  300. right(0*segment_size.x) link();
  301. right(1*segment_size.x) link();
  302. }
  303. intersection() {
  304. right(1*segment_size.x) link();
  305. right(2*segment_size.x) link();
  306. }
  307. }
  308. } else {
  309. intersection () {
  310. if (!is_undef(xray)) {
  311. down(50) cube([100, 100, 100], center=true);
  312. }
  313. union() {
  314. if (is_model(MODEL_CLIP_A) || is_model(MODEL_CLIP_B)) {
  315. left(get_link_clip_size().x) clip();
  316. }
  317. if (is_model(MODEL_CLIP_RATCHETING) || is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING_B)) {
  318. left(get_link_clip_size().x) clip_ratcheting();
  319. }
  320. if (is_model(MODEL_LINKS)) for (i = [0:links_count-1]) {
  321. terminal=(i==links_count-1) && include_terminal;
  322. right(i*segment_size.x) link(terminal=terminal);
  323. }
  324. }
  325. }
  326. }