From a5bc80c0e865335cde29db9203438fe4bc659f43 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Mon, 10 Jan 2022 23:28:33 +0000 Subject: [PATCH] Added D_plug_d() function. --- readme.md | 1 + vitamins/d_connector.scad | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/readme.md b/readme.md index d37a46e..9596432 100644 --- a/readme.md +++ b/readme.md @@ -876,6 +876,7 @@ D-connectors. Can be any number of ways, male or female, solder buckets, PCB mou | `d_connector_holes(type)` | Place children at the screw hole positions | | `d_pillar()` | Draw a pillar for a D-connector | | `d_plug(type, socket = false, pcb = false, idc = false)` | Draw specified D plug, which can be IDC, PCB or plain solder bucket | +| `d_plug_D(length, width, rad)` | D plug D shape | | `d_socket(connector, pcb = false, idc = false)` | Draw specified D socket, which can be IDC, PCB or plain solder bucket | ![d_connectors](tests/png/d_connectors.png) diff --git a/vitamins/d_connector.scad b/vitamins/d_connector.scad index 0357c13..f4f69a8 100644 --- a/vitamins/d_connector.scad +++ b/vitamins/d_connector.scad @@ -72,6 +72,16 @@ module d_pillar() { //! Draw a pillar for a D-connector female_metric_thread(screw, pitch, height, false, colour = d_pillar_colour); } +module d_plug_D(length, width, rad) { //! D plug D shape + d = width / 2 - rad; + offset = d * sin(10); + + hull() + for(x = [-1, 1], y = [-1, 1]) + translate([x * (length / 2 - rad) + y * x * offset, y * (width / 2 - rad)]) + circle(rad); +} + module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specified D plug, which can be IDC, PCB or plain solder bucket hole_r = 3.05 / 2; dwall = 0.5; @@ -89,16 +99,6 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi vitamin(str(socket ? "d_socket(" : "d_plug(", type[0], arg(pcb, false, "pcb"), arg(idc, false, "idc"), "): D-type ", pins, " way ", desc, socket ? " socket" : " plug")); - module D(length, width, rad) { - d = width / 2 - rad; - offset = d * sin(10); - - hull() - for(x = [-1, 1], y = [-1, 1]) - translate([x * (length / 2 - rad) + y * x * offset, y * (width / 2 - rad)]) - circle(rad); - } - module pin_positions() for($i = [1 : pins]) translate([($i - (pins + 1) / 2) * 2.77 / 2, ($i % 2 - 0.5) * 2.84]) @@ -117,14 +117,14 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi linear_extrude(front_height, convexity = 5) difference() { - D(d_length, d_width, 2.5); - D(d_length - 2 * dwall, d_width - 2 * dwall, 2.5 - dwall); + d_plug_D(d_length, d_width, 2.5); + d_plug_D(d_length - 2 * dwall, d_width - 2 * dwall, 2.5 - dwall); } if(!idc) - rotate([0,180,0]) + hflip() linear_extrude(back_height, convexity = 5) - D(d_lengths(type)[0] + 2 * dwall, d_widths(type)[0] + 2 * dwall, 2.5 + dwall); + d_plug_D(d_lengths(type)[0] + 2 * dwall, d_widths(type)[0] + 2 * dwall, 2.5 + dwall); } // @@ -134,12 +134,12 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi translate_z(d_flange_thickness(type) + eps) rotate([0, 180, 0]) linear_extrude(back_height + 1 + d_flange_thickness(type), convexity = 5) - D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); + d_plug_D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); if(socket) linear_extrude(front_height - eps, convexity = 5) difference() { - D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); + d_plug_D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); pin_positions() circle(r = 0.7);