plate.scad 3.8 KB

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