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.

290 lines
9.6 KiB

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