plate.scad 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. include <../config/plate.scad>
  2. include <ATX.scad>
  3. function plate_mount_holes_pattern() = [
  4. [
  5. -plate_mount_width / 2 + plate_mount_rounding,
  6. plate_mount_depth / 2 - plate_mount_rounding - plate_mount_small
  7. ],
  8. [
  9. -plate_mount_width / 2 + plate_mount_rounding,
  10. -plate_mount_depth / 2 + plate_mount_rounding + plate_mount_small
  11. ],
  12. [
  13. 0,
  14. plate_mount_depth / 2 - plate_mount_rounding - plate_mount_small / 2
  15. ],
  16. [
  17. 0,
  18. -plate_mount_depth / 2 + plate_mount_rounding + plate_mount_small / 2
  19. ],
  20. [
  21. plate_mount_width / 2 - plate_mount_rounding,
  22. plate_mount_depth / 2 - plate_mount_rounding
  23. ],
  24. [
  25. plate_mount_width / 2 - plate_mount_rounding,
  26. -plate_mount_depth / 2 + plate_mount_rounding
  27. ]
  28. ];
  29. module plate_shape() {
  30. size = plate_size;
  31. holes = plate_holes;
  32. padding = plate_padding;
  33. hole = plate_hole;
  34. module corner(x = 0, y = 0) {
  35. translate([x, y]) {
  36. circle(r = padding);
  37. }
  38. }
  39. module board_mount_hole(hole = [0, 0]) {
  40. translate(hole) {
  41. circle(r = hole / 2);
  42. }
  43. }
  44. module base_shape() {
  45. hull() {
  46. move_x = size[0] / 2;
  47. move_y = size[1] / 2;
  48. corner(move_x, move_y);
  49. corner(-move_x, move_y);
  50. corner(move_x, -move_y);
  51. corner(-move_x, -move_y);
  52. }
  53. }
  54. module shape_with_mobo_mount() {
  55. difference() {
  56. base_shape();
  57. for (hole = holes) {
  58. board_mount_hole(hole);
  59. }
  60. }
  61. }
  62. module mount_shape(position = [0, 0], mirrored = false, scaled = false) {
  63. if (mirrored) {
  64. mirror([1, 0]) {
  65. mount_shape(mirrored = false);
  66. }
  67. } else {
  68. width = plate_mount_width;
  69. depth = plate_mount_depth;
  70. small = plate_mount_small;
  71. rounding = plate_mount_rounding;
  72. hole_scale = plate_mount_hole_scale;
  73. hole = plate_mount_hole;
  74. move_x = width / 2 - rounding;
  75. move_y_big = depth / 2 - rounding;
  76. move_y_small = move_y_big - small;
  77. translate(position) {
  78. difference() {
  79. hull() {
  80. translate([move_x, move_y_big]) {
  81. circle(r = rounding);
  82. }
  83. translate([move_x, -move_y_big]) {
  84. circle(r = rounding);
  85. }
  86. translate([-move_x, move_y_small]) {
  87. circle(r = rounding);
  88. }
  89. translate([-move_x, -move_y_small]) {
  90. circle(r = rounding);
  91. }
  92. }
  93. if (!scaled) {
  94. scale(hole_scale) {
  95. mount_shape(scaled = true);
  96. }
  97. for (count = plate_mount_holes_pattern()) {
  98. translate(count) {
  99. circle(r = hole / 2);
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. mount_move_x
  108. = plate_mount_width / 2
  109. + plate_size.x / 2
  110. + plate_padding;
  111. shape_with_mobo_mount();
  112. translate([mount_move_x, 0]) {
  113. mount_shape(mirrored = true);
  114. }
  115. translate([-mount_move_x, 0]) {
  116. mount_shape(mirrored = false);
  117. }
  118. }
  119. module plate_object() {
  120. linear_extrude(height = plate_thickness, center = true) {
  121. plate_shape();
  122. }
  123. }