Pip-Boy inspired phone holder built around the PINE64 PinePhone
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

356 Zeilen
11 KiB

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