-
Notifications
You must be signed in to change notification settings - Fork 6
/
conn_molex_pico_ezmate_1x02.js
221 lines (197 loc) · 9.67 KB
/
conn_molex_pico_ezmate_1x02.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Author: @infused-kim
//
// Description:
// PCB footprint for for molex pico ezmate connector with 2 pins. Ideal for
// battery connections.
//
// This connector was chosen over the more common JST connector, because it
// has a mated profile height of only 1.65 mm. This is lower than the Kailh
// Choc hotswap sockets.
//
// It should also be compatible with the JST ACH connector (which is almost the
// same).
//
// One downside is that there are almost no batteries that ship with this
// connector. The one exception is the Nintendo Joycon 500 mAh battery.
//
// If you want to use the common 301230 battery, you will either need to crimp
// the connector yourself or buy a pre-crimped connector that you attach to
// the battery wires (available on digikey).
module.exports = {
params: {
designator: 'CONN',
side: 'F',
reverse: false,
pad_1: {type: 'net', value: 'RAW'},
pad_2: {type: 'net', value: 'GND'},
cable_3dmodel_filename: '${EG_INFUSED_KIM_3D_MODELS}/Molex_Ezmate_Pico_Cable_2pin.step',
cable_3dmodel_side: '',
cable_3dmodel_xyz_scale: '',
cable_3dmodel_xyz_rotation: '',
cable_3dmodel_xyz_offset: '',
socket_3dmodel_filename: '${EG_INFUSED_KIM_3D_MODELS}/Molex_Ezmate_Pico_Socket_2pin.step',
socket_3dmodel_side: '',
socket_3dmodel_xyz_scale: '',
socket_3dmodel_xyz_rotation: '',
socket_3dmodel_xyz_offset: '',
},
body: p => {
const gen_3d_model = (filename, scale, rotation, offset, side, {
default_side = 'F',
scale_f = [1, 1, 1],
rotation_f = [0, 0, 0],
offset_f = [0, 0, 0],
scale_b = [1, 1, 1],
rotation_b = [0, 0, 0],
offset_b = [0, 0, 0]
} = {}) => {
if(filename == '') {
return '';
}
const get_3d_model_side = (side, default_side) => {
if(side == '') {
if(p.reverse == true) {
side = default_side;
} else {
side = p.side;
}
}
if(side == 'F' || side == 'B') {
return side;
} else {
return default_side;
}
}
const final_side = get_3d_model_side(side, default_side, p);
const is_front = final_side === 'F';
// Determine the actual values to use
const final_scale = scale || (is_front ? scale_f : scale_b);
const final_rotation = rotation || (is_front ? rotation_f : rotation_b);
let final_offset = offset || (is_front ? offset_f : offset_b);
// Fix bug that seems to happen during the upgrade from KiCad 5 to
// 8. All offset values seem to be multiplied by 25.4. So here we
// divide them so that the upgrade KiCad file ends up with the
// correct value.
const offset_divisor = 25.4;
final_offset = final_offset.map(value => value / offset_divisor);
return `
(model ${filename}
(at (xyz ${final_offset[0]} ${final_offset[1]} ${final_offset[2]}))
(scale (xyz ${final_scale[0]} ${final_scale[1]} ${final_scale[2]}))
(rotate (xyz ${final_rotation[0]} ${final_rotation[1]} ${final_rotation[2]}))
)
`;
};
const top = `
(module conn_molex_pico_ezmate_1x02 (layer F.Cu) (tedit 6445F610)
${p.at /* parametric position */}
(attr smd)
`;
const front = `
(fp_text reference ${p.ref} (at 0.1 3.9 ${p.rot}) (layer F.SilkS) ${p.ref_hide}
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 0.64 2.63) (end 1.14 2.63) (layer F.SilkS) (width 0.12))
(fp_line (start 0.34 2.13) (end 0.64 2.63) (layer F.SilkS) (width 0.12))
(fp_line (start -0.34 2.13) (end 0.34 2.13) (layer F.SilkS) (width 0.12))
(fp_line (start -0.64 2.63) (end -0.34 2.13) (layer F.SilkS) (width 0.12))
(fp_line (start -0.45 2.02) (end 0.45 2.02) (layer F.Fab) (width 0.1))
(fp_line (start -0.75 2.52) (end -0.45 2.02) (layer F.Fab) (width 0.1))
(fp_line (start -2.1 2.52) (end -0.75 2.52) (layer F.Fab) (width 0.1))
(fp_line (start -1.16 -2.09) (end -1.16 -2.3) (layer F.SilkS) (width 0.12))
(fp_line (start -2.21 -2.09) (end -1.16 -2.09) (layer F.SilkS) (width 0.12))
(fp_line (start -2.21 1.24) (end -2.21 -2.09) (layer F.SilkS) (width 0.12))
(fp_line (start -2.1 -1.98) (end 2.1 -1.98) (layer F.Fab) (width 0.1))
(fp_line (start -1.14 2.63) (end -0.64 2.63) (layer F.SilkS) (width 0.12))
(fp_line (start 2.21 -2.09) (end 1.16 -2.09) (layer F.SilkS) (width 0.12))
(fp_line (start 2.21 1.24) (end 2.21 -2.09) (layer F.SilkS) (width 0.12))
(fp_line (start -0.6 -1.272893) (end -0.1 -1.98) (layer F.Fab) (width 0.1))
(fp_line (start -1.1 -1.98) (end -0.6 -1.272893) (layer F.Fab) (width 0.1))
(fp_line (start 2.6 -2.8) (end -2.6 -2.8) (layer F.CrtYd) (width 0.05))
(fp_line (start -2.6 -2.8) (end -2.6 3.02) (layer F.CrtYd) (width 0.05))
(fp_line (start 2.1 -1.98) (end 2.1 2.52) (layer F.Fab) (width 0.1))
(fp_line (start -2.1 -1.98) (end -2.1 2.52) (layer F.Fab) (width 0.1))
(fp_line (start 0.75 2.52) (end 2.1 2.52) (layer F.Fab) (width 0.1))
(fp_line (start 0.45 2.02) (end 0.75 2.52) (layer F.Fab) (width 0.1))
(fp_line (start 2.6 3.02) (end 2.6 -2.8) (layer F.CrtYd) (width 0.05))
(fp_line (start -2.6 3.02) (end 2.6 3.02) (layer F.CrtYd) (width 0.05))
(pad MP smd roundrect (at 1.75 1.9 ${p.rot}) (size 0.7 0.8) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
(pad MP smd roundrect (at -1.75 1.9 ${p.rot}) (size 0.7 0.8) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
(pad 2 smd roundrect (at 0.6 -1.875 ${p.rot}) (size 0.6 0.85) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25) ${p.pad_2.str})
(pad 1 smd roundrect (at -0.6 -1.875 ${p.rot}) (size 0.6 0.85) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25) ${p.pad_1.str})
`
const back = `
(fp_line (start -0.34 2.13) (end -0.64 2.63) (layer B.SilkS) (width 0.12))
(fp_line (start -2.6 3.02) (end -2.6 -2.8) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.6 3.02) (end -2.6 3.02) (layer B.CrtYd) (width 0.05))
(fp_line (start -0.64 2.63) (end -1.14 2.63) (layer B.SilkS) (width 0.12))
(fp_line (start 1.16 -2.09) (end 1.16 -2.3) (layer B.SilkS) (width 0.12))
(fp_line (start 2.21 -2.09) (end 1.16 -2.09) (layer B.SilkS) (width 0.12))
(fp_line (start 2.21 1.24) (end 2.21 -2.09) (layer B.SilkS) (width 0.12))
(fp_line (start 2.1 -1.98) (end -2.1 -1.98) (layer B.Fab) (width 0.1))
(fp_line (start 1.14 2.63) (end 0.64 2.63) (layer B.SilkS) (width 0.12))
(fp_line (start -2.21 -2.09) (end -1.16 -2.09) (layer B.SilkS) (width 0.12))
(fp_line (start -2.21 1.24) (end -2.21 -2.09) (layer B.SilkS) (width 0.12))
(fp_line (start 0.6 -1.272893) (end 0.1 -1.98) (layer B.Fab) (width 0.1))
(fp_line (start 1.1 -1.98) (end 0.6 -1.272893) (layer B.Fab) (width 0.1))
(fp_line (start -2.6 -2.8) (end 2.6 -2.8) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.6 -2.8) (end 2.6 3.02) (layer B.CrtYd) (width 0.05))
(fp_line (start -2.1 -1.98) (end -2.1 2.52) (layer B.Fab) (width 0.1))
(fp_line (start 2.1 -1.98) (end 2.1 2.52) (layer B.Fab) (width 0.1))
(fp_line (start -0.75 2.52) (end -2.1 2.52) (layer B.Fab) (width 0.1))
(fp_line (start -0.45 2.02) (end -0.75 2.52) (layer B.Fab) (width 0.1))
(fp_line (start 0.64 2.63) (end 0.34 2.13) (layer B.SilkS) (width 0.12))
(fp_line (start 0.45 2.02) (end -0.45 2.02) (layer B.Fab) (width 0.1))
(fp_line (start 0.75 2.52) (end 0.45 2.02) (layer B.Fab) (width 0.1))
(fp_line (start 2.1 2.52) (end 0.75 2.52) (layer B.Fab) (width 0.1))
(fp_line (start 0.34 2.13) (end -0.34 2.13) (layer B.SilkS) (width 0.12))
(pad MP smd roundrect (at 1.75 1.9 ${180 + p.rot}) (size 0.7 0.8) (layers B.Cu B.Paste B.Mask) (roundrect_rratio 0.25))
(pad 2 smd roundrect (at -0.6 -1.875 ${180 + p.rot}) (size 0.6 0.85) (layers B.Cu B.Paste B.Mask) (roundrect_rratio 0.25) ${p.pad_2.str})
(pad 1 smd roundrect (at 0.6 -1.875 ${180 + p.rot}) (size 0.6 0.85) (layers B.Cu B.Paste B.Mask) (roundrect_rratio 0.25) ${p.pad_1.str})
(pad MP smd roundrect (at -1.75 1.9 ${180 + p.rot}) (size 0.7 0.8) (layers B.Cu B.Paste B.Mask) (roundrect_rratio 0.25))
`
const all_3d_models = `
${ gen_3d_model(
p.cable_3dmodel_filename,
p.cable_3dmodel_xyz_scale,
p.cable_3dmodel_xyz_rotation,
p.cable_3dmodel_xyz_offset,
p.cable_3dmodel_side,
{
rotation_f: [0, 0, 0],
offset_f: [0, 0, 0.8],
rotation_b: [0, 180, 0],
offset_b: [0, 0, -(1.6 + 0.8)],
},
)
}
${ gen_3d_model(
p.socket_3dmodel_filename,
p.socket_3dmodel_xyz_scale,
p.socket_3dmodel_xyz_rotation,
p.socket_3dmodel_xyz_offset,
p.socket_3dmodel_side,
{
rotation_f: [-90, 0, 0],
offset_f: [0, 0, 1.4],
rotation_b: [-90, 180, 0],
offset_b: [0, 0, -3],
},
)
}
`
const bottom = `
)
`
let final = top;
if(p.side == "F" || p.reverse) {
final += front;
}
if(p.side == "B" || p.reverse) {
final += back;
}
final += all_3d_models;
final += bottom;
return final;
}
}