diff --git a/src/footprints/alps.js b/src/footprints/alps.js index c1e28c4..ad98514 100644 --- a/src/footprints/alps.js +++ b/src/footprints/alps.js @@ -1,11 +1,18 @@ module.exports = { nets: ['from', 'to'], + params: { + class: 'S' + }, body: p => ` (module ALPS (layer F.Cu) (tedit 5CF31DEF) ${p.at /* parametric position */} + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + ${''/* corner marks */} (fp_line (start -7 -6) (end -7 -7) (layer Dwgs.User) (width 0.15)) (fp_line (start -7 7) (end -6 7) (layer Dwgs.User) (width 0.15)) @@ -17,8 +24,8 @@ module.exports = { (fp_line (start 7 -7) (end 7 -6) (layer Dwgs.User) (width 0.15)) ${''/* pins */} - (pad 1 thru_hole circle (at 2.5 -4.5) (size 2.25 2.25) (drill 1.47) (layers *.Cu *.Mask) ${p.net_from}) - (pad 2 thru_hole circle (at -2.5 -4) (size 2.25 2.25) (drill 1.47) (layers *.Cu *.Mask) ${p.net_to}) + (pad 1 thru_hole circle (at 2.5 -4.5) (size 2.25 2.25) (drill 1.47) (layers *.Cu *.Mask) ${p.net.from}) + (pad 2 thru_hole circle (at -2.5 -4) (size 2.25 2.25) (drill 1.47) (layers *.Cu *.Mask) ${p.net.to}) ) ` diff --git a/src/footprints/choc.js b/src/footprints/choc.js index bd44684..13a7122 100644 --- a/src/footprints/choc.js +++ b/src/footprints/choc.js @@ -1,11 +1,18 @@ module.exports = { nets: ['from', 'to'], + params: { + class: 'S' + }, body: p => ` (module PG1350 (layer F.Cu) (tedit 5DD50112) ${p.at /* parametric position */} + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + ${''/* corner marks */} (fp_line (start -7 -6) (end -7 -7) (layer Dwgs.User) (width 0.15)) (fp_line (start -7 7) (end -6 7) (layer Dwgs.User) (width 0.15)) @@ -17,8 +24,8 @@ module.exports = { (fp_line (start 7 -7) (end 7 -6) (layer Dwgs.User) (width 0.15)) ${''/* pins */} - (pad 1 thru_hole circle (at 5 -3.8) (size 2.032 2.032) (drill 1.27) (layers *.Cu *.Mask) ${p.net_from}) - (pad 2 thru_hole circle (at 0 -5.9) (size 2.032 2.032) (drill 1.27) (layers *.Cu *.Mask) ${p.net_to}) + (pad 1 thru_hole circle (at 5 -3.8) (size 2.032 2.032) (drill 1.27) (layers *.Cu *.Mask) ${p.net.from}) + (pad 2 thru_hole circle (at 0 -5.9) (size 2.032 2.032) (drill 1.27) (layers *.Cu *.Mask) ${p.net.to}) ${''/* middle shaft */} (pad "" np_thru_hole circle (at 0 0) (size 3.429 3.429) (drill 3.429) (layers *.Cu *.Mask)) diff --git a/src/footprints/diode.js b/src/footprints/diode.js index 1c91063..02825c9 100644 --- a/src/footprints/diode.js +++ b/src/footprints/diode.js @@ -1,11 +1,18 @@ module.exports = { nets: ['from', 'to'], + params: { + class: 'D' + }, body: p => ` (module ComboDiode (layer F.Cu) (tedit 5B24D78E) ${p.at /* parametric position */} + + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) ${''/* diode symbols */} (fp_line (start 0.25 0) (end 0.75 0) (layer F.SilkS) (width 0.1)) @@ -24,14 +31,14 @@ module.exports = { (fp_line (start -0.75 0) (end -0.35 0) (layer B.SilkS) (width 0.1)) ${''/* SMD pads on both sides */} - (pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.net_to}) - (pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.net_from}) - (pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.net_to}) - (pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.net_from}) + (pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.net.to}) + (pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.net.from}) + (pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.net.to}) + (pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.net.from}) ${''/* THT terminals */} - (pad 1 thru_hole circle (at 3.81 0 ${p.rot}) (size 1.905 1.905) (drill 0.9906) (layers *.Cu *.Mask) ${p.net_from}) - (pad 2 thru_hole rect (at -3.81 0 ${p.rot}) (size 1.778 1.778) (drill 0.9906) (layers *.Cu *.Mask) ${p.net_to}) + (pad 1 thru_hole circle (at 3.81 0 ${p.rot}) (size 1.905 1.905) (drill 0.9906) (layers *.Cu *.Mask) ${p.net.from}) + (pad 2 thru_hole rect (at -3.81 0 ${p.rot}) (size 1.778 1.778) (drill 0.9906) (layers *.Cu *.Mask) ${p.net.to}) ) ` diff --git a/src/footprints/jstph.js b/src/footprints/jstph.js index 0cc69c6..e8a2e43 100644 --- a/src/footprints/jstph.js +++ b/src/footprints/jstph.js @@ -1,6 +1,7 @@ module.exports = { nets: ['pos', 'neg'], params: { + class: 'J', side: 'F' }, body: p => ` @@ -12,20 +13,24 @@ module.exports = { ${p.at /* parametric position */} - (fp_line (start -2.25 0.25) (end -2.25 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.25 -1.35) (end -2.95 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.95 -1.35) (end -2.95 6.25) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.95 6.25) (end 2.95 6.25) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.95 6.25) (end 2.95 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.95 -1.35) (end 2.25 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.25 -1.35) (end 2.25 0.25) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.25 0.25) (end -2.25 0.25) (layer ${p.param_side}.SilkS) (width 0.15)) + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) - (fp_line (start -1 1.5) (end -1 2.0) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -1.25 1.75) (end -0.75 1.75) (layer ${p.param_side}.SilkS) (width 0.15)) + (fp_line (start -2.25 0.25) (end -2.25 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.25 -1.35) (end -2.95 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.95 -1.35) (end -2.95 6.25) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.95 6.25) (end 2.95 6.25) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.95 6.25) (end 2.95 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.95 -1.35) (end 2.25 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.25 -1.35) (end 2.25 0.25) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.25 0.25) (end -2.25 0.25) (layer ${p.param.side}.SilkS) (width 0.15)) - (pad 1 thru_hole rect (at -1 0 ${p.rot}) (size 1.2 1.7) (drill 0.75) (layers *.Cu *.Mask) ${p.net_pos}) - (pad 2 thru_hole oval (at 1 0 ${p.rot}) (size 1.2 1.7) (drill 0.75) (layers *.Cu *.Mask) ${p.net_neg}) + (fp_line (start -1 1.5) (end -1 2.0) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -1.25 1.75) (end -0.75 1.75) (layer ${p.param.side}.SilkS) (width 0.15)) + + (pad 1 thru_hole rect (at -1 0 ${p.rot}) (size 1.2 1.7) (drill 0.75) (layers *.Cu *.Mask) ${p.net.pos}) + (pad 2 thru_hole oval (at 1 0 ${p.rot}) (size 1.2 1.7) (drill 0.75) (layers *.Cu *.Mask) ${p.net.neg}) ) diff --git a/src/footprints/mx.js b/src/footprints/mx.js index 214ea62..981cfd5 100644 --- a/src/footprints/mx.js +++ b/src/footprints/mx.js @@ -1,11 +1,18 @@ module.exports = { nets: ['from', 'to'], + params: { + class: 'S' + }, body: p => ` (module MX (layer F.Cu) (tedit 5DD4F656) ${p.at /* parametric position */} + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + ${''/* corner marks */} (fp_line (start -7 -6) (end -7 -7) (layer Dwgs.User) (width 0.15)) (fp_line (start -7 7) (end -6 7) (layer Dwgs.User) (width 0.15)) @@ -17,8 +24,8 @@ module.exports = { (fp_line (start 7 -7) (end 7 -6) (layer Dwgs.User) (width 0.15)) ${''/* pins */} - (pad 1 thru_hole circle (at 2.54 -5.08) (size 2.286 2.286) (drill 1.4986) (layers *.Cu *.Mask) ${p.net_from}) - (pad 2 thru_hole circle (at -3.81 -2.54) (size 2.286 2.286) (drill 1.4986) (layers *.Cu *.Mask) ${p.net_to}) + (pad 1 thru_hole circle (at 2.54 -5.08) (size 2.286 2.286) (drill 1.4986) (layers *.Cu *.Mask) ${p.net.from}) + (pad 2 thru_hole circle (at -3.81 -2.54) (size 2.286 2.286) (drill 1.4986) (layers *.Cu *.Mask) ${p.net.to}) ${''/* middle shaft */} (pad "" np_thru_hole circle (at 0 0) (size 3.9878 3.9878) (drill 3.9878) (layers *.Cu *.Mask)) diff --git a/src/footprints/pad.js b/src/footprints/pad.js index 5c7f9c4..eb5e69b 100644 --- a/src/footprints/pad.js +++ b/src/footprints/pad.js @@ -1,6 +1,7 @@ module.exports = { nets: ['net'], params: { + class: 'P', width: 1, height: 1, front: true, @@ -15,18 +16,18 @@ module.exports = { if (!toggle) return '' let x = 0, y = 0 const mirror = side == 'B' ? '(justify mirror)' : '' - const plus = (p.param_text.length + 1) * 0.5 - let align = p.param_align - if (p.param_mirrored === true) { + const plus = (p.param.text.length + 1) * 0.5 + let align = p.param.align + if (p.param.mirrored === true) { if (align == 'left') align = 'right' else if (align == 'right') align = 'left' } - if (align == 'left') x -= p.param_width / 2 + plus - if (align == 'right') x += p.param_width / 2 + plus - if (align == 'up') y += p.param_height / 2 + plus - if (align == 'down') y -= p.param_height / 2 + plus - const text = `(fp_text user ${p.param_text} (at ${x} ${y} ${p.rot}) (layer ${side}.SilkS) (effects (font (size 0.8 0.8) (thickness 0.15)) ${mirror}))` - return `(pad 1 smd rect (at 0 0 ${p.rot}) (size ${p.param_width} ${p.param_height}) (layers ${side}.Cu ${side}.Paste ${side}.Mask) ${p.net_net})\n${text}` + if (align == 'left') x -= p.param.width / 2 + plus + if (align == 'right') x += p.param.width / 2 + plus + if (align == 'up') y += p.param.height / 2 + plus + if (align == 'down') y -= p.param.height / 2 + plus + const text = `(fp_text user ${p.param.text} (at ${x} ${y} ${p.rot}) (layer ${side}.SilkS) (effects (font (size 0.8 0.8) (thickness 0.15)) ${mirror}))` + return `(pad 1 smd rect (at 0 0 ${p.rot}) (size ${p.param.width} ${p.param.height}) (layers ${side}.Cu ${side}.Paste ${side}.Mask) ${p.net.net})\n${text}` } return ` @@ -34,10 +35,14 @@ module.exports = { (module SMDPad (layer F.Cu) (tedit 5B24D78E) ${p.at /* parametric position */} + + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) ${''/* SMD pads */} - ${layout(p.param_front, 'F')} - ${layout(p.param_back, 'B')} + ${layout(p.param.front, 'F')} + ${layout(p.param.back, 'B')} ) diff --git a/src/footprints/promicro.js b/src/footprints/promicro.js index 1e4dd5a..b7eacde 100644 --- a/src/footprints/promicro.js +++ b/src/footprints/promicro.js @@ -6,11 +6,18 @@ module.exports = { 'P1', 'P0', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9' ], + params: { + class: 'C' // for Controller + }, body: p => ` (module ProMicro (layer F.Cu) (tedit 5B307E4C) ${p.at /* parametric position */} + + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) ${''/* illustration of the (possible) USB port overhang */} (fp_line (start -19.304 -3.556) (end -14.224 -3.556) (layer Dwgs.User) (width 0.15)) @@ -57,31 +64,31 @@ module.exports = { (fp_text user P09 (at 13.97 -4.8 ${p.rot + 90}) (layer F.SilkS) (effects (font (size 0.8 0.8) (thickness 0.15)))) ${''/* and now the actual pins */} - (pad 1 thru_hole rect (at -13.97 7.62 ${p.rot}) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_RAW}) - (pad 2 thru_hole circle (at -11.43 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_GND}) - (pad 3 thru_hole circle (at -8.89 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_RST}) - (pad 4 thru_hole circle (at -6.35 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_VCC}) - (pad 5 thru_hole circle (at -3.81 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P21}) - (pad 6 thru_hole circle (at -1.27 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P20}) - (pad 7 thru_hole circle (at 1.27 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P19}) - (pad 8 thru_hole circle (at 3.81 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P18}) - (pad 9 thru_hole circle (at 6.35 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P15}) - (pad 10 thru_hole circle (at 8.89 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P14}) - (pad 11 thru_hole circle (at 11.43 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P16}) - (pad 12 thru_hole circle (at 13.97 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P10}) + (pad 1 thru_hole rect (at -13.97 7.62 ${p.rot}) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.RAW}) + (pad 2 thru_hole circle (at -11.43 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.GND}) + (pad 3 thru_hole circle (at -8.89 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.RST}) + (pad 4 thru_hole circle (at -6.35 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.VCC}) + (pad 5 thru_hole circle (at -3.81 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P21}) + (pad 6 thru_hole circle (at -1.27 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P20}) + (pad 7 thru_hole circle (at 1.27 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P19}) + (pad 8 thru_hole circle (at 3.81 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P18}) + (pad 9 thru_hole circle (at 6.35 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P15}) + (pad 10 thru_hole circle (at 8.89 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P14}) + (pad 11 thru_hole circle (at 11.43 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P16}) + (pad 12 thru_hole circle (at 13.97 7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P10}) - (pad 13 thru_hole circle (at -13.97 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P1}) - (pad 14 thru_hole circle (at -11.43 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P0}) - (pad 15 thru_hole circle (at -8.89 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_GND}) - (pad 16 thru_hole circle (at -6.35 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_GND}) - (pad 17 thru_hole circle (at -3.81 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P2}) - (pad 18 thru_hole circle (at -1.27 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P3}) - (pad 19 thru_hole circle (at 1.27 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P4}) - (pad 20 thru_hole circle (at 3.81 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P5}) - (pad 21 thru_hole circle (at 6.35 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P6}) - (pad 22 thru_hole circle (at 8.89 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P7}) - (pad 23 thru_hole circle (at 11.43 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P8}) - (pad 24 thru_hole circle (at 13.97 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net_P9}) + (pad 13 thru_hole circle (at -13.97 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P1}) + (pad 14 thru_hole circle (at -11.43 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P0}) + (pad 15 thru_hole circle (at -8.89 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.GND}) + (pad 16 thru_hole circle (at -6.35 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.GND}) + (pad 17 thru_hole circle (at -3.81 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P2}) + (pad 18 thru_hole circle (at -1.27 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P3}) + (pad 19 thru_hole circle (at 1.27 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P4}) + (pad 20 thru_hole circle (at 3.81 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P5}) + (pad 21 thru_hole circle (at 6.35 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P6}) + (pad 22 thru_hole circle (at 8.89 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P7}) + (pad 23 thru_hole circle (at 11.43 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P8}) + (pad 24 thru_hole circle (at 13.97 -7.62 0) (size 1.7526 1.7526) (drill 1.0922) (layers *.Cu *.SilkS *.Mask) ${p.net.P9}) ) ` } diff --git a/src/footprints/reset.js b/src/footprints/reset.js index 7911029..bb13b9c 100644 --- a/src/footprints/reset.js +++ b/src/footprints/reset.js @@ -1,6 +1,7 @@ module.exports = { nets: ['from', 'to'], params: { + class: 'B', // for Button side: 'F' }, body: p => ` @@ -11,22 +12,25 @@ module.exports = { (tags "SPST Tactile Switch") ${p.at /* parametric position */} + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) ${'' /* outline */} - (fp_line (start 2.75 1.25) (end 1.25 2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.75 -1.25) (end 1.25 -2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.75 -1.25) (end 2.75 1.25) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -1.25 2.75) (end 1.25 2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -1.25 -2.75) (end 1.25 -2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.75 1.25) (end -1.25 2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.75 -1.25) (end -1.25 -2.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.75 -1.25) (end -2.75 1.25) (layer ${p.param_side}.SilkS) (width 0.15)) + (fp_line (start 2.75 1.25) (end 1.25 2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.75 -1.25) (end 1.25 -2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.75 -1.25) (end 2.75 1.25) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -1.25 2.75) (end 1.25 2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -1.25 -2.75) (end 1.25 -2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.75 1.25) (end -1.25 2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.75 -1.25) (end -1.25 -2.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.75 -1.25) (end -2.75 1.25) (layer ${p.param.side}.SilkS) (width 0.15)) ${'' /* pins */} - (pad 1 smd rect (at -3.1 -1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_from}) - (pad 1 smd rect (at 3.1 -1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_from}) - (pad 2 smd rect (at -3.1 1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_to}) - (pad 2 smd rect (at 3.1 1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_to}) + (pad 1 smd rect (at -3.1 -1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.from}) + (pad 1 smd rect (at 3.1 -1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.from}) + (pad 2 smd rect (at -3.1 1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.to}) + (pad 2 smd rect (at 3.1 1.85 ${p.rot}) (size 1.8 1.1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.to}) ) ` diff --git a/src/footprints/rgb.js b/src/footprints/rgb.js index 28f4a61..6fc8ca1 100644 --- a/src/footprints/rgb.js +++ b/src/footprints/rgb.js @@ -2,6 +2,7 @@ module.exports = { static_nets: ['VCC', 'GND'], nets: ['din', 'dout'], params: { + class: 'L', // for Led side: 'F' }, body: p => ` @@ -10,27 +11,31 @@ module.exports = { ${p.at /* parametric position */} - (fp_line (start -1.75 -1.75) (end -1.75 1.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -1.75 1.75) (end 1.75 1.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 1.75 1.75) (end 1.75 -1.75) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 1.75 -1.75) (end -1.75 -1.75) (layer ${p.param_side}.SilkS) (width 0.15)) + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) - (fp_line (start -2.5 -2.5) (end -2.5 2.5) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -2.5 2.5) (end 2.5 2.5) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.5 2.5) (end 2.5 -2.5) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 2.5 -2.5) (end -2.5 -2.5) (layer ${p.param_side}.SilkS) (width 0.15)) + (fp_line (start -1.75 -1.75) (end -1.75 1.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -1.75 1.75) (end 1.75 1.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 1.75 1.75) (end 1.75 -1.75) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 1.75 -1.75) (end -1.75 -1.75) (layer ${p.param.side}.SilkS) (width 0.15)) - (fp_poly (pts (xy 4 2.2) (xy 4 0.375) (xy 5 1.2875)) (layer ${p.param_side}.SilkS) (width 0.1)) + (fp_line (start -2.5 -2.5) (end -2.5 2.5) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -2.5 2.5) (end 2.5 2.5) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.5 2.5) (end 2.5 -2.5) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 2.5 -2.5) (end -2.5 -2.5) (layer ${p.param.side}.SilkS) (width 0.15)) - (pad 1 smd rect (at -2.2 -0.875 ${p.rot}) (size 2.6 1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_VCC}) - (pad 2 smd rect (at -2.2 0.875 ${p.rot}) (size 2.6 1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_dout}) - (pad 3 smd rect (at 2.2 0.875 ${p.rot}) (size 2.6 1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_GND}) - (pad 4 smd rect (at 2.2 -0.875 ${p.rot}) (size 2.6 1) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_din}) + (fp_poly (pts (xy 4 2.2) (xy 4 0.375) (xy 5 1.2875)) (layer ${p.param.side}.SilkS) (width 0.1)) - (pad 11 smd rect (at -2.5 -1.6 ${p.rot}) (size 2 1.2) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_VCC}) - (pad 22 smd rect (at -2.5 1.6 ${p.rot}) (size 2 1.2) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_dout}) - (pad 33 smd rect (at 2.5 1.6 ${p.rot}) (size 2 1.2) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_GND}) - (pad 44 smd rect (at 2.5 -1.6 ${p.rot}) (size 2 1.2) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_din}) + (pad 1 smd rect (at -2.2 -0.875 ${p.rot}) (size 2.6 1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.VCC}) + (pad 2 smd rect (at -2.2 0.875 ${p.rot}) (size 2.6 1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.dout}) + (pad 3 smd rect (at 2.2 0.875 ${p.rot}) (size 2.6 1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.GND}) + (pad 4 smd rect (at 2.2 -0.875 ${p.rot}) (size 2.6 1) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.din}) + + (pad 11 smd rect (at -2.5 -1.6 ${p.rot}) (size 2 1.2) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.VCC}) + (pad 22 smd rect (at -2.5 1.6 ${p.rot}) (size 2 1.2) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.dout}) + (pad 33 smd rect (at 2.5 1.6 ${p.rot}) (size 2 1.2) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.GND}) + (pad 44 smd rect (at 2.5 -1.6 ${p.rot}) (size 2 1.2) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.din}) ) diff --git a/src/footprints/slider.js b/src/footprints/slider.js index 6caad77..f1b203f 100644 --- a/src/footprints/slider.js +++ b/src/footprints/slider.js @@ -1,25 +1,31 @@ module.exports = { nets: ['from', 'to'], params: { + class: 'T', // for Toggle (?) side: 'F' }, body: p => { - const sign = p.param_side == 'F' ? '-' : '' + const left = p.param.side == 'F' ? '-' : '' + const right = p.param.side == 'F' ? '' : '-' return ` (module E73:SPDT_C128955 (layer F.Cu) (tstamp 5BF2CC3C) ${p.at /* parametric position */} + + ${'' /* footprint reference */} + (fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) (effects (font (size 1.27 1.27) (thickness 0.15)))) ${'' /* outline */} - (fp_line (start 1.95 -1.35) (end -1.95 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 0 -1.35) (end -3.3 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -3.3 -1.35) (end -3.3 1.5) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start -3.3 1.5) (end 3.3 1.5) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 3.3 1.5) (end 3.3 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) - (fp_line (start 0 -1.35) (end 3.3 -1.35) (layer ${p.param_side}.SilkS) (width 0.15)) + (fp_line (start 1.95 -1.35) (end -1.95 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 0 -1.35) (end -3.3 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -3.3 -1.35) (end -3.3 1.5) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start -3.3 1.5) (end 3.3 1.5) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 3.3 1.5) (end 3.3 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) + (fp_line (start 0 -1.35) (end 3.3 -1.35) (layer ${p.param.side}.SilkS) (width 0.15)) ${'' /* extra indicator for the slider */} (fp_line (start -1.95 -3.85) (end 1.95 -3.85) (layer Dwgs.User) (width 0.15)) @@ -31,15 +37,15 @@ module.exports = { (pad "" np_thru_hole circle (at -1.5 0) (size 1 1) (drill 0.9) (layers *.Cu *.Mask)) ${'' /* pins */} - (pad 1 smd rect (at 2.25 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_from}) - (pad 2 smd rect (at ${sign}0.75 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask) ${p.net_to}) - (pad 3 smd rect (at -2.25 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask)) + (pad 1 smd rect (at ${right}2.25 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.from}) + (pad 2 smd rect (at ${left}0.75 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask) ${p.net.to}) + (pad 3 smd rect (at ${left}2.25 2.075 ${p.rot}) (size 0.9 1.25) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask)) ${'' /* side mounts */} - (pad "" smd rect (at 3.7 -1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask)) - (pad "" smd rect (at 3.7 1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask)) - (pad "" smd rect (at -3.7 1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask)) - (pad "" smd rect (at -3.7 -1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param_side}.Cu ${p.param_side}.Paste ${p.param_side}.Mask)) + (pad "" smd rect (at 3.7 -1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask)) + (pad "" smd rect (at 3.7 1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask)) + (pad "" smd rect (at -3.7 1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask)) + (pad "" smd rect (at -3.7 -1.1 ${p.rot}) (size 0.9 0.9) (layers ${p.param.side}.Cu ${p.param.side}.Paste ${p.param.side}.Mask)) ) ` diff --git a/src/outlines.js b/src/outlines.js index e984539..204ab60 100644 --- a/src/outlines.js +++ b/src/outlines.js @@ -71,9 +71,6 @@ const layout = exports._layout = (config = {}, points = {}) => { a.detect_unexpected(params, `${export_name}`, expected.concat(['side', 'tags', 'glue', 'size', 'corner', 'bevel', 'bound'])) const side = a.in(params.side, `${export_name}.side`, ['left', 'right', 'middle', 'both', 'glue']) const tags = a.sane(params.tags || [], `${export_name}.tags`, 'array') - const default_glue_name = Object.keys(parsed_glue)[0] - const glue_def = parsed_glue[a.sane(params.glue || default_glue_name, `${export_name}.glue`, 'string')] - a.assert(glue_def, `Field "${export_name}.glue" does not name a valid glue!`) const size = a.wh(params.size, `${export_name}.size`) const corner = a.sane(params.corner || 0, `${export_name}.corner`, 'number') const bevel = a.sane(params.bevel || 0, `${export_name}.bevel`, 'number') @@ -135,6 +132,10 @@ const layout = exports._layout = (config = {}, points = {}) => { let glue = {models: {}} if (bound && ['middle', 'both', 'glue'].includes(side)) { + const default_glue_name = Object.keys(parsed_glue)[0] + const glue_def = parsed_glue[a.sane(params.glue || default_glue_name, `${export_name}.glue`, 'string')] + a.assert(glue_def, `Field "${export_name}.glue" does not name a valid glue!`) + const get_line = (anchor) => { if (a.type(anchor) == 'number') { return u.line([anchor, -1000], [anchor, 1000]) diff --git a/src/pcbs.js b/src/pcbs.js index 3383fb6..4fd8dda 100644 --- a/src/pcbs.js +++ b/src/pcbs.js @@ -145,7 +145,7 @@ const makerjs2kicad = exports._makerjs2kicad = (model, layer='Edge.Cuts') => { } const footprint_types = require('./footprints') -const footprint = exports._footprint = (config, name, points, net_indexer, point) => { +const footprint = exports._footprint = (config, name, points, point, net_indexer, component_indexer) => { if (config === false) return '' @@ -165,9 +165,10 @@ const footprint = exports._footprint = (config, name, points, net_indexer, point parsed_params.rot = anchor.r // connecting static nets + parsed_params.net = {} for (const net of (fp.static_nets || [])) { const index = net_indexer(net) - parsed_params['net_' + net] = `(net ${index} "${net}")` + parsed_params.net[net] = `(net ${index} "${net}")` } // connecting parametric nets @@ -180,10 +181,11 @@ const footprint = exports._footprint = (config, name, points, net_indexer, point a.sane(net, `${name}.nets.${net_ref} --> ${point.meta.name}.${indirect}`, 'string') } const index = net_indexer(net) - parsed_params['net_' + net_ref] = `(net ${index} "${net}")` + parsed_params.net[net_ref] = `(net ${index} "${net}")` } // connecting other, non-net parameters + parsed_params.param = {} for (const param of (Object.keys(fp.params || {}))) { let value = params[param] === undefined ? fp.params[param] : params[param] if (value === undefined) throw new Error(`Field "${name}.params.${param}" is missing!`) @@ -192,9 +194,12 @@ const footprint = exports._footprint = (config, name, points, net_indexer, point value = point.meta[indirect] if (value === undefined) throw new Error(`Field "${name}.params.${param} --> ${point.meta.name}.${indirect}" is missing!`) } - parsed_params['param_' + param] = value + parsed_params.param[param] = value } + // reference + parsed_params.ref = component_indexer(parsed_params.param.class || '_') + return fp.body(parsed_params) } @@ -224,20 +229,29 @@ exports.parse = (config, points, outlines) => { const index = Object.keys(nets).length return nets[net] = index } + // and a component indexer + const component_registry = {} + const component_indexer = _class => { + if (!component_registry[_class]) { + component_registry[_class] = 0 + } + component_registry[_class]++ + return `${_class}${component_registry[_class]}` + } const footprints = [] // key-level footprints for (const [p_name, point] of Object.entries(points)) { for (const [f_name, f] of Object.entries(point.meta.footprints || {})) { - footprints.push(footprint(f, `${p_name}.footprints.${f_name}`, points, net_indexer, point)) + footprints.push(footprint(f, `${p_name}.footprints.${f_name}`, points, point, net_indexer, component_indexer)) } } // global one-off footprints const global_footprints = a.sane(pcb_config.footprints || {}, `pcb.${pcb_name}.footprints`, 'object') for (const [gf_name, gf] of Object.entries(global_footprints)) { - footprints.push(footprint(gf, `pcb.${pcb_name}.footprints.${gf_name}`, points, net_indexer)) + footprints.push(footprint(gf, `pcb.${pcb_name}.footprints.${gf_name}`, points, undefined, net_indexer, component_indexer)) } // finalizing nets diff --git a/src/points.js b/src/points.js index 3c02199..14f2ffb 100644 --- a/src/points.js +++ b/src/points.js @@ -217,6 +217,7 @@ exports.parse = (config = {}) => { p.meta.mirrored = false const new_name = `mirror_${name}` mp.meta.name = new_name + mp.meta.colrow = `mirror_${mp.meta.colrow}` mirrored_points[new_name] = mp if (p.meta.asym == 'right') { p.meta.skip = true diff --git a/test/fixtures/absolem.yaml b/test/fixtures/absolem.yaml index d251b50..1a381e9 100644 --- a/test/fixtures/absolem.yaml +++ b/test/fixtures/absolem.yaml @@ -130,7 +130,6 @@ points: front: false text: '!row_mark' align: right - ring: rows: bottom: @@ -307,7 +306,6 @@ points: front: false text: '!row_mark' align: right - home: spread: 21.25 rotate: -28 @@ -315,11 +313,14 @@ points: rows: thumb: bind: [,10,,15] - key: - column_net: P3 - tags: - classic: true - uniform: true + column_net: P3 + tags: + classic: true + uniform: true + footprints: + diode: + anchor: + shift: [8,] far: rows: thumb: @@ -334,6 +335,12 @@ points: diode: anchor: shift: [-4,] + rotate: 0 + mirror: + footprints: + diode: + anchor: + rotate: 180 rows: thumb: row_net: P10