1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-01-17 05:28:14 +01:00

Allow pin header base colour to be set on PCB.

This commit is contained in:
Martin Budden 2020-01-30 19:59:04 +00:00
parent c1833f0820
commit ce36729e50
2 changed files with 4 additions and 3 deletions

View File

@ -710,7 +710,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
function show(comp, part) = (comp[3] == part || comp[3] == str("-",part)) && (!cutouts || angle == undef || angle == comp.z); function show(comp, part) = (comp[3] == part || comp[3] == str("-",part)) && (!cutouts || angle == undef || angle == comp.z);
function param(n, default = 0) = len(comp) > n ? comp[n] : default; function param(n, default = 0) = len(comp) > n ? comp[n] : default;
rotate(comp.z) { rotate(comp.z) {
if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6), cutouts); if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6), cutouts, colour = param(7, undef));
if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6), cutouts); if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6), cutouts);
if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7), param(8, false), cutouts); if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7), param(8, false), cutouts);
if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey30), cutouts); if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey30), cutouts);

View File

@ -43,8 +43,9 @@ module pin(type, length = undef) { //! Draw a header pin
} }
} }
module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cutout = false) { //! Draw pin header module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cutout = false, colour) { //! Draw pin header
pitch = hdr_pitch(type); pitch = hdr_pitch(type);
base_colour = colour ? colour : hdr_base_colour(type);
h = pitch; h = pitch;
ra_offset = 2.4; ra_offset = 2.4;
width = pitch * rows; width = pitch * rows;
@ -79,7 +80,7 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
} }
translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0]) translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0])
rotate([right_angle ? 90 : 0, 0, 0]) rotate([right_angle ? 90 : 0, 0, 0])
color(hdr_base_colour(type)) color(base_colour)
linear_extrude(height = h) linear_extrude(height = h)
for(x = [0 : cols - 1], y = [0 : rows - 1]) for(x = [0 : cols - 1], y = [0 : rows - 1])
translate([pitch * (x - (cols - 1) / 2), pitch * (y - (rows - 1) / 2), pitch / 2]) translate([pitch * (x - (cols - 1) / 2), pitch * (y - (rows - 1) / 2), pitch / 2])