diff --git a/readme.md b/readme.md index 6a480db..c4c99bf 100644 --- a/readme.md +++ b/readme.md @@ -2394,7 +2394,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | Module | Description | |:--- |:--- | | `barrel_jack(cutout = false)` | Draw barrel power jack | -| `block(size, colour, makes_cutout, cutouts)` | Draw a coloured cube to represent a random PCB component | +| `block(size, colour, makes_cutout, cutouts, r = 0, rtop = 0)` | Draw a coloured cube to represent a random PCB component | | `buzzer(height, diameter, colour)` | Draw PCB buzzer with specified height, diameter and colour | | `chip(length, width, thickness, colour, cutout = false)` | Draw a coloured cube to represent a chip, or other rectangular component, or cylinder if width is zero | | `flat_flex(type, cutout = false)` | Draw flat flexistrip connector as used on RPI0 | @@ -2560,7 +2560,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | Module | Description | |:--- |:--- | | `barrel_jack(cutout = false)` | Draw barrel power jack | -| `block(size, colour, makes_cutout, cutouts)` | Draw a coloured cube to represent a random PCB component | +| `block(size, colour, makes_cutout, cutouts, r = 0, rtop = 0)` | Draw a coloured cube to represent a random PCB component | | `buzzer(height, diameter, colour)` | Draw PCB buzzer with specified height, diameter and colour | | `chip(length, width, thickness, colour, cutout = false)` | Draw a coloured cube to represent a chip, or other rectangular component, or cylinder if width is zero | | `flat_flex(type, cutout = false)` | Draw flat flexistrip connector as used on RPI0 | diff --git a/tests/png/pcbs.png b/tests/png/pcbs.png index e5ac8ab..8beaeee 100644 Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 95ae209..da0bbc2 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -1071,7 +1071,7 @@ module trimpot10(vertical, cutout = false) { //! Draw a ten turn trimpot } } -module block(size, colour, makes_cutout, cutouts) //! Draw a coloured cube to represent a random PCB component +module block(size, colour, makes_cutout, cutouts, r = 0, rtop = 0) //! Draw a coloured cube to represent a random PCB component if(cutouts) { if(makes_cutout) translate([-50, 0, size.z / 2 - panel_clearance]) @@ -1079,8 +1079,10 @@ module block(size, colour, makes_cutout, cutouts) //! Draw a coloured cube to re } else color(colour) - translate_z(size.z / 2) - cube(size, center = true); + if(rtop) + let($fn = 32) rounded_top_rectangle(size, r, rtop); + else + rounded_rectangle(size, r); module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb component from description function show(comp, part) = (comp[3] == part || comp[3] == str("-",part)) && (!cutouts || angle == undef || angle == comp.z); @@ -1116,7 +1118,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon if(show(comp, "molex_usb_Ax1")) molex_usb_Ax1(cutouts); if(show(comp, "smd_led")) smd_led(comp[4], comp[5], cutouts); if(show(comp, "7seg")) let(z = param(6, 0)) translate_z(z) 7_segment_digits(comp[4], comp[5], pin_length = z + 3, cutout = cutouts); - if(show(comp, "block")) block(size = [comp[4], comp[5], comp[6]], colour = comp[7], makes_cutout = param(8)); + if(show(comp, "block")) block(size = [comp[4], comp[5], comp[6]], colour = comp[7], makes_cutout = param(8), r = param(9, 0), rtop = param(10, 0)); if(!cutouts) { // Components that don't have a cutout parameter go in this section if(show(comp, "button_6mm")) square_button(button_6mm); diff --git a/vitamins/pcbs.scad b/vitamins/pcbs.scad index 4ec7a27..524abd9 100644 --- a/vitamins/pcbs.scad +++ b/vitamins/pcbs.scad @@ -864,7 +864,7 @@ XIAO = [ [for(x = [0:6], y = [-1,1]) [x * 2.54 + 2.71, y * 3 * 2.54 + 9], // Inboard hole positions for(x = [0:6], y = [-1,1]) [x * 2.54 + 2.71, y * 9 + 9]], // Hole positions on the edge, pad overlaps the inboard holes [ // components - [7.6, 9, 0, "block", 12.3, 12, 2.41, silver], // can + [7.6, 9, 0, "block", 12.3, 12, 2.41, silver, false, 0.3, 0.3], // can [21 + 1.76 - 7.35 / 2, 9, 0, "usb_C"], ], [] // accessories @@ -913,7 +913,7 @@ ESP32_DOIT_V1 = let(l = 51.45, w = 28.33, pitch = inch(1), pins = 15, poffset = [l / 2 + poffset, w / 2 - pitch / 2, 0, "-2p54joiner", pins, 1], [l / 2 + poffset, w / 2 + pitch / 2, 0, "-2p54joiner", pins, 1], [1.75, w / 2, 180, "usb_uA" ], - [35, w / 2, 0, "block", 17.7, 16, 3, silver], // can + [35, w / 2, 0, "block", 17.7, 16, 3, silver, false, 0.3, 0.3], // can for(y=[-1,1]) [3.5, y * 6.5, 0, "chip", 4, 3, 1.6, silver], // Mock button surround for(y=[-1,1]) [3.5, y * 6.5, 0, "chip", 1.8,0, 2.0, grey(20)], // Mock buttons for(y=[-1,1]) [21.6, y * 9, 0, "smd_led", LED0603, y < 0 ? "red" : "blue"],