headphones_mount.scad 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. include <../config/headphones_mount.scad>
  2. module headphones_mount_object() {
  3. length = headphones_mount_length;
  4. height = headphones_mount_height;
  5. thickness = headphones_mount_thickness;
  6. width = headphones_mount_width;
  7. screw = headphones_mount_screw;
  8. screws_width = headphones_mount_screws_width;
  9. module base() {
  10. module cutoff(x = 0, y = 0, rotation = 0) {
  11. translate([x, y]) {
  12. rotate(rotation) {
  13. move = width / 2 - thickness / 2;
  14. hull() {
  15. translate([-move, 0]) {
  16. circle(d = thickness);
  17. }
  18. translate([move, 0]) {
  19. circle(d = thickness);
  20. }
  21. }
  22. }
  23. }
  24. }
  25. module ending(split = false) {
  26. mirror([split ? 1 : 0, 0, 0]) {
  27. translate([length / 2, 0, height - thickness / 2]) {
  28. rotate([90, 90, 0]) {
  29. rotate_extrude(angle = 90) {
  30. cutoff(rotation = 90, x = height - thickness / 2);
  31. }
  32. }
  33. }
  34. }
  35. }
  36. module center() {
  37. rotate([90, 0, 90]) {
  38. translate([0, 0, -height / 2]) {
  39. linear_extrude(height = length + height, center = true) {
  40. cutoff();
  41. }
  42. }
  43. }
  44. }
  45. module result() {
  46. translate([0, 0, thickness / 2 - height / 2]) {
  47. ending(split = false);
  48. ending(split = true);
  49. center();
  50. }
  51. }
  52. result();
  53. }
  54. module screws() {
  55. move = screws_width / 2;
  56. module screw_hole(x = 0, y = 0) {
  57. translate([x, y]) {
  58. circle(d = screw);
  59. }
  60. }
  61. module mount() {
  62. hull() {
  63. translate([-move, 0]) {
  64. circle(d = height);
  65. }
  66. translate([move, 0]) {
  67. circle(d = height);
  68. }
  69. }
  70. }
  71. module shape() {
  72. difference() {
  73. mount();
  74. screw_hole(move);
  75. screw_hole(-move);
  76. }
  77. }
  78. module final() {
  79. linear_extrude(height = thickness, center = true) {
  80. shape();
  81. }
  82. }
  83. translate([thickness * 1.5 - length - height, 0, 0]) {
  84. rotate([90, 0, 90]) {
  85. final();
  86. }
  87. }
  88. }
  89. module final() {
  90. color("#404040") {
  91. render() {
  92. union() {
  93. screws();
  94. base();
  95. }
  96. }
  97. }
  98. }
  99. final();
  100. }