-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathswitch_choc_v1_v2.js
750 lines (704 loc) · 31.9 KB
/
switch_choc_v1_v2.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
// 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/
//
// Authors: @ergogen + @infused-kim, @ceoloide, @grazfather, @nxtk improvements
//
// Description:
// Kailh Choc PG1350 (v1) + Kailh Choc PG1353 (v2) reversible and hotswappable footprint.
// This includes support for LOFREE low profile POM switches (Ghost, Phantom, Wizard)
//
// With the set defaults it will include support for choc v1 and v2 hotswap, single side
// (Back).
//
// Nets:
// from: corresponds to pin 1
// to: corresponds to pin 2
//
// Params:
// side: default is B for Back
// the side on which to place the single-side footprint and designator, either F or B
// reversible: default is false
// if true, the footprint will be placed on both sides so that the PCB can be
// reversible
// hotswap: default is true
// if true, will include holes and pads for Kailh choc hotswap sockets
// solder: default is false
// if true, will include holes to solder switches (works with hotswap too)
// hotswap_pads_same_side: false
// if true, and if not using plated holes, it will position the pads so that nets are on
// the same side to simplify routing.
// include_traces_vias: default is true
// if true it will include traces and vias when hotswap is true, footprint is reversible
// and when no plated holes are used, to simplify routing. In the other cases it's simply
// not needed.
// trace_width: default is 0.200mm
// allows to override the trace width that connects the pads. Not recommended
// to go below 0.15mm (JLCPC min is 0.127mm), or above 0.200mm to avoid DRC errors.
// via_size: default is 0.6
// allows to define the size of the via. Not recommended below 0.56 (JLCPCB minimum),
// or above 0.8 (KiCad default), to avoid overlap or DRC errors
// via_drill: default is 0.3
// allows to define the size of the drill. Not recommended below 0.3 (JLCPCB minimum),
// or above 0.4 (KiCad default), to avoid overlap or DRC errors
// locked_traces_vias: false
// sets the traces and vias as locked in KiCad. Locked objects may not be manipulated
// or moved, and cannot be selected unless the Locked Items option is enabled in the
// Selection Filter panel in KiCad. Useful for a faster workflow. If using autorouting
// solutins like Freerouting, locking can prevent the traces and vias from being
// replaced.
// include_plated_holes: default is false
// Alternate version of the footprint compatible with side, reversible, hotswap, solder options in any combination.
// Pretty, allows for connecting ground fill zones via center hole,
// allows for setting nets to Choc v2 stabilizers and them for your routing needs.
// include_stabilizer_nets: default is false
// if true, will add adjustable nets to choc v2 plated stabilizer holes,
// LEFTSTAB: default is "D1"
// RIGHTSTAB: default is "D2"
// include_centerhole_net: default is false
// if true, will add adjustable net to the center hole
// CENTERHOLE: default is "GND"
// outer_pad_width_front: default 2.6
// outer_pad_width_back: default 2.6
// Allows you to make the outer hotswap pads smaller to silence DRC
// warnings when the sockets are too close to the edge cuts. It's not
// recommended to go below 1.6mm to ensure the hotswap socket can be
// properly soldered.
// include_keycap: default is false
// if true, will add mx sized keycap box around the footprint (18mm)
// include_corner_marks: default is false
// if true, will add corner marks to indicate plate hole size and position
// include_choc_v1_led_cutout_marks: default is false
// if true, will add marks for the led cutout in choc v1 switch body
// include_choc_v2_led_cutout_marks: default is false
// if true, will add marks for the led cutout in choc v2 switch body
// include_stabilizer_pad: default is true
// if true, will add a corner pad for the stabilizer leg present in some
// Choc switches, unless choc_v2_support is false.
// oval_stabilizer_pad: default is false
// if false, will add an oval pad for the stabilizer leg, and a round one
// if true. Note that the datasheet calls for a round one.
// choc_v1_stabilizers_diameter: default is 1.9 (mm)
// Allows you to narrow Choc v1 stabilizer / boss holes diameter for tighter fit, not recommended to set below 1.7
// choc_v1_support: default is true
// if true, will add lateral stabilizer holes that are required for
// Choc v1 footprints.
// choc_v2_support: default is true
// if true, will make the central hole bigger to as required for
// Choc v2 footprints. If false it will also disable the corner stabilizer
// pad even if include_stabilizer_pad is true.
// keycap_height: default is 18
// Allows you to adjust the width of the keycap outline. For example,
// to show a 1.5u outline for easier aligning.
// keycap_width: default is 18
// Allows you to adjust the height of the keycap outline.
// allow_soldermask_bridges: default is true
// Disables 'solder mask aperture bridges items with different nets' DRC check when set to true
// setting this option to false may be useful for debugging purposes, (applied locally to this footprint only)
// for global setting see `allow_soldermask_bridges_in_footprints` in a kicad template
// switch_3dmodel_filename: default is ''
// Allows you to specify the path to a 3D model STEP or WRL file to be
// used when rendering the PCB. Use the ${VAR_NAME} syntax to point to
// a KiCad configured path.
// switch_3dmodel_xyz_offset: default is [0, 0, 0]
// xyz offset (in mm), used to adjust the position of the 3d model
// relative the footprint.
// switch_3dmodel_xyz_scale: default is [1, 1, 1]
// xyz scale, used to adjust the size of the 3d model relative to its
// original size.
// switch_3dmodel_xyz_rotation: default is [0, 0, 0]
// xyz rotation (in degrees), used to adjust the orientation of the 3d
// model relative the footprint.
// hotswap_3dmodel_filename: default is ''
// Allows you to specify the path to a 3D model to be used when rendering
// the PCB. Allows for paths using a configured path by using the
// ${VAR_NAME} syntax.
// hotswap_3dmodel_xyz_offset: default is [0, 0, 0]
// xyz offset (in mm), used to adjust the position of the 3d model
// relative the footprint.
// hotswap_3dmodel_xyz_scale: default is [1, 1, 1]
// xyz scale, used to adjust the size of the 3d model relative its
// original size.
// hotswap_3dmodel_xyz_rotation: default is [0, 0, 0]
// xyz rotation (in degrees), used to adjust the orientation of the 3d
// model relative the footprint.
// keycap_3dmodel_filename: default is ''
// Allows you to specify the path to a 3D model STEP or WRL file to be
// used when rendering the PCB. Use the ${VAR_NAME} syntax to point to
// a KiCad configured path.
// keycap_3dmodel_xyz_offset: default is [0, 0, 0]
// xyz offset (in mm), used to adjust the position of the 3d model
// relative the footprint.
// keycap_3dmodel_xyz_scale: default is [1, 1, 1]
// xyz scale, used to adjust the size of the 3d model relative to its
// original size.
// keycap_3dmodel_xyz_rotation: default is [0, 0, 0]
// xyz rotation (in degrees), used to adjust the orientation of the 3d
// model relative the footprint.
//
// Notes:
// - Hotswap and solder can be used together. The solder holes will then be
// added above the hotswap holes.
//
// @infused-kim's improvements:
// - Add hotswap socket outlines
// - Move switch corner marks from user layer to silk screen
// - Add option to adjust keycap size outlines (to show 1.5u outline)
// - Add option to add hotswap sockets and direct soldering holes at the
// same time
// - Make hotswap pads not overlap holes to fix DRC errors
// - Fixed DRC errors "Drilled holes co-located"
//
// @ceoloide's improvements:
// - Adjusted footprint to be Choc PG1353 (v2) compatible
// - Add option to hide corner marks, as they interfere with hotswap silkscreen
// - Add ability to specify board side
// - Add ability to include stabilizer pad
// - Add ability to use an oval stabilizer pad
// - Add option to add routes between pads, and have pads on the same side
// - Add option to lock routes between pads
// - Upgrade to KiCad 8
//
// @grazfather's improvements:
// - Add support for switch 3D model
//
// @nxtk's improvements:
// - Add plated version, inspired by @daprice and @ssbb
// - Add ability to adjust v1 stabilizer / boss holes
// - Add ability to assign nets to v2 stabilizer / boss holes (useful for routing diode in place of backlight led)
// - Add ability to set a net to central hole (useful for connecting ground fill zones)
// - Add opposite stabilizer / boss holes when (choc_v2_support & solder & hotswap) options enabled together
// - Change v2 stabilizer / boss holes to plated
// - Add allow_soldermask_bridges option, which disables 'solder mask aperture bridges items with different nets' DRC check
//
// @mlilley's improvements:
// - Add options to include marks for the led cutout in choc v1 and v2 switch bodies
module.exports = {
params: {
designator: 'S',
side: 'B',
reversible: false,
hotswap_pads_same_side: false,
include_traces_vias: true,
trace_width: 0.2,
via_size: 0.6,
via_drill: 0.3,
locked_traces_vias: false,
hotswap: true,
include_plated_holes: false,
include_stabilizer_nets: false,
include_centerhole_net: false,
solder: false,
outer_pad_width_front: 2.6,
outer_pad_width_back: 2.6,
include_keycap: false,
keycap_width: 18,
keycap_height: 18,
include_corner_marks: false,
include_choc_v1_led_cutout_marks: false,
include_choc_v2_led_cutout_marks: false,
include_stabilizer_pad: true,
oval_stabilizer_pad: false,
choc_v1_support: true,
choc_v2_support: true,
choc_v1_stabilizers_diameter: 1.9,
allow_soldermask_bridges: true,
switch_3dmodel_filename: '',
switch_3dmodel_xyz_offset: [0, 0, 0],
switch_3dmodel_xyz_rotation: [0, 0, 0],
switch_3dmodel_xyz_scale: [1, 1, 1],
hotswap_3dmodel_filename: '',
hotswap_3dmodel_xyz_offset: [0, 0, 0],
hotswap_3dmodel_xyz_rotation: [0, 0, 0],
hotswap_3dmodel_xyz_scale: [1, 1, 1],
keycap_3dmodel_filename: '',
keycap_3dmodel_xyz_offset: [0, 0, 0],
keycap_3dmodel_xyz_rotation: [0, 0, 0],
keycap_3dmodel_xyz_scale: [1, 1, 1],
from: undefined,
to: undefined,
CENTERHOLE: { type: 'net', value: 'GND'},
LEFTSTAB: { type: 'net', value: 'D1' },
RIGHTSTAB: { type: 'net', value: 'D2' }
},
body: p => {
const common_top = `
(footprint "ceoloide:switch_choc_v1_v2"
(layer "${p.side}.Cu")
${p.at}
(property "Reference" "${p.ref}"
(at 0 8.8 ${p.r})
(layer "${p.side}.SilkS")
${p.ref_hide}
(effects (font (size 1 1) (thickness 0.15)))
)
(attr exclude_from_pos_files exclude_from_bom${p.allow_soldermask_bridges ? ' allow_soldermask_bridges' : ''})
${''/* middle shaft hole */}
${p.include_plated_holes ? `
(pad "" thru_hole circle (at 0 0 ${p.r}) (size ${p.choc_v2_support ? '5.3 5.3' : '3.7 3.7'}) (drill ${p.choc_v2_support ? '5' : '3.4'}) (layers "*.Cu" "*.Mask") ${p.include_centerhole_net ? p.CENTERHOLE : ''})
`: `
(pad "" np_thru_hole circle (at 0 0 ${p.r}) (size ${p.choc_v2_support ? '5 5' : '3.4 3.4'}) (drill ${p.choc_v2_support ? '5' : '3.4'}) (layers "*.Cu" "*.Mask"))
`}
`
const choc_v1_stabilizers = `
${p.include_plated_holes ? `
(pad "" thru_hole circle (at 5.5 0 ${p.r}) (size ${p.choc_v1_stabilizers_diameter + 0.3} ${p.choc_v1_stabilizers_diameter + 0.3}) (drill ${p.choc_v1_stabilizers_diameter}) (layers "*.Cu" "*.Mask"))
(pad "" thru_hole circle (at -5.5 0 ${p.r}) (size ${p.choc_v1_stabilizers_diameter + 0.3} ${p.choc_v1_stabilizers_diameter + 0.3}) (drill ${p.choc_v1_stabilizers_diameter}) (layers "*.Cu" "*.Mask"))
`: `
(pad "" np_thru_hole circle (at 5.5 0 ${p.r}) (size ${p.choc_v1_stabilizers_diameter} ${p.choc_v1_stabilizers_diameter}) (drill ${p.choc_v1_stabilizers_diameter}) (layers "*.Cu" "*.Mask"))
(pad "" np_thru_hole circle (at -5.5 0 ${p.r}) (size ${p.choc_v1_stabilizers_diameter} ${p.choc_v1_stabilizers_diameter}) (drill ${p.choc_v1_stabilizers_diameter}) (layers "*.Cu" "*.Mask"))
`}
`
const corner_marks = `
${''/* corner marks - front */}
(fp_line (start -7 -6) (end -7 -7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start -7 7) (end -6 7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start -6 -7) (end -7 -7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start -7 7) (end -7 6) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start 7 6) (end 7 7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start 7 -7) (end 6 -7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start 6 7) (end 7 7) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
(fp_line (start 7 -7) (end 7 -6) (layer "Dwgs.User") (stroke (width 0.15) (type solid)))
`
const keycap_xo = 0.5 * p.keycap_width
const keycap_yo = 0.5 * p.keycap_height
const keycap_marks = `
(fp_rect (start ${keycap_xo} ${keycap_yo}) (end ${-keycap_xo} ${-keycap_yo}) (layer "Dwgs.User") (stroke (width 0.15) (type solid)) (fill none))
`
const choc_v1_led_cutout_marks = `
(fp_rect (start -2.65 6.325) (end 2.65 3.075) (layer "Dwgs.User") (width 0.15) (stroke (width 0.15) (type solid)) (fill none))
`
const choc_v2_led_cutout_marks = `
(fp_rect (start -2.75 6.405) (end 2.75 3.455) (layer "Dwgs.User") (width 0.15) (stroke (width 0.15) (type solid)) (fill none))
`
const hotswap_common = `
${'' /* Middle Hole */}
${p.include_plated_holes ? `
(pad ${p.reversible ? '""' : 1} thru_hole circle (at 0 -5.95 ${p.r}) (size 3.3 3.3) (drill 3) (layers "*.Cu" "*.Mask") ${p.reversible ? '' : p.from.str})
`: `
(pad "" np_thru_hole circle (at 0 -5.95 ${p.r}) (size 3 3) (drill 3) (layers "*.Cu" "*.Mask"))
`}
`
const hotswap_back_pads_plated = `
(pad "1" smd roundrect (at -2.648 -5.95 ${p.r}) (size 3.8 2.15) (layers "B.Cu") (roundrect_rratio 0.1) ${p.from.str})
(pad "" smd roundrect (at -3.248 -5.95 ${p.r}) (size 2.6 2.15) (layers "B.Paste" "B.Mask") (roundrect_rratio 0.1))
(pad "2" smd roundrect (at ${7.6475 - (2.6 - p.outer_pad_width_back) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_back + 1.2} 2.15) (layers "B.Cu") (roundrect_rratio 0.1) ${p.to.str})
(pad "" smd roundrect (at ${8.2475 - (2.6 - p.outer_pad_width_back) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_back} 2.15) (layers "B.Paste" "B.Mask") (roundrect_rratio ${(2.15 / p.outer_pad_width_back) <= 1 ? 0.1 : 0.1 * (2.15 / p.outer_pad_width_back)}))
`
const hotswap_front_pads_plated = `
(pad "1" smd roundrect (at 2.648 -5.95 ${p.r}) (size 3.8 2.15) (layers "F.Cu") (roundrect_rratio 0.1) ${p.from.str})
(pad "" smd roundrect (at 3.248 -5.95 ${p.r}) (size 2.6 2.15) (layers "F.Paste" "F.Mask") (roundrect_rratio 0.1))
(pad "2" smd roundrect (at ${-7.6475 + (2.6 - p.outer_pad_width_front) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_front + 1.2} 2.15) (layers "F.Cu") (roundrect_rratio 0.1) ${p.to.str})
(pad "" smd roundrect (at ${-8.2475 + (2.6 - p.outer_pad_width_front) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_front} 2.15) (layers "F.Paste" "F.Mask") (roundrect_rratio ${(2.15 / p.outer_pad_width_front) <= 1 ? 0.1 : 0.1 * (2.15 / p.outer_pad_width_front)}))
`
const hotswap_back_pads_plated_reversible = `
(pad "1" smd roundrect (at -3.245 -5.95 ${p.r}) (size 2.65 2.15) (layers "B.Cu" "B.Paste" "B.Mask") (roundrect_rratio 0.1) ${p.from.str})
(pad "2" smd roundrect (at ${7.6475 - (2.6 - p.outer_pad_width_back) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_back + 1.2} 2.15) (layers "B.Cu") (roundrect_rratio 0.1) ${p.to.str})
(pad "" smd roundrect (at ${8.2475 - (2.6 - p.outer_pad_width_back) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_back} 2.15) (layers "B.Paste" "B.Mask") (roundrect_rratio ${(2.15 / p.outer_pad_width_back) <= 1 ? 0.1 : 0.1 * (2.15 / p.outer_pad_width_back)}))
`
const hotswap_front_pads_plated_reversible = `
(pad "2" smd roundrect (at 3.245 -5.95 ${p.r}) (size 2.65 2.15) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.1) ${p.to.str})
(pad "1" smd roundrect (at ${-7.6475 + (2.6 - p.outer_pad_width_front) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_front + 1.2} 2.15) (layers "F.Cu") (roundrect_rratio 0.1) ${p.from.str})
(pad "" smd roundrect (at ${-8.2475 + (2.6 - p.outer_pad_width_front) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_front} 2.15) (layers "F.Paste" "F.Mask") (roundrect_rratio ${(2.15 / p.outer_pad_width_front) <= 1 ? 0.1 : 0.1 * (2.15 / p.outer_pad_width_front)}))
`
const hotswap_front_pad_cutoff = `
(pad "1" smd roundrect
(at 3.275 -5.95 ${p.r})
(size 2.6 2.6)
(layers "F.Cu" "F.Paste" "F.Mask")
(roundrect_rratio 0)
(chamfer_ratio 0.455)
(chamfer bottom_right)
${p.from.str}
)
`
const hotswap_front_pad_full = `
(pad "1" smd rect (at 3.275 -5.95 ${p.r}) (size 2.6 2.6) (layers "F.Cu" "F.Paste" "F.Mask") ${p.from.str})
`
const hotswap_back_pad_cutoff = `
(pad "1" smd roundrect
(at -3.275 -5.95 ${p.r})
(size 2.6 2.6)
(layers "B.Cu" "B.Paste" "B.Mask")
(roundrect_rratio 0)
(chamfer_ratio 0.455)
(chamfer bottom_left)
${p.hotswap_pads_same_side ? p.to.str : p.from.str}
)
`
const hotswap_back_pad_full = `
(pad "1" smd rect (at -3.275 -5.95 ${p.r}) (size 2.6 2.6) (layers "B.Cu" "B.Paste" "B.Mask") ${p.from.str})
`
const hotswap_back = `
${'' /* Silkscreen outline */}
${'' /* back top */}
(fp_line (start -1.5 -8.2) (end -2 -7.7) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 1.5 -8.2) (end -1.5 -8.2) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2 -7.7) (end 1.5 -8.2) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2 -7.7) (end 2 -6.78) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2.52 -6.2) (end 7 -6.2) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 7 -6.2) (end 7 -5.6) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_arc (start 2.52 -6.2) (mid 2.139878 -6.382304) (end 2 -6.78) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
${'' /* back bottom */}
(fp_line (start -1.5 -3.7) (end -2 -4.2) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 0.8 -3.7) (end -1.5 -3.7) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2.5 -1.5) (end 2.5 -2.2) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 7 -1.5) (end 2.5 -1.5) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 7 -2) (end 7 -1.5) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
(fp_arc (start 0.8 -3.7) (mid 1.956518 -3.312082) (end 2.5 -2.22) (layer "B.SilkS") (stroke (width 0.15) (type solid)))
${p.include_plated_holes ? `
${'' /* Side Hole */}
${p.reversible ? `
(pad "2" thru_hole circle (at 5 -3.75 ${195 + p.r}) (size 3.3 3.3) (drill 3) (layers "*.Cu" "*.Mask") ${p.to.str})
${'' /* Pads */}
${hotswap_back_pads_plated_reversible}
`:`
(pad "2" thru_hole circle (at 5 -3.75 ${195 + p.r}) (size 3.3 3.3) (drill 3) (layers "*.Cu" "*.Mask") ${p.to.str})
${'' /* Pads */}
${hotswap_back_pads_plated}
`}
`: `
${'' /* Left Pad*/}
${p.reversible ? hotswap_back_pad_cutoff : hotswap_back_pad_full}
${'' /* Right Pad (not cut off) */}
(pad "2" smd rect (at ${8.275 - (2.6 - p.outer_pad_width_back) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_back} 2.6) (layers "B.Cu" "B.Paste" "B.Mask") ${p.hotswap_pads_same_side ? p.from.str : p.to.str})
${'' /* Side Hole */}
(pad "" np_thru_hole circle (at 5 -3.75 ${195 + p.r}) (size 3 3) (drill 3) (layers "*.Cu" "*.Mask"))
`}
`
const hotswap_front = `
${'' /* Silkscreen outline */}
${'' /* front top */}
(fp_line (start -7 -5.6) (end -7 -6.2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start -7 -6.2) (end -2.52 -6.2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start -2 -6.78) (end -2 -7.7) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start -1.5 -8.2) (end -2 -7.7) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 1.5 -8.2) (end -1.5 -8.2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2 -7.7) (end 1.5 -8.2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_arc (start -2 -6.78) (mid -2.139878 -6.382304) (end -2.52 -6.2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
${'' /* front bottom */}
(fp_line (start -7 -1.5) (end -7 -2) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start -2.5 -1.5) (end -7 -1.5) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start -2.5 -2.2) (end -2.5 -1.5) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 1.5 -3.7) (end -0.8 -3.7) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_line (start 2 -4.2) (end 1.5 -3.7) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
(fp_arc (start -2.5 -2.22) (mid -1.956518 -3.312082) (end -0.8 -3.7) (layer "F.SilkS") (stroke (width 0.15) (type solid)))
${p.include_plated_holes ? `
${'' /* Side Hole */}
${p.reversible ? `
(pad "1" thru_hole circle (at -5 -3.75 ${195 + p.r}) (size 3.3 3.3) (drill 3) (layers "*.Cu" "*.Mask") ${p.from.str})
${'' /* Pads */}
${hotswap_front_pads_plated_reversible}
`:`
(pad "2" thru_hole circle (at -5 -3.75 ${195 + p.r}) (size 3.3 3.3) (drill 3) (layers "*.Cu" "*.Mask") ${p.to.str})
${'' /* Pads */}
${hotswap_front_pads_plated}
`}
`: `
${'' /* Side Hole */}
(pad "" np_thru_hole circle (at -5 -3.75 ${195 + p.r}) (size 3 3) (drill 3) (layers "*.Cu" "*.Mask"))
${'' /* Right Pad (cut off) */}
${p.reversible ? hotswap_front_pad_cutoff : hotswap_front_pad_full}
${'' /* Left Pad (not cut off) */}
(pad "2" smd rect (at ${-8.275 + (2.6 - p.outer_pad_width_front) / 2} -3.75 ${p.r}) (size ${p.outer_pad_width_front} 2.6) (layers "F.Cu" "F.Paste" "F.Mask") ${p.to.str})
`}
`
// If both hotswap and solder are enabled, move the solder holes
// "down" to the opposite side of the switch.
// Since switches can be rotated by 90 degrees, this won't be a
// problem as long as we switch the side the holes are on.
let solder_offset_x_front = '-'
let solder_offset_x_back = ''
let solder_offset_y = '-'
let stab_offset_x_front = ''
let stab_offset_x_back = '-'
let stab_offset_y = ''
if (p.hotswap && p.solder) {
solder_offset_x_front = ''
solder_offset_x_back = '-'
solder_offset_y = ''
stab_offset_x_front = '-'
stab_offset_x_back = ''
stab_offset_y = ''
}
const solder_common = `
(pad "2" thru_hole circle (at 0 ${solder_offset_y}5.9 ${195 + p.r}) (size 2.032 2.032) (drill 1.27) (layers "*.Cu" "*.Mask") ${p.from.str})
`
const solder_front = `
(pad "1" thru_hole circle (at ${solder_offset_x_front}5 ${solder_offset_y}3.8 ${195 + p.r}) (size 2.032 2.032) (drill 1.27) (layers "*.Cu" "*.Mask") ${p.to.str})
`
const solder_back = `
(pad "1" thru_hole circle (at ${solder_offset_x_back}5 ${solder_offset_y}3.8 ${195 + p.r}) (size 2.032 2.032) (drill 1.27) (layers "*.Cu" "*.Mask") ${p.to.str})
`
const oval_corner_stab_front = `
(pad "" thru_hole oval (at ${stab_offset_x_front}5 ${stab_offset_y}5.15 ${p.r}) (size 2.4 1.2) (drill oval 1.6 0.4) (layers "*.Cu" "*.Mask") ${p.solder && p.hotswap ? p.to.str : p.include_stabilizer_nets ? p.RIGHTSTAB : ''})
`
const oval_corner_stab_back = `
(pad "" thru_hole oval (at ${stab_offset_x_back}5 ${stab_offset_y}5.15 ${p.r}) (size 2.4 1.2) (drill oval 1.6 0.4) (layers "*.Cu" "*.Mask") ${p.solder && p.hotswap ? p.to.str : p.include_stabilizer_nets ? p.LEFTSTAB : ''})
`
const round_corner_stab_front = `
(pad "" thru_hole circle (at ${stab_offset_x_front}5.00 ${stab_offset_y}5.15 ${p.r}) (size 1.9 1.9) (drill 1.6) (layers "*.Cu" "*.Mask") ${p.solder && p.hotswap ? p.to.str : p.include_stabilizer_nets ? p.RIGHTSTAB : ''})
`
const round_corner_stab_back = `
(pad "" thru_hole circle (at ${stab_offset_x_back}5.00 ${stab_offset_y}5.15 ${p.r}) (size 1.9 1.9) (drill 1.6) (layers "*.Cu" "*.Mask") ${p.solder && p.hotswap ? p.to.str : p.include_stabilizer_nets ? p.LEFTSTAB : ''})
`
const switch_3dmodel = `
(model ${p.switch_3dmodel_filename}
(offset (xyz ${p.switch_3dmodel_xyz_offset[0]} ${p.switch_3dmodel_xyz_offset[1]} ${p.switch_3dmodel_xyz_offset[2]}))
(scale (xyz ${p.switch_3dmodel_xyz_scale[0]} ${p.switch_3dmodel_xyz_scale[1]} ${p.switch_3dmodel_xyz_scale[2]}))
(rotate (xyz ${p.switch_3dmodel_xyz_rotation[0]} ${p.switch_3dmodel_xyz_rotation[1]} ${p.switch_3dmodel_xyz_rotation[2]}))
)
`
const hotswap_3dmodel = `
(model ${p.hotswap_3dmodel_filename}
(offset (xyz ${p.hotswap_3dmodel_xyz_offset[0]} ${p.hotswap_3dmodel_xyz_offset[1]} ${p.hotswap_3dmodel_xyz_offset[2]}))
(scale (xyz ${p.hotswap_3dmodel_xyz_scale[0]} ${p.hotswap_3dmodel_xyz_scale[1]} ${p.hotswap_3dmodel_xyz_scale[2]}))
(rotate (xyz ${p.hotswap_3dmodel_xyz_rotation[0]} ${p.hotswap_3dmodel_xyz_rotation[1]} ${p.hotswap_3dmodel_xyz_rotation[2]}))
)
`
const keycap_3dmodel = `
(model ${p.keycap_3dmodel_filename}
(offset (xyz ${p.keycap_3dmodel_xyz_offset[0]} ${p.keycap_3dmodel_xyz_offset[1]} ${p.keycap_3dmodel_xyz_offset[2]}))
(scale (xyz ${p.keycap_3dmodel_xyz_scale[0]} ${p.keycap_3dmodel_xyz_scale[1]} ${p.keycap_3dmodel_xyz_scale[2]}))
(rotate (xyz ${p.keycap_3dmodel_xyz_rotation[0]} ${p.keycap_3dmodel_xyz_rotation[1]} ${p.keycap_3dmodel_xyz_rotation[2]}))
)
`
const common_bottom = `
)
`
const hotswap_routes_unplated = `
(segment
(start ${p.eaxy(3.275, -5.95)})
(end ${p.eaxy(1.2, -3.875)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.from.index})
)
(segment
(start ${p.eaxy(1.2, -3.875)})
(end ${p.eaxy(0, -3.875)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.from.index})
)
(via
(at ${p.eaxy(0, -3.875)})
(size ${p.via_size})
(drill ${p.via_drill})
(layers "F.Cu" "B.Cu")
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(net ${p.from.index})
)
(segment
(start ${p.eaxy(-1.2, -3.875)})
(end ${p.eaxy(0, -3.875)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.from.index})
)
(segment
(start ${p.eaxy(-3.275, -5.95)})
(end ${p.eaxy(-1.2, -3.875)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.from.index})
)
(segment
(start ${p.eaxy(-6.421, -1.896)})
(end ${p.eaxy(-2.154, -1.896)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(-0.975, -3.075)})
(end ${p.eaxy(0, -3.075)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(-8.275, -3.75)})
(end ${p.eaxy(-6.421, -1.896)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(-2.154, -1.896)})
(end ${p.eaxy(-0.975, -3.075)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.to.index})
)
(via
(at ${p.eaxy(0, -3.075)})
(size ${p.via_size})
(drill ${p.via_drill})
(layers "F.Cu" "B.Cu")
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(net ${p.to.index})
)
(segment
(start ${p.eaxy(2.140166, -1.896)})
(end ${p.eaxy(0.961166, -3.075)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(6.421, -1.896)})
(end ${p.eaxy(2.140166, -1.896)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(0.961166, -3.075)})
(end ${p.eaxy(0, -3.075)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.to.index})
)
(segment
(start ${p.eaxy(8.275, -3.75)})
(end ${p.eaxy(6.421, -1.896)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.to.index})
)
`
const hotswap_routes_same_side = `
(segment
(start ${p.eaxy(3.275, -5.95)})
(end ${p.eaxy(7.775, -5.95)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.from.index})
)
(via
(at ${p.eaxy(7.775, -5.95)})
(size ${p.via_size})
(drill ${p.via_drill})
(layers "F.Cu" "B.Cu")
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(net ${p.from.index})
)
(segment
(start ${p.eaxy(7.775, -3.75)})
(end ${p.eaxy(7.775, -5.95)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.from.index})
)
(segment
(start ${p.eaxy(-7.775, -3.75)})
(end ${p.eaxy(-7.775, -5.95)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "F.Cu")
(net ${p.to.index})
)
(via
(at ${p.eaxy(-7.775, -5.95)})
(size ${p.via_size})
(drill ${p.via_drill})
(layers "F.Cu" "B.Cu")
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(net ${p.to.index})
)
(segment
(start ${p.eaxy(-3.275, -5.95)})
(end ${p.eaxy(-7.775, -5.95)})
(width ${p.trace_width})
(locked ${p.locked_traces_vias ? 'yes' : 'no'})
(layer "B.Cu")
(net ${p.to.index})
)
`
let final = common_top
if (p.choc_v1_support) {
final += choc_v1_stabilizers
}
if (p.include_corner_marks) {
final += corner_marks;
}
if (p.include_keycap) {
final += keycap_marks
}
if (p.include_stabilizer_pad && p.choc_v2_support) {
if (p.reversible || p.side == "F") {
if (p.oval_stabilizer_pad) {
final += oval_corner_stab_front
} else {
final += round_corner_stab_front
}
}
if (p.reversible || p.side == "B") {
if (p.oval_stabilizer_pad) {
final += oval_corner_stab_back
} else {
final += round_corner_stab_back
}
}
}
if (p.include_choc_v1_led_cutout_marks) {
final += choc_v1_led_cutout_marks
}
if (p.include_choc_v2_led_cutout_marks) {
final += choc_v2_led_cutout_marks
}
if (p.hotswap) {
final += hotswap_common
if (p.reversible || p.side == "F") {
final += hotswap_front
}
if (p.reversible || p.side == "B") {
final += hotswap_back
}
if (p.hotswap_3dmodel_filename) {
final += hotswap_3dmodel
}
}
if (p.solder) {
final += solder_common
if (p.reversible || p.side == "F") {
final += solder_front
}
if (p.reversible || p.side == "B") {
final += solder_back
}
}
if (p.switch_3dmodel_filename) {
final += switch_3dmodel
}
if (p.keycap_3dmodel_filename) {
final += keycap_3dmodel
}
final += common_bottom
if (p.reversible && p.hotswap && p.include_traces_vias && !p.include_plated_holes) {
if(p.hotswap_pads_same_side){
final += hotswap_routes_same_side
} else {
final += hotswap_routes_unplated
}
}
return final;
}
}