Add the option to flip the footprint

This commit is contained in:
Marco Massarelli 2023-06-14 14:06:00 +02:00
parent 374b23e751
commit 48925114c9
1 changed files with 71 additions and 47 deletions

View File

@ -2,15 +2,15 @@ module.exports = {
params: {
designator: 'LED',
P1: {type: 'net', value: 'VDD'},
P2: undefined, // {type: 'net', value: 'DOUT'},
P2: undefined,
P3: {type: 'net', value: 'GND'},
P4: undefined, //{type: 'net', value: 'DIN'},
P4: undefined,
reverse: false,
flip: false, // False = per-key, True = underglow
side: 'B',
},
body: p => {
const standard_opening = `
${'' /* Add parts that should be on both sides here (module def) */}
(module YS-SK6812MINI-E (layer F.Cu) (tedit 5F70BC98)
${p.at /* parametric position */}
@ -39,7 +39,6 @@ module.exports = {
(fp_line (start 2.94 -0.37) (end 2.94 -1.05) (layer Dwgs.User) (width 0.12))
`
const front = `
${'' /* Add the parts that should be on the front here */}
(fp_line (start -1.6 0.7) (end -0.8 1.4) (layer Dwgs.User) (width 0.12))
(fp_line (start -3.9 1.85) (end 3.9 1.85) (layer F.SilkS) (width 0.12))
(fp_line (start 3.9 -1.85) (end -3.9 -1.85) (layer F.SilkS) (width 0.12))
@ -49,8 +48,17 @@ module.exports = {
(pad 4 smd rect (at 2.65 -0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P4.str})
(pad 3 smd rect (at 2.65 0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P3.str})
`
const front_flipped = `
(fp_line (start 1.6 0.7) (end 0.8 1.4) (layer Dwgs.User) (width 0.12))
(fp_line (start 3.9 1.85) (end -3.9 1.85) (layer F.SilkS) (width 0.12))
(fp_line (start -3.9 -1.85) (end 3.9 -1.85) (layer F.SilkS) (width 0.12))
(fp_line (start 3.9 0.25) (end 3.9 1.85) (layer F.SilkS) (width 0.12))
(pad 4 smd rect (at -2.65 -0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P4.str})
(pad 3 smd rect (at -2.65 0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P3.str})
(pad 1 smd rect (at 2.65 -0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P1.str})
(pad 2 smd rect (at 2.65 0.7 ${p.rot}) (size 1.5 1) (layers F.Cu F.Paste F.Mask) ${p.P2.str})
`
const back = `
${'' /* Add the parts that should be on the back here */}
(fp_line (start -1.6 -0.7) (end -0.8 -1.4) (layer Dwgs.User) (width 0.12))
(fp_line (start 3.9 1.85) (end -3.9 1.85) (layer B.SilkS) (width 0.12))
(fp_line (start -3.9 -1.85) (end 3.9 -1.85) (layer B.SilkS) (width 0.12))
@ -60,9 +68,17 @@ module.exports = {
(pad 2 smd rect (at -2.65 -0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P2.str})
(pad 1 smd rect (at -2.65 0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P1.str})
`
const back_flipped = `
(fp_line (start 1.6 -0.7) (end 0.8 -1.4) (layer Dwgs.User) (width 0.12))
(fp_line (start -3.9 1.85) (end 3.9 1.85) (layer B.SilkS) (width 0.12))
(fp_line (start 3.9 -1.85) (end -3.9 -1.85) (layer B.SilkS) (width 0.12))
(fp_line (start 3.9 -0.25) (end 3.9 -1.85) (layer B.SilkS) (width 0.12))
(pad 2 smd rect (at 2.65 -0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P2.str})
(pad 1 smd rect (at 2.65 0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P1.str})
(pad 3 smd rect (at -2.65 -0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P3.str})
(pad 4 smd rect (at -2.65 0.7 ${p.rot}) (size 1.5 1) (layers B.Cu B.Paste B.Mask) ${p.P4.str})
`
const standard_closing = `
${'' /* Add parts that should be on both sides here (closing bracket) */}
(fp_line (start -1.8 -1.55) (end -1.8 1.55) (layer Edge.Cuts) (width 0.12))
(fp_line (start -1.8 1.55) (end 1.8 1.55) (layer Edge.Cuts) (width 0.12))
(fp_line (start 1.8 1.55) (end 1.8 -1.55) (layer Edge.Cuts) (width 0.12))
@ -73,11 +89,19 @@ module.exports = {
let final = standard_opening;
if(p.side == "F" || p.reverse) {
if(p.flip) {
final += front_flipped;
} else {
final += front;
}
}
if(p.side == "B" || p.reverse) {
if(p.flip) {
final += back_flipped;
} else {
final += back;
}
}
final += standard_closing;