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.

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