-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmounting_hole_plated.js
102 lines (93 loc) · 3.69 KB
/
mounting_hole_plated.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) 2023 Marco Massarelli
//
// SPDX-License-Identifier: CC-BY-NC-SA-4.0
//
// To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
//
// Author: @infused-kim + @ceoloide improvements
//
// Description:
// A simple mounting hole with plated rim.
//
// Note that some fine details may be lost depending on scale and fab capabilities.
//
// Params:
// side: default is F for Front
// The side on which to place the mounting hole.
// outline: default is 0.8 (mm)
// The width of the gold rim around the hole, in mm.
// drill: default is 2.2 (mm / M2 screw)
// The actual size for the hole. If drill_y is defined, it represents the
// horizontal width of an oval hole, in mm.
// drill_y: default is 0 (mm)
// The vertical height of an oval hole, in mm.
// include_courtyard: default is true
// if true it will include the part courtyard
//
// @ceoloide's improvements:
// - Upgrade to KiCad 8
// - Minor footprint restructure
module.exports = {
params: {
designator: 'H',
side: 'F',
outline: 0.8,
drill: 2.2,
drill_y: 0,
include_courtyard: true,
},
body: p => {
if (p.drill_y == 0) {
p.drill_y = p.drill
}
const size_x = p.drill + p.outline * 2;
const size_y = p.drill_y + p.outline * 2;
const courtyard_offset = 0.25;
const courtyard_x = size_x / 2 + courtyard_offset;
const courtyard_y = size_y / 2 + courtyard_offset;
const top = `
(footprint "ceoloide:mounting_hole_plated"
(layer "${p.side}.Cu")
${p.at}
(property "Reference" "${p.ref}"
(at 0 3 ${p.r})
(layer "${p.side}.SilkS")
${p.ref_hide}
(effects (font (size 1 1) (thickness 0.15)))
)
`
const pad_circle = `
(pad "" thru_hole circle (at 0 0 ${p.r}) (size ${size_x} ${size_y}) (drill ${p.drill}) (layers "*.Cu" "*.Mask"))
`
const courtyard_circle = `
(fp_circle (center 0 0) (end -${courtyard_x} 0) (layer "F.CrtYd") (stroke (width 0.05) (type solid)) (fill none))
(fp_circle (center 0 0) (end -${courtyard_x} 0) (layer "B.CrtYd") (stroke (width 0.05) (type solid)) (fill none))
`
const pad_oval = `
(pad "" thru_hole oval (at 0 0 ${p.r}) (size ${size_x} ${size_y}) (drill oval ${p.drill} ${p.drill_y}) (layers "*.Cu" "*.Mask"))
`
const courtyard_oval = `
(fp_line (start ${courtyard_x} -${courtyard_y}) (end ${courtyard_x} ${courtyard_y}) (layer "F.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} -${courtyard_y}) (end -${courtyard_x} ${courtyard_y}) (layer "F.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} ${courtyard_y}) (end ${courtyard_x} ${courtyard_y}) (layer "F.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} -${courtyard_y}) (end ${courtyard_x} -${courtyard_y}) (layer "F.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} ${courtyard_y}) (end ${courtyard_x} ${courtyard_y}) (layer "B.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} ${courtyard_y}) (end -${courtyard_x} -${courtyard_y}) (layer "B.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start -${courtyard_x} -${courtyard_y}) (end ${courtyard_x} -${courtyard_y}) (layer "B.CrtYd") (stroke (width 0.05) (type solid)))
(fp_line (start ${courtyard_x} ${courtyard_y}) (end ${courtyard_x} -${courtyard_y}) (layer "B.CrtYd") (stroke (width 0.05) (type solid)))
`
const bottom = `
)
`
let final = top
if (size_x == size_y) {
final += pad_circle
final += courtyard_circle
} else {
final += pad_oval
final += courtyard_oval
}
final += bottom
return final
}
}