Преглед изворни кода

refactor flare code into one flare module and addition modules for connector, cable and capsule array stalk

Fernando Pablo Lopez-Lezcano пре 9 година
родитељ
комит
23208763ed
1 измењених фајлова са 59 додато и 106 уклоњено
  1. 59 106
      TinySpHEAR_mount_pcb.scad

+ 59 - 106
TinySpHEAR_mount_pcb.scad

@@ -259,7 +259,7 @@ module tetra_mount_body(height, radius, corner, lower_lip, upper_lip, clear) {
 
 // flares from the body to the microphone stalk and cable
 
-module tetra_mount_flare(height, lip, transition, bot_radius, bot_corner, top_radius, stalk_height, dot) {
+module tetra_mount_flare(height, lip, transition, bot_radius, bot_corner, top_radius) {
     // bottom rounded box
     difference() {
         union() {
@@ -322,127 +322,71 @@ module tetra_mount_flare(height, lip, transition, bot_radius, bot_corner, top_ra
             }
         }
     }
-    // cylindrical stalk
-    translate([0, 0, height + transition]) {
-        difference() {
-            cylinder(r = top_radius, h = stalk_height, $fn = facets);
-            cylinder(r = top_radius - wall, h = stalk_height, $fn = facets);
-        }
-        // add marker for "back of microphone" orientation
-        if (dot == 1) {
-            rotate([0, 0, 90]) {
-                translate([0, top_radius - wall * 2 / 3, stalk_height - top_radius]) {
-                    difference() {
-                        sphere(r = top_radius / 3, $fn = 32);
-                        translate([0, -top_radius + top_radius / 2, 0]) {
-                            cube([top_radius, top_radius, top_radius], center = true);
-                        }
-                    }
+}
+
+// stalk that connects upper flare to capsule array mount
+
+module tetra_mount_array_stalk(height, radius) {
+    difference() {
+        cylinder(r = radius, h = height, $fn = facets);
+        cylinder(r = radius - wall, h = height, $fn = facets);
+    }
+    // add marker for "back of microphone" orientation
+    rotate([0, 0, 90]) {
+        translate([0, radius - wall * 2 / 3, height - radius]) {
+            difference() {
+                sphere(r = radius / 3, $fn = 32);
+                translate([0, -radius + radius / 2, 0]) {
+                    cube([radius, radius, radius], center = true);
                 }
             }
         }
     }
 }
 
-// flares from the body to 12 pin connector
+// bottom cable holder
 
-module tetra_mount_connector_flare(height, lip, transition, bot_radius, bot_corner, top_radius, stalk_height, dot) {
-    // bottom rounded box
+module tetra_mount_cable_holder(height, radius) {
     difference() {
-        union() {
-            rounded_block(height, bot_radius, bot_radius, bot_corner);
-            // make snap joint arm thicker
-            for (r = [90, 270]) rotate([0, 0, r]) {
-                translate([- snap_joint_hook_w - snap_joint_slot_w / 2, bot_radius, 0]) {
-                    cube([snap_joint_hook_w * 2 + snap_joint_slot_w, wall / 2, lip * 1.25]);
-                }
-            }
-        }
-        rounded_block_relative(height, bot_radius, bot_radius, bot_corner, -(2 * wall));
-        // cut flange to mount on body
-        rounded_block_relative(lip + 1.00, bot_radius, bot_radius, bot_corner, - (wall));
-        // cut slots for snap joint hooks
-        for (r = [90, 270]) rotate([0, 0, r]) {
-            for (m = [-1, 1]) {
-                translate([m * (snap_joint_hook_w + snap_joint_slot_w) - snap_joint_slot_w / 2, bot_radius - 1.5 * wall, 0]) {
-                    cube([snap_joint_slot_w, 2 * wall, lip - 1.0]);
-                }
-            }
-        }
-        // and make a smooth transition to avoid overhangs
-        translate([0, 0, lip + 1.00]) {
-            hull() {
-                rounded_block_relative(thin_mint, bot_radius, bot_radius, bot_corner, - wall);
-                translate([0, 0, 1.0]) {
-                    rounded_block_relative(thin_mint, bot_radius, bot_radius, bot_corner, - 2 * wall);
-                }
-            }
-        }
+        cylinder(r = radius, h = height, $fn = facets);
+        cylinder(r = radius - wall, h = height, $fn = facets);
     }
-    // add snap joint hook to arm
-    for (r = [90, 270]) rotate([0, 0, r]) {
-        translate([- snap_joint_hook_w / 2, bot_radius - wall/2, 1/4 * lip]) {
-            rotate([90, 0, 90]) {
-                difference() {
-                    cylinder(r = snap_joint_hook_r - 0.2, h = snap_joint_hook_w, $fn = facets);
-                    translate([0, -snap_joint_hook_r, 0]) {
-                        cube([snap_joint_hook_r, snap_joint_hook_w, snap_joint_hook_w]);
-                    }
+}
+
+// bottom connector holder
+
+module tetra_mount_connector_holder(height, radius, inside_radius, sleeve_height, sleeve_radius) {
+    difference() {
+        union() {
+            cylinder(r = radius, h = height, $fn = facets);
+            // add seats for screw heads
+            for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, radius / 2, conn_core_holes_h]) {
+                rotate([90, 0, 0]) {
+                    scale([1, 1, 1]) cylinder(r = conn_core_screw_d / 2, h = radius * 1.43, $fn = facets);
                 }
             }
         }
-    }
-    // flare to round section
-    translate([0, 0, height]) {
-        difference() {
-            hull() {
-                rounded_block(thin_mint, bot_radius, bot_radius, bot_corner);
-                translate([0, 0, transition]) {
-                    cylinder(r = top_radius, h = thin_mint, $fn = facets);
-                }
-            }
-            hull() {
-                rounded_block_relative(thin_mint, bot_radius, bot_radius, bot_corner, - wall);
-                translate([0, 0, transition]) {
-                    cylinder(r = top_radius - wall, h = thin_mint, $fn = facets);
-                }
+        cylinder(r = inside_radius, h = height, $fn = facets);
+        // transition from thin wall to thick wall at the bottom of connector
+        cylinder(r1 = radius - wall, r2 = inside_radius, h = 2.0, $fn = facets);
+        // holes for connector core screws
+        for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, - radius / 3, conn_core_holes_h]) {
+            rotate([90, 0, 0]) {
+                cylinder(r = conn_core_holes_d / 2, h = radius, $fn = facets);
             }
         }
-    }
-    // connector holder
-    translate([0, 0, height + transition]) {
-        difference() {
-            union() {
-                cylinder(r = top_radius, h = conn_core_sleeve, $fn = facets);
-                // add seats for screw heads
-                for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, top_radius / 2, conn_core_holes_h]) {
-                    rotate([90, 0, 0]) {
-                        scale([1, 1, 1]) cylinder(r = conn_core_screw_d / 2, h = top_radius * 1.43, $fn = facets);
-                    }
-                }
-            }
-            cylinder(r = conn_core_diam / 2, h = conn_core_sleeve, $fn = facets);
-            // transition from thin wall to thick wall at the bottom of connector
-            cylinder(r1 = top_radius - wall, r2 = conn_core_diam / 2, h = 2.0, $fn = facets);
-            // holes for connector core screws
-            for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, - top_radius / 3, conn_core_holes_h]) {
-                rotate([90, 0, 0]) {
-                    cylinder(r = conn_core_holes_d / 2, h = top_radius, $fn = facets);
-                }
-            }
-            // substract cutout for screw heads
-            for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, - top_radius + 1.5, conn_core_holes_h]) {
-                rotate([90, 0, 0]) {
-                    cylinder(r = conn_core_screw_d / 2, h = 2.0, $fn = facets);
-                }
+        // substract cutout for screw heads
+        for (m = [-1, 1]) translate([m * conn_core_holes_w / 2, - radius + 1.5, conn_core_holes_h]) {
+            rotate([90, 0, 0]) {
+                cylinder(r = conn_core_screw_d / 2, h = 2.0, $fn = facets);
             }
         }
     }
     // thinner cylinder sits inside connector sleeve
-    translate([0, 0, height + transition + conn_core_sleeve]) {
+    translate([0, 0, height]) {
         difference() {
-            cylinder(r = conn_core_s_diam / 2, h = conn_core_overlap, $fn = facets);
-            cylinder(r = conn_core_diam / 2, h = conn_core_overlap, $fn = facets);
+            cylinder(r = sleeve_radius, h = sleeve_height, $fn = facets);
+            cylinder(r = inside_radius, h = sleeve_height, $fn = facets);
         }
     }
 }
@@ -542,7 +486,10 @@ module tetra_capsule_array_mount(angles) {
 module render_tetra_capsule_flare(z_offset) {
     translate([0, 0, z_offset]) {
         tetra_mount_flare(pcb_hi_clear + pcb_hi_exp, 
-                    mount_lip, flare_height, box_radius + wall,  mount_corner, mount_radius + wall, stalk_height, 1);
+                    mount_lip, flare_height, box_radius + wall,  mount_corner, mount_radius + wall, stalk_height);
+        translate([0, 0, pcb_hi_clear + pcb_hi_exp + flare_height]) {
+            tetra_mount_array_stalk(stalk_height, mount_radius + wall);
+        }
         translate([0, 0, pcb_hi_clear + pcb_hi_exp + flare_height + stalk_height]) {
             tetra_capsule_array_mount([-45, 135]);
         }
@@ -575,7 +522,10 @@ module render_tetra_pcb_mount(z_offset, showint) {
 
 module render_tetra_cable_flare(z_offset, flip) {
     translate([0, 0, z_offset]) {
-        tetra_mount_flare(pcb_low_clear + pcb_low_exp, mount_lip, 20, box_radius + wall, mount_corner, cable_diam / 2 + wall, 10, 0);
+        tetra_mount_flare(pcb_low_clear + pcb_low_exp, mount_lip, 20, box_radius + wall, mount_corner, cable_diam / 2 + wall, 10);
+        translate([0, 0, pcb_low_clear + pcb_low_exp + 20]) {
+            tetra_mount_cable_holder(10, cable_diam / 2 + wall);
+        }
     }
 }
 
@@ -584,7 +534,10 @@ module render_tetra_cable_flare(z_offset, flip) {
 
 module render_tetra_connector_flare(z_offset, flip) {
     translate([0, 0, z_offset]) {
-        tetra_mount_connector_flare(pcb_low_clear + pcb_low_exp, mount_lip, 20, box_radius + wall, mount_corner, conn_core_o_diam / 2, 10, 0);
+        tetra_mount_flare(pcb_low_clear + pcb_low_exp, mount_lip, 20, box_radius + wall, mount_corner, conn_core_o_diam / 2, 10);
+        rotate([0, 0, -90]) translate([0, 0, pcb_low_clear + pcb_low_exp + 20]) {
+            tetra_mount_connector_holder(conn_core_sleeve, conn_core_o_diam / 2, conn_core_diam / 2, conn_core_overlap, conn_core_s_diam / 2);
+        }
     }
 }