Pip-Boy inspired phone holder built around the PINE64 PinePhone
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
9.1 KiB

  1. links_count=3; // [1..20]
  2. include_terminal=true; // [true,false]
  3. include <export.scad>
  4. use <BOSL/transforms.scad>
  5. use <BOSL/shapes.scad>
  6. include <BOSL/constants.scad>
  7. use <strap_common.scad>
  8. if (is_model_strict(MODEL_LINKS)) {
  9. echo("===============================");
  10. echo(str("Strap length: ", (links_count * get_link_segment_size().x), " mm"));
  11. echo("===============================");
  12. }
  13. assert(get_link_segment_size().x >= 10, "Link segment is too short.");
  14. assert(get_link_segment_size().z >= (get_link_pin_diameter() + get_link_socket_slack().z + 1), "Link segment is too thin.");
  15. module link(terminal=false) {
  16. $fn=$preview?4:20;
  17. module link_joiner() {
  18. gap=get_link_socket_roundgap();
  19. segment_size=get_link_segment_size();
  20. arm_size=get_link_joiner_arm_size();
  21. module pin_to_socket_joiner() {
  22. joiner_size=[segment_size.x-get_link_socket_size().x+get_link_socket_size().x*0.2,
  23. segment_size.y-4,
  24. segment_size.z];
  25. difference() {
  26. right(joiner_size.x/2 + 4.5) cuboid(joiner_size, fillet=1, edges=EDGES_Z_ALL + EDGES_BOTTOM);
  27. right(segment_size.x) scale([1, 2, 1]) pin_socket_area();
  28. }
  29. }
  30. pin_to_socket_joiner();
  31. }
  32. link_connector_pin();
  33. if (terminal) {
  34. right(get_link_segment_size().x + 2) zrot(180) link_connector_pin();
  35. } else {
  36. link_joiner();
  37. right(get_link_segment_size().x) link_connector_socket();
  38. }
  39. }
  40. module link_chain(links_count, include_terminal=true) {
  41. for (i = [0:links_count-1]) {
  42. terminal=(i==links_count-1) && include_terminal;
  43. right(i*get_link_segment_size().x) link(terminal=terminal);
  44. }
  45. }
  46. module clip() {
  47. $fn=$preview?4:20;
  48. socket_size=get_link_socket_size();
  49. clip_size=get_link_clip_size();
  50. pin_diam=get_link_pin_diameter();
  51. slot_slack=get_link_socket_slack();
  52. size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z];
  53. slot_size=[clip_size.x+slot_slack.x, size.y+1, pin_diam+slot_slack.z];
  54. entry_size=[slot_size.x, clip_size.y+1, clip_size.z];
  55. entry_pos=[0, 0, 1.5];
  56. module socket_area() {
  57. $fn=$preview? 10 : 20;
  58. xrot(90) down(size.y/2) cylinder(d=size.z, h=size.y);
  59. }
  60. module socket_cutout() {
  61. $fn=$preview? 10 : 20;
  62. xrot(90) down(slot_size.y/2) cylinder(d=slot_size.z, h=slot_size.y);
  63. }
  64. module cover() {
  65. translate(entry_pos) cube(entry_size, center=true);
  66. }
  67. module joiner(groove) {
  68. slack=groove?0.2:0;
  69. joiner_size=[entry_size.x-6+slack, entry_size.y-6+slack, entry_size.z-3+slack];
  70. joiner_pos=[entry_pos.x, entry_pos.y, entry_pos.z - entry_size.z/2 + joiner_size.z/2];
  71. translate(joiner_pos) cube(joiner_size, center=true);
  72. }
  73. module model() {
  74. difference() {
  75. union() {
  76. right(clip_size.x/2) socket_area();
  77. left(clip_size.x/2) socket_area();
  78. cube(clip_size, center=true);
  79. }
  80. right(clip_size.x/2) socket_cutout();
  81. left(clip_size.x/2) socket_cutout();
  82. }
  83. }
  84. left(socket_size.x/2)
  85. {
  86. if (is_model(MODEL_CLIP_A)) {
  87. difference() {
  88. model();
  89. cover();
  90. }
  91. joiner(groove=false);
  92. }
  93. if (is_model(MODEL_CLIP_B)) {
  94. difference() {
  95. intersection() {
  96. model();
  97. cover();
  98. }
  99. joiner(groove=true);
  100. }
  101. }
  102. }
  103. }
  104. module clip_ratcheting(ratchet_length=28) {
  105. $fn=$preview?4:20;
  106. socket_size=get_link_socket_size();
  107. clip_size=get_link_clip_size();
  108. pin_diam=get_link_pin_diameter();
  109. slot_slack=get_link_socket_slack();
  110. size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z];
  111. slot_size=[clip_size.x+slot_slack.x + 0.2, size.y+1, pin_diam+slot_slack.z];
  112. entry_size=[slot_size.x-5, clip_size.y+1, clip_size.z];
  113. connector_size=[25, 0, 0];
  114. module hookRight() {
  115. right(connector_size.x/2) zrot(180) link_connector_pin();
  116. }
  117. module hookLeft() {
  118. left(connector_size.x/2) link_connector_pin();
  119. }
  120. wall=2;
  121. tooth_size=[4, 3, 3];
  122. module tooth() {
  123. s=[tooth_size.x, tooth_size.z, tooth_size.y];
  124. up(tooth_size.z/2) xrot(-90) right_triangle(s);
  125. }
  126. module teethFwd() {
  127. tooth_count = ratchet_length/tooth_size.x;
  128. fwd((clip_size.y-wall*2)/2)
  129. right(ratchet_length/2) {
  130. for (i=[1:tooth_count]) {
  131. left(i*tooth_size.x) tooth();
  132. }
  133. cap_size=[ratchet_length, tooth_size.y, 1];
  134. up(tooth_size.z/2 + cap_size.z/2) left(cap_size.x/2) back(tooth_size.y/2) {
  135. difference() {
  136. cube(cap_size, center=true);
  137. translate([0.1, 0.1, 0]) back(tooth_size.y/2) right(ratchet_length/2) zrot(180) tooth();
  138. }
  139. }
  140. }
  141. }
  142. module teethBack() {
  143. scale([1, -1, 1]) teethFwd();
  144. }
  145. module ratchetLeft() {
  146. right(ratchet_length/2) {
  147. difference() {
  148. cube([ratchet_length, clip_size.y, clip_size.z], center=true);
  149. up(wall/2) cube([ratchet_length, clip_size.y-wall*2, clip_size.z], center=true);
  150. right(ratchet_length/2+1) {
  151. slideRailGuide(groove=true);
  152. scale([1,-1,1]) slideRailGuide(groove=true);
  153. }
  154. }
  155. teethFwd();
  156. teethBack();
  157. }
  158. }
  159. ratchet_tooth_count=2;
  160. ratchet_wall=2.5;
  161. ratchet_slack=0.3;
  162. rail_slack=0.2;
  163. ratchet_tooth_scale_z=0.8;
  164. module ratchetTeethFront() {
  165. module ratchetButton() {
  166. size=[8,wall*4,4];
  167. up(size.z+1) fwd(wall*2 - ratchet_wall) cuboid(size, fillet=1, edges=EDGES_FRONT);
  168. up(2) back(ratchet_wall/2) cube([size.x, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z + size.z], center=true);
  169. }
  170. fwd((clip_size.y-wall*2)/2 - tooth_size.y - ratchet_slack)
  171. left(ratchet_length) {
  172. for (i=[0:ratchet_tooth_count-1]) {
  173. right(i*tooth_size.x) scale([-1,-1*(1-i/5),ratchet_tooth_scale_z]) tooth();
  174. }
  175. ratchetButton();
  176. }
  177. module ratchetWall() {
  178. 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)
  179. down(wall/2+0.5) cube([ratchet_length + wall, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z], center=true);
  180. }
  181. ratchetWall();
  182. }
  183. module ratchetTeethBack() {
  184. scale([1,-1,1]) ratchetTeethFront();
  185. }
  186. module ratchetRight() {
  187. left(wall) cube([wall*2, clip_size.y + rail_slack*2, clip_size.z], center=true);
  188. ratchetTeethFront();
  189. ratchetTeethBack();
  190. }
  191. module slideRailGuide(groove) {
  192. size=[ratchet_length, wall, wall];
  193. fwd(clip_size.y/2 + rail_slack)
  194. left(size.x/2) scale(groove?1.5:1) cuboid(size, fillet=0.5);
  195. }
  196. module slideRailLeft() {
  197. size=[ratchet_length, clip_size.y/2 - ratchet_wall*2 - wall/2 - ratchet_slack - tooth_size.y, clip_size.z];
  198. right(size.x/2) cube(size, center=true);
  199. }
  200. module slideRailRight() {
  201. size=[ratchet_length + 3, wall*1.5, clip_size.z];
  202. module railFront() {
  203. fwd(clip_size.y/2 + size.y/2 + rail_slack) left(size.x/2)
  204. cuboid(size, fillet=1, edges=EDGES_FRONT);
  205. slideRailGuide(groove=false);
  206. }
  207. module railBack() {
  208. scale([1, -1, 1]) railFront();
  209. }
  210. railFront();
  211. railBack();
  212. }
  213. right(size.x + connector_size.x - 2) {
  214. left(2)
  215. if (is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING)) {
  216. left(ratchet_length + wall + 1) {
  217. hookLeft();
  218. left(0.1) {
  219. ratchetLeft();
  220. slideRailLeft();
  221. }
  222. }
  223. }
  224. right(is_model(MODEL_DEMO) ? ratchet_length + 5 : 0)
  225. if (is_model(MODEL_CLIP_RATCHETING_B) || is_model(MODEL_CLIP_RATCHETING)) {
  226. ratchetRight();
  227. hookRight();
  228. slideRailRight();
  229. }
  230. }
  231. }
  232. // === Export ===
  233. if (is_model(MODEL_DEMO)) {
  234. translate([-20, -40, -10]) zrot(-90) {
  235. link_chain(links_count, include_terminal=include_terminal);
  236. right(links_count * get_link_segment_size().x + get_link_clip_size().x) {
  237. clip();
  238. right(get_link_clip_size().x) clip_ratcheting();
  239. }
  240. }
  241. } else {
  242. if (is_model(MODEL_CLIP_A) || is_model(MODEL_CLIP_B)) {
  243. left(get_link_clip_size().x) clip();
  244. }
  245. if (is_model(MODEL_CLIP_RATCHETING) || is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING_B)) {
  246. left(get_link_clip_size().x * 2 + 3) clip_ratcheting();
  247. }
  248. if (is_model(MODEL_LINKS)) for (i = [0:links_count-1]) {
  249. terminal=(i==links_count-1) && include_terminal;
  250. right(i*get_link_segment_size().x) link(terminal=terminal);
  251. }
  252. }