// Modified version of rgb.js
// Source for KiCad footprint: https://github.com/keebio/Keebio-Parts.pretty/blob/master/SK6812-MINI-E.kicad_mod

module.exports = {
    params: {
        designator: 'LED',
        side: 'F',
        din: undefined,
        dout: undefined,
        VCC: {type: 'net', value: 'VCC'},
        GND: {type: 'net', value: 'GND'}
    },
    body: p => `
        (module SK6812-MINI-E (layer F.Cu) (tedit 53BEE615)
            ${p.at /* parametric position */}
            (attr smd)

            ${'' /* footprint reference */}
            (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)))
            )
            (fp_text value "" (at 0 0) (layer ${p.side}.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15))))

            (fp_poly (pts (xy 2.8 1.4) (xy 2.2 1.4) (xy 2.2 2)) (layer ${p.side}.SilkS) (width 0.1))
            (fp_line (start 1.6 -1.4) (end 1.6 1.4) (layer Cmts.User) (width 0.12))
            (fp_line (start 1.6 1.4) (end -1.6 1.4) (layer Cmts.User) (width 0.12))
            (fp_line (start -1.6 1.4) (end -1.6 -1.4) (layer Cmts.User) (width 0.12))
            (fp_line (start -1.6 -1.4) (end 1.6 -1.4) (layer Cmts.User) (width 0.12))
            (fp_line (start 1.7 -1.5) (end 1.7 1.5) (layer Edge.Cuts) (width 0.12))
            (fp_line (start 1.7 1.5) (end -1.7 1.5) (layer Edge.Cuts) (width 0.12))
            (fp_line (start -1.7 1.5) (end -1.7 -1.5) (layer Edge.Cuts) (width 0.12))
            (fp_line (start -1.7 -1.5) (end 1.7 -1.5) (layer Edge.Cuts) (width 0.12))

            (pad "1" smd rect (at -2.6 -0.75 ${p.r}) (size 1.6 0.82)
                (layers "${p.side}.Cu" "${p.side}.Paste" "${p.side}.Mask")
                ${p.VCC}
            )
            (pad "2" smd rect (at -2.6 0.75 ${p.r}) (size 1.6 0.82)
                (layers "${p.side}.Cu" "${p.side}.Paste" "${p.side}.Mask")
                ${p.dout}
            )
            (pad "4" smd rect (at 2.6 -0.75 ${p.r}) (size 1.6 0.82)
                (layers "${p.side}.Cu" "${p.side}.Paste" "${p.side}.Mask")
                ${p.din}
            )
            (pad "3" smd roundrect (at 2.6 0.75 ${p.r}) (size 1.6 0.82)
                (layers "${p.side}.Cu" "${p.side}.Paste" "${p.side}.Mask")
                (roundrect_rratio 0.25)
                ${p.GND}
            )
        )
    `
}
