-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpoint_debugger.js
81 lines (74 loc) · 2.54 KB
/
point_debugger.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
// Author: @infused-kim
//
// Description:
// Adds tiny x and y arrows at the origin of points to help with the debugging
// of complex layouts.
//
// This will only show arrows for actual points you define. So if you draw an
// outline without defining points, then they won't show up.
//
// Usage:
// You can make enabling and disabling easy with ergogen's preprocessor:
//
// ```js
// settings:
// point_debugger:
// enabled: false
// [...]
// pcbs:
// your_keyboard:
// footprints:
// point_debugger:
// what: infused-kim/point_debugger
// where: true
// params:
// $extends: settings.point_debugger
// ```
//
// Showing the point name:
// The footprint supports showing the name of the point when you zoom in, but
// the latest version of ergogen (4.0.4) does not make the name available to
// the footprint.
//
// Until this gets merged, you can use the ergogen fork from this PR:
// https://github.com/ergogen/ergogen/pull/103
module.exports = {
params: {
designator: 'P',
enabled: true,
},
body: p => {
if(p.enabled == false) {
return '';
}
const top = `
(module point_debugger (layer F.Cu) (tedit 64B42FA5)
${p.at /* parametric position */}
(fp_text reference ${p.ref}"(at 0 2) (layer F.SilkS) ${p.ref_hide}
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -0.6 0) (end 0.6 0) (layer Dwgs.User) (width 0.05))
(fp_line (start 0 -0.6) (end 0 0.6) (layer Dwgs.User) (width 0.05))
(fp_line (start 0.6 0) (end 0.5 -0.1) (layer Dwgs.User) (width 0.05))
(fp_line (start 0.6 0) (end 0.5 0.1) (layer Dwgs.User) (width 0.05))
(fp_line (start 0 -0.6) (end 0.1 -0.5) (layer Dwgs.User) (width 0.05))
(fp_line (start 0 -0.6) (end -0.1 -0.5) (layer Dwgs.User) (width 0.05))
`
const bottom = `
)
`
let final = top;
// point is a property that is not available to footprints as of
// ergogen 4.0.4. I have submitted a PR to add it and until then
// my custom fork needs to be used if you want to see it.
if('point' in p) {
final += `
(fp_text user ${p.point.meta.name} (at -0.3 -0.05 ${p.rot}) (layer Dwgs.User)
(effects (font (size 0.0254 0.0254) (thickness 0.001)))
)
`;
}
final += bottom;
return final;
}
}