-
Notifications
You must be signed in to change notification settings - Fork 6
/
trackpoint_mount.js
342 lines (298 loc) · 13.5 KB
/
trackpoint_mount.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
// Author: @infused-kim
//
// Description:
// Adds mounting holes for a trackpoint to the PCB.
//
// Should be compatible with:
// - Thinkpad T430
// - Thinkpad T440 / X240
//
// Check this page for other models:
// https://deskthority.net/wiki/TrackPoint_Hardware
module.exports = {
params: {
designator: 'TP',
side: 'B',
reverse: false,
// T430: 3.5
// T460S (red one): 3.5
// X240: 5.5
drill: 5.5,
outline: 0.25,
show_outline_t430: false,
show_outline_x240: false,
show_outline_t460s: false,
show_board: false,
// This side parameter applies to all 3d models
tp_3dmodel_side: '',
tp_cap_3dmodel_filename: '${EG_INFUSED_KIM_3D_MODELS}/trackpoint/TP_Cap_Red_T460S.step',
tp_cap_3dmodel_xyz_scale: '',
tp_cap_3dmodel_xyz_rotation: '',
tp_cap_3dmodel_xyz_offset: '',
tp_extension_3dmodel_filename: '${EG_INFUSED_KIM_3D_MODELS}/trackpoint/TP_Extension_Red_T460S_h10.5_md0.0_pcb1.6.step',
tp_extension_3dmodel_xyz_scale: '',
tp_extension_3dmodel_xyz_rotation: '',
tp_extension_3dmodel_xyz_offset: '',
tp_3dmodel_filename: '${EG_INFUSED_KIM_3D_MODELS}/trackpoint/TP_Red_T460S_platform_z_offset_+0.0_pcb_offset_-2.0.step',
tp_3dmodel_xyz_scale: '',
tp_3dmodel_xyz_rotation: '',
tp_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 trackpoint_mount_t430 (layer F.Cu) (tedit 6449FFC5)
${p.at /* parametric position */}
(attr virtual)
(fp_text reference "${p.ref}" (at 0 0) (layer ${p.side}.SilkS) ${p.ref_hide}
(effects (font (size 1 1) (thickness 0.15)))
)
`;
const front = `
(fp_circle (center 0 -9.75) (end -2.15 -9.75) (layer F.CrtYd) (width 0.05))
(fp_circle (center 0 -9.75) (end -1.9 -9.75) (layer Cmts.User) (width 0.15))
(fp_circle (center 0 9.75) (end -2.15 9.75) (layer F.CrtYd) (width 0.05))
(fp_circle (center 0 9.75) (end -1.9 9.75) (layer Cmts.User) (width 0.15))
(fp_circle (center 0 0) (end -3.95 0) (layer F.CrtYd) (width 0.05))
(fp_circle (center 0 0) (end -3.7 0) (layer Cmts.User) (width 0.15))
(fp_text user %R (at 0 0 180) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
`
const back = `
(fp_circle (center 0 0) (end -3.95 0) (layer B.CrtYd) (width 0.05))
(fp_circle (center 0 0) (end -3.7 0) (layer Cmts.User) (width 0.15))
(fp_circle (center 0 9.75) (end -2.15 9.75) (layer B.CrtYd) (width 0.05))
(fp_circle (center 0 -9.75) (end -2.15 -9.75) (layer B.CrtYd) (width 0.05))
`
const outline_t430_front = `
(fp_line (start -4.5 -12.75) (end -9.5 -7.25) (layer F.Fab) (width 0.2))
(fp_line (start -9.5 7.25) (end -4.5 12.75) (layer F.Fab) (width 0.2))
(fp_line (start 6.5 8) (end 6.5 -8) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 -8) (end 9.5 -12.75) (layer F.Fab) (width 0.2))
(fp_line (start -9.5 7.25) (end -9.5 -7.25) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 -12.75) (end -4.5 -12.75) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 12.75) (end -4.5 12.75) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 -8) (end 6.5 -8) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 8) (end 9.5 12.75) (layer F.Fab) (width 0.2))
(fp_line (start 9.5 8) (end 6.5 8) (layer F.Fab) (width 0.2))
(fp_line (start 8.5 5.5) (end 8.5 -5.5) (layer F.Fab) (width 0.2))
(fp_line (start 8.5 -5.5) (end 6.5 -5.5) (layer F.Fab) (width 0.2))
(fp_line (start 8.5 5.5) (end 6.5 5.5) (layer F.Fab) (width 0.2))
`
const outline_t430_back = `
(fp_line (start -4.5 12.75) (end -9.5 7.25) (layer B.Fab) (width 0.2))
(fp_line (start 9.5 -8) (end 9.5 -12.75) (layer B.Fab) (width 0.12))
(fp_line (start 9.5 8) (end 9.5 12.75) (layer B.Fab) (width 0.2))
(fp_line (start 6.5 -8) (end 6.5 8) (layer B.Fab) (width 0.2))
(fp_line (start 9.5 -12.75) (end -4.5 -12.75) (layer B.Fab) (width 0.2))
(fp_line (start -9.5 -7.25) (end -4.5 -12.75) (layer B.Fab) (width 0.2))
(fp_line (start 9.5 -8) (end 6.5 -8) (layer B.Fab) (width 0.12))
(fp_line (start 9.5 8) (end 6.5 8) (layer B.Fab) (width 0.2))
(fp_line (start -9.5 -7.25) (end -9.5 7.25) (layer B.Fab) (width 0.2))
(fp_line (start 9.5 12.75) (end -4.5 12.75) (layer B.Fab) (width 0.2))
(fp_line (start 8.5 -5.5) (end 8.5 5.5) (layer B.Fab) (width 0.2))
(fp_line (start 8.5 -5.5) (end 6.5 -5.5) (layer B.Fab) (width 0.2))
(fp_line (start 8.5 5.5) (end 6.5 5.5) (layer B.Fab) (width 0.2))
`
const outline_x240_front = `
(fp_line (start 12.25 -6.5) (end 6.75 -6.5) (layer F.Fab) (width 0.2))
(fp_line (start 12.25 6.5) (end 6.75 6.5) (layer F.Fab) (width 0.2))
(fp_line (start 12.25 6.5) (end 12.25 -6.5) (layer F.Fab) (width 0.2))
(fp_line (start 6.75 11.5) (end -6.75 11.5) (layer F.Fab) (width 0.2))
(fp_line (start 6.75 -11.5) (end -6.75 -11.5) (layer F.Fab) (width 0.2))
(fp_line (start -6.75 11.5) (end -6.75 -11.5) (layer F.Fab) (width 0.2))
(fp_line (start 6.75 11.5) (end 6.75 -11.5) (layer F.Fab) (width 0.2))
`
const outline_x240_back = `
(fp_line (start 12.25 -6.5) (end 6.75 -6.5) (layer B.Fab) (width 0.2))
(fp_line (start 12.25 -6.5) (end 12.25 6.5) (layer B.Fab) (width 0.2))
(fp_line (start 6.75 -11.5) (end -6.75 -11.5) (layer B.Fab) (width 0.2))
(fp_line (start 6.75 11.5) (end -6.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start -6.75 -11.5) (end -6.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start 6.75 -11.5) (end 6.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start 12.25 6.5) (end 6.75 6.5) (layer B.Fab) (width 0.2))
`
const outline_x240_board = `
(fp_line (start 39.25 12) (end 23.25 12) (layer Dwgs.User) (width 0.2))
(fp_line (start 23.25 5.5) (end 23.25 12) (layer Dwgs.User) (width 0.2))
(fp_line (start 23.25 -5.5) (end 23.25 5.5) (layer Dwgs.User) (width 0.2))
(fp_line (start 23.25 5.5) (end 12.25 5.5) (layer Dwgs.User) (width 0.2))
(fp_line (start 23.25 -5.5) (end 12.25 -5.5) (layer Dwgs.User) (width 0.2))
(fp_line (start 39.25 -22) (end 39.25 12) (layer Dwgs.User) (width 0.2))
(fp_line (start 39.25 -22) (end 23.25 -22) (layer Dwgs.User) (width 0.2))
(fp_line (start 23.25 -22) (end 23.25 -5.5) (layer Dwgs.User) (width 0.2))
(fp_line (start 12.25 -5.5) (end 12.25 5.5) (layer Dwgs.User) (width 0.2))
`
const outline_t460s_front = `
(fp_line (start 2.75 6.5) (end 6.25 3) (layer F.Fab) (width 0.2))
(fp_line (start 2.75 11.5) (end -2.75 11.5) (layer F.Fab) (width 0.2))
(fp_line (start -6.25 3) (end -6.25 -3) (layer F.Fab) (width 0.2))
(fp_line (start 6.25 3) (end 6.25 -3) (layer F.Fab) (width 0.2))
(fp_line (start 2.75 -11.5) (end -2.75 -11.5) (layer F.Fab) (width 0.2))
(fp_line (start 2.75 6.5) (end 2.75 11.5) (layer F.Fab) (width 0.2))
(fp_line (start -2.75 6.5) (end -2.75 11.5) (layer F.Fab) (width 0.2))
(fp_line (start -2.75 -11.5) (end -2.75 -6.5) (layer F.Fab) (width 0.2))
(fp_line (start 2.75 -11.5) (end 2.75 -6.5) (layer F.Fab) (width 0.2))
(fp_line (start -2.75 6.5) (end -6.25 3) (layer F.Fab) (width 0.2))
(fp_line (start 6.25 -3) (end 2.75 -6.5) (layer F.Fab) (width 0.2))
(fp_line (start -6.25 -3) (end -2.75 -6.5) (layer F.Fab) (width 0.2))
`
const outline_t460s_back = `
(fp_line (start -6.25 -3) (end -2.75 -6.5) (layer B.Fab) (width 0.2))
(fp_line (start 6.25 -3) (end 2.75 -6.5) (layer B.Fab) (width 0.2))
(fp_line (start 2.75 6.5) (end 6.25 3) (layer B.Fab) (width 0.2))
(fp_line (start -2.75 6.5) (end -6.25 3) (layer B.Fab) (width 0.2))
(fp_line (start 6.25 3) (end 6.25 -3) (layer B.Fab) (width 0.2))
(fp_line (start 2.75 11.5) (end -2.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start -6.25 3) (end -6.25 -3) (layer B.Fab) (width 0.2))
(fp_line (start 2.75 -11.5) (end -2.75 -11.5) (layer B.Fab) (width 0.2))
(fp_line (start -2.75 6.5) (end -2.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start 2.75 6.5) (end 2.75 11.5) (layer B.Fab) (width 0.2))
(fp_line (start -2.75 -11.5) (end -2.75 -6.5) (layer B.Fab) (width 0.2))
(fp_line (start 2.75 -11.5) (end 2.75 -6.5) (layer B.Fab) (width 0.2))
`
const outline_t460s_board = `
(fp_line (start 38.25 12.25) (end 22.25 12.25) (layer Dwgs.User) (width 0.2))
(fp_line (start 22.25 2.75) (end 22.25 12.25) (layer Dwgs.User) (width 0.2))
(fp_line (start 22.25 -2.75) (end 22.25 2.75) (layer Dwgs.User) (width 0.2))
(fp_line (start 22.25 2.75) (end 6.25 2.75) (layer Dwgs.User) (width 0.2))
(fp_line (start 22.25 -2.75) (end 6.25 -2.75) (layer Dwgs.User) (width 0.2))
(fp_line (start 38.25 -22.25) (end 38.25 12.25) (layer Dwgs.User) (width 0.2))
(fp_line (start 38.25 -22.25) (end 22.25 -22.25) (layer Dwgs.User) (width 0.2))
(fp_line (start 22.25 -22.25) (end 22.25 -2.75) (layer Dwgs.User) (width 0.2))
(fp_line (start 6.25 -2.75) (end 6.25 2.75) (layer Dwgs.User) (width 0.2))
`
const size = p.drill + (p.outline * 2)
const bottom = `
(pad "" thru_hole circle (at 0 -9.75 180) (size 3.8 3.8) (drill 2.2) (layers *.Cu *.Mask))
(pad 1 np_thru_hole circle (at 0 0 180) (size ${size} ${size}) (drill ${p.drill}) (layers *.Cu *.Mask))
(pad "" thru_hole circle (at 0 9.75 180) (size 3.8 3.8) (drill 2.2) (layers *.Cu *.Mask))
)
`
let final = top;
if(p.side == "F" || p.reverse) {
final += front;
if(p.show_outline_t430) {
final += outline_t430_front;
}
if(p.show_outline_x240) {
final += outline_x240_front;
}
if(p.show_outline_t460s) {
final += outline_t460s_front;
}
}
if(p.side == "B" || p.reverse) {
final += back;
if(p.show_outline_t430) {
final += outline_t430_back;
}
if(p.show_outline_x240) {
final += outline_x240_back;
}
if(p.show_outline_t460s) {
final += outline_t460s_back;
}
}
if(p.show_board) {
if(p.show_outline_x240) {
final += outline_x240_board
}
if(p.show_outline_t460s) {
final += outline_t460s_board
}
}
final += `
${ gen_3d_model(
p.tp_cap_3dmodel_filename,
p.tp_cap_3dmodel_xyz_scale,
p.tp_cap_3dmodel_xyz_rotation,
p.tp_cap_3dmodel_xyz_offset,
p.tp_3dmodel_side,
{
rotation_f: [0, 0, 0],
offset_f: [0, 0, 10.5],
rotation_b: [0, 180, 0],
offset_b: [0, 0, -(10.5+1.6)],
},
)
}
${ gen_3d_model(
p.tp_extension_3dmodel_filename,
p.tp_extension_3dmodel_xyz_scale,
p.tp_extension_3dmodel_xyz_rotation,
p.tp_extension_3dmodel_xyz_offset,
p.tp_3dmodel_side,
{
rotation_f: [0, 0, 0],
offset_f: [0, 0, 0],
rotation_b: [0, 180, 0],
offset_b: [0, 0, -1.6],
},
)
}
${ gen_3d_model(
p.tp_3dmodel_filename,
p.tp_3dmodel_xyz_scale,
p.tp_3dmodel_xyz_rotation,
p.tp_3dmodel_xyz_offset,
p.tp_3dmodel_side,
{
rotation_f: [0, 0, 180],
offset_f: [0, 0, 0],
rotation_b: [0, 0, 0],
offset_b: [0, 0, 0],
},
)
}
`;
final += bottom;
return final;
}
}