Update the diode to be optionally reversible

This commit is contained in:
Marco Massarelli 2023-08-14 17:09:15 -04:00
parent 5edc43cf97
commit 3f25b4b531
1 changed files with 49 additions and 37 deletions

View File

@ -4,56 +4,68 @@
// - Added option to hide thru-holes // - Added option to hide thru-holes
// - Added virtual attribute to silence DRC error // - Added virtual attribute to silence DRC error
module.exports = { module.exports = {
params: { params: {
designator: 'D', designator: 'D',
include_tht: true, include_tht: true,
reversible: false,
side: 'B',
from: undefined, from: undefined,
to: undefined to: undefined
}, },
body: p => { body: p => {
const standard_opening = `
(module ComboDiode (layer ${p.side}.Cu) (tedit 5B24D78E)
${p.at /* parametric position */}
(fp_text reference "${p.ref}" (at 0 0) (layer ${p.side}.SilkS) ${p.ref_hide} (effects (font (size 1.27 1.27) (thickness 0.15))))
`
const front = `
(fp_line (start 0.25 0) (end 0.75 0) (layer F.SilkS) (width 0.1))
(fp_line (start 0.25 0.4) (end -0.35 0) (layer F.SilkS) (width 0.1))
(fp_line (start 0.25 -0.4) (end 0.25 0.4) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end 0.25 -0.4) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 0.55) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 -0.55) (layer F.SilkS) (width 0.1))
(fp_line (start -0.75 0) (end -0.35 0) (layer F.SilkS) (width 0.1))
(pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.to.str})
(pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.from.str})
`
const back = `
(fp_line (start 0.25 0) (end 0.75 0) (layer B.SilkS) (width 0.1))
(fp_line (start 0.25 0.4) (end -0.35 0) (layer B.SilkS) (width 0.1))
(fp_line (start 0.25 -0.4) (end 0.25 0.4) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end 0.25 -0.4) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 0.55) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 -0.55) (layer B.SilkS) (width 0.1))
(fp_line (start -0.75 0) (end -0.35 0) (layer B.SilkS) (width 0.1))
(pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.from.str})
(pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.to.str})
`
const tht = ` const tht = `
(pad 1 thru_hole rect (at -3.81 0 ${p.rot}) (size 1.778 1.778) (drill 0.9906) (layers *.Cu *.Mask) ${p.to.str}) (pad 1 thru_hole rect (at -3.81 0 ${p.rot}) (size 1.778 1.778) (drill 0.9906) (layers *.Cu *.Mask) ${p.to.str})
(pad 2 thru_hole circle (at 3.81 0 ${p.rot}) (size 1.905 1.905) (drill 0.9906) (layers *.Cu *.Mask) ${p.from.str}) (pad 2 thru_hole circle (at 3.81 0 ${p.rot}) (size 1.905 1.905) (drill 0.9906) (layers *.Cu *.Mask) ${p.from.str})
`; `
const standard_closing = `
)
`
const footprint = ` let final = standard_opening;
(module ComboDiode (layer F.Cu) (tedit 5B24D78E)
${p.at /* parametric position */}
(attr virtual)
${'' /* footprint reference */} if(p.side == "F" || p.reversible) {
(fp_text reference "${p.ref}" (at 0 0) (layer F.SilkS) ${p.ref_hide} (effects (font (size 1.27 1.27) (thickness 0.15)))) final += front;
(fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) }
if(p.side == "B" || p.reversible) {
final += back;
}
if(p.include_tht) {
final += tht;
}
${''/* diode symbols */} final += standard_closing;
(fp_line (start 0.25 0) (end 0.75 0) (layer F.SilkS) (width 0.1))
(fp_line (start 0.25 0.4) (end -0.35 0) (layer F.SilkS) (width 0.1))
(fp_line (start 0.25 -0.4) (end 0.25 0.4) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end 0.25 -0.4) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 0.55) (layer F.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 -0.55) (layer F.SilkS) (width 0.1))
(fp_line (start -0.75 0) (end -0.35 0) (layer F.SilkS) (width 0.1))
(fp_line (start 0.25 0) (end 0.75 0) (layer B.SilkS) (width 0.1))
(fp_line (start 0.25 0.4) (end -0.35 0) (layer B.SilkS) (width 0.1))
(fp_line (start 0.25 -0.4) (end 0.25 0.4) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end 0.25 -0.4) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 0.55) (layer B.SilkS) (width 0.1))
(fp_line (start -0.35 0) (end -0.35 -0.55) (layer B.SilkS) (width 0.1))
(fp_line (start -0.75 0) (end -0.35 0) (layer B.SilkS) (width 0.1))
${''/* SMD pads on both sides */} return final;
(pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.to.str})
(pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.from.str})
(pad 1 smd rect (at -1.65 0 ${p.rot}) (size 0.9 1.2) (layers B.Cu B.Paste B.Mask) ${p.to.str})
(pad 2 smd rect (at 1.65 0 ${p.rot}) (size 0.9 1.2) (layers F.Cu F.Paste F.Mask) ${p.from.str})
${''/* THT terminals */}
${ p.include_tht ? tht : '' }
)
`
return footprint;
} }
} }