/
layout.py
executable file
·888 lines (848 loc) · 40.1 KB
/
layout.py
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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
#!/usr/bin/python
"""
Create a json file using http://www.keyboard-layout-editor.com/
Use that file to create a kicad schematic and pcb with the switches.
"""
import six
import json
import codecs
import os
from time import time
from pprint import pprint
#
# footprint_name is used to look up the pcb template below
#
# The following are currently defined:
#
# mx - MX, no mounting holes, no LEDs
# mx_pcb - MX, includes mounting holes, but no LEDs
# mx_led - MX, includes LEDs and mounting holes
# mxalps - mx merged with alps using slots (w/LEDs + holes)
# mxalps-no_pcb - mx merged with alps using slots (w/LEDs, but no holes)
# mxalps-reversed - mx merged with alps rotated 180 no LEDs or holes
# mxalps-no-led - mx merged with alps, but no LEDs or holes
#
footprint_name = "mxalps"
# If 0 the LED slot will be at the top, if you're not using LEDs
# rotating 180 will orient the switch in the standard cherry way
# which is apparently more compatible with some key caps.
switch_rotate = 180
# Path to the json file downloaded from http://www.keyboard-layout-editor.com/
layout_file_name = "EL87.json"
# name that will be prepended to all output
project_name = "EL87"
# output directory
output_directory = os.path.join(os.getcwd(), project_name)
# project file
project_file_name = os.path.join(output_directory, project_name + ".pro")
# schematic file
schematic_file_name = os.path.join(output_directory, project_name + ".sch")
# pcb file
pcb_file_name = os.path.join(output_directory, project_name + ".kicad_pcb")
# PCB - Basics
pcb_spacing = 19.05 # 19.05mm aka .75"
x_origin = 2.0
y_origin = 1.5
# PCB - Diode placement relative to the switch
#
# WARNING: You almost certainly need to move some diodes manually. In
# particular check for overlap with stabilizers.
#
# Through hole examples:
# Left side:
# diode_rotate = 270
# diode_x_offset = -9
# diode_y_offset = -5
# diode_label_rotate = 0
# diode_label_x_offset = 3 * 2.54
# diode_label_y_offset = -1.6
# Top:
# diode_rotate = 0
# diode_x_offset = -7.62
# diode_y_offset = -8.1
# Bottom:
# diode_rotate = 180
# diode_x_offset = 3 * 2.54
# diode_y_offset = 8.1
diode_template = "diode_MiniMELF"
# diode_template = "diode_SOD-123" # 'diode_MiniMELF' 'diode_SOD-123' or 'diode_DO-35'
diode_rotate = 90
diode_x_offset = -2 * 2.54
diode_y_offset = 2 * 2.54
diode_label_rotate = 90
diode_label_x_offset = 0
diode_label_y_offset = -1.8
# Schematic
# Switches
sw_spacing = 1000
sw_x_origin = 100
sw_y_origin = 100
# LEDs
led_spacing = 1000
led_x_origin = 100
led_y_origin = 6000
#
# End of config variables
#
pcb_header = """(kicad_pcb (version 4) (host pcbnew 4.0.2-stable)
(general
(links 539)
(no_connects 522)
(area 0 0 0 0)
(thickness 1.6)
(drawings 0)
(tracks 47)
(zones 0)
(modules 202)
(nets 134)
)
(page A2)
(layers
(0 F.Cu signal)
(31 B.Cu signal)
(32 B.Adhes user)
(33 F.Adhes user)
(34 B.Paste user)
(35 F.Paste user)
(36 B.SilkS user)
(37 F.SilkS user)
(38 B.Mask user)
(39 F.Mask user)
(40 Dwgs.User user)
(41 Cmts.User user)
(42 Eco1.User user)
(43 Eco2.User user)
(44 Edge.Cuts user)
(45 Margin user)
(46 B.CrtYd user)
(47 F.CrtYd user)
(48 B.Fab user)
(49 F.Fab user)
)
(setup
(last_trace_width 0.254)
(user_trace_width 0.254)
(user_trace_width 0.3048)
(user_trace_width 0.381)
(trace_clearance 0.2032)
(zone_clearance 0.508)
(zone_45_only no)
(trace_min 0.2032)
(segment_width 0.2)
(edge_width 0.15)
(via_size 0.6096)
(via_drill 0.3048)
(via_min_size 0.6096)
(via_min_drill 0.3048)
(uvia_size 0.4572)
(uvia_drill 0.3048)
(uvias_allowed no)
(uvia_min_size 0.4572)
(uvia_min_drill 0.3048)
(pcb_text_width 0.3)
(pcb_text_size 1.5 1.5)
(mod_edge_width 0.15)
(mod_text_size 1 1)
(mod_text_width 0.15)
(pad_size 1.524 1.524)
(pad_drill 0.762)
(pad_to_mask_clearance 0.04)
(solder_mask_min_width 0.1)
(aux_axis_origin 0 0)
(visible_elements FFFFF77F)
(pcbplotparams
(layerselection 0x00030_80000001)
(usegerberextensions false)
(excludeedgelayer true)
(linewidth 0.150000)
(plotframeref false)
(viasonmask false)
(mode 1)
(useauxorigin false)
(hpglpennumber 1)
(hpglpenspeed 20)
(hpglpendiameter 15)
(hpglpenoverlay 2)
(psnegative false)
(psa4output false)
(plotreference true)
(plotvalue true)
(plotinvisibletext false)
(padsonsilk false)
(subtractmaskfromsilk false)
(outputformat 1)
(mirror false)
(drillshape 1)
(scaleselection 1)
(outputdirectory ""))
)
(net_class Default "This is the default net class."
(clearance 0.2032)
(trace_width 0.381)
(via_dia 0.6096)
(via_drill 0.3048)
(uvia_dia 0.4572)
(uvia_drill 0.3048)
)
(net_class 10m ""
(clearance 0.2032)
(trace_width 0.254)
(via_dia 0.6096)
(via_drill 0.3048)
(uvia_dia 0.4572)
(uvia_drill 0.3048)
)
(net_class 20m ""
(clearance 0.254)
(trace_width 0.508)
(via_dia 0.6096)
(via_drill 0.3048)
(uvia_dia 0.4572)
(uvia_drill 0.3048)
)"""
pcb_footer = """)
"""
#
# mx - Standard, includes mounting holes, but no LEDs
# mx_led - Standard, includes LEDs and mounting holes
# mxalps - mx merged with alps using slots (w/LEDs + holes)
# mxalps-reversed - mx merged with alps rotated 180 no LEDs or holes
# mxalps-no-led - mx merged with alps, but no LEDs or holes
#
footprints = {
#
# Standard, includes mounting holes, but no LEDs
#
"mx": """(module MX locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MX)
(tags MX)
(fp_text reference {reference} (at 0 3) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.985) (end 6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.985) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad SW2 thru_hole circle (at 2.54 -5.08) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad SW1 thru_hole circle (at -3.81 -2.54) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad "" np_thru_hole circle (at 0 0) (size 3.9878 3.9878) (drill 3.9878) (layers *.Cu))
)""",
"mx_pcb": """(module MX_PCB locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MX_PCB)
(tags MX_PCB)
(fp_text reference {reference} (at 0 3) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.985) (end 6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.985) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad SW2 thru_hole circle (at 2.54 -5.08) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad SW1 thru_hole circle (at -3.81 -2.54) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad "" np_thru_hole circle (at 0 0) (size 3.9878 3.9878) (drill 3.9878) (layers *.Cu))
(pad HOLE np_thru_hole circle (at -5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu))
(pad "" np_thru_hole circle (at 5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu))
)""",
#
# Standard, includes LEDs and mounting holes
#
"mx_led": """(module MX_LED locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MX_LED)
(tags MX_LED)
(fp_text reference {reference} (at 0 3) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_line (start -0.762 6.731) (end -0.762 6.35) (layer F.SilkS) (width 0.15))
(fp_line (start -0.762 6.35) (end -0.762 6.223) (layer F.SilkS) (width 0.15))
(fp_line (start -0.762 3.429) (end -0.762 3.937) (layer F.SilkS) (width 0.15))
(fp_arc (start 0.127 5.334) (end 1.524 6.223) (angle 90) (layer F.SilkS) (width 0.15))
(fp_arc (start 0.127 4.826) (end -0.762 3.429) (angle 90) (layer F.SilkS) (width 0.15))
(fp_arc (start 0.127 5.461) (end 0.889 6.223) (angle 90) (layer F.SilkS) (width 0.15))
(fp_arc (start 0.127 4.699) (end -0.635 3.937) (angle 90) (layer F.SilkS) (width 0.15))
(fp_text user A (at 2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user K (at -2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user A (at 2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user K (at -2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.985) (end 6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.985) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad A thru_hole circle (at 1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
(pad K thru_hole rect (at -1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
(pad SW2 thru_hole circle (at 2.54 -5.08) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad SW1 thru_hole circle (at -3.81 -2.54) (size 2.5 2.5) (drill 1.4986) (layers *.Cu *.SilkS *.Mask))
(pad "" np_thru_hole circle (at 0 0) (size 3.9878 3.9878) (drill 3.9878) (layers *.Cu))
(pad HOLE np_thru_hole circle (at -5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu))
(pad "" np_thru_hole circle (at 5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu))
)""",
#
# mx merged with alps using slots (w/LEDs, but no holes)
#
"mxalps-no_pcb": """(module MXALPS locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MXALPS)
(tags MXALPS)
(fp_text reference {reference} (at 0 7) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_text user A (at 2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user K (at -2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user A (at 2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user K (at -2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end 6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.4) (end 7.75 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 -6.4) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 -6.4) (end -6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 6.4) (end 7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.4) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 -6.4) (end 6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.4) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad "" np_thru_hole circle (at 0 0) (size 3.98781 3.98781) (drill 3.9878) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad SW1 thru_hole oval (at -3.405 -3.27 330.95) (size 2.5 4.17) (drill oval 1.5 3.17) (layers *.Cu *.Mask F.SilkS))
(pad SW2 thru_hole oval (at 2.52 -4.79 356.1) (size 2.5 3.08) (drill oval 1.5 2.08) (layers *.Cu *.Mask F.SilkS))
(pad K thru_hole rect (at -1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
(pad A thru_hole circle (at 1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
)""",
#
# mx merged with alps using slots (w/LEDs + holes)
#
"mxalps": """(module MXALPS locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MXALPS)
(tags MXALPS)
(fp_text reference {reference} (at 0 7) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_text user A (at 2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user K (at -2.794 5.08) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text user A (at 2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user K (at -2.794 5.08) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end 6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.4) (end 7.75 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 -6.4) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 -6.4) (end -6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 6.4) (end 7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.4) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 -6.4) (end 6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.4) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad "" np_thru_hole circle (at 0 0) (size 3.98781 3.98781) (drill 3.9878) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad "" np_thru_hole circle (at -5.08 0) (size 1.70181 1.70181) (drill 1.7018) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad "" np_thru_hole circle (at 5.08 0) (size 1.70181 1.70181) (drill 1.7018) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad SW1 thru_hole oval (at -3.405 -3.27 330.95) (size 2.5 4.17) (drill oval 1.5 3.17) (layers *.Cu *.Mask F.SilkS))
(pad SW2 thru_hole oval (at 2.52 -4.79 356.1) (size 2.5 3.08) (drill oval 1.5 2.08) (layers *.Cu *.Mask F.SilkS))
(pad K thru_hole rect (at -1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
(pad A thru_hole circle (at 1.27 5.08) (size 2 2) (drill 1) (layers *.Cu *.SilkS *.Mask))
)""",
#
# mx merged with alps rotated 180 no LEDs or holes
#
"mxalps-reversed": """(module MXALPS-REVERSED locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MXALPS-REVERSED)
(tags MXALPS-REVERSED)
(fp_text reference {reference} (at 0 6.731) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end 6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.4) (end 7.75 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 -6.4) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 -6.4) (end -6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 6.4) (end 7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.4) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 -6.4) (end 6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.4) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad "" np_thru_hole circle (at 0 0) (size 3.98781 3.98781) (drill 3.9878) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad SW1 thru_hole circle (at -3.81 -2.54) (size 2.5 2.5) (drill 1.5) (layers *.Cu *.SilkS *.Mask))
(pad SW2 thru_hole circle (at 2.54 -5.08) (size 2.5 2.5) (drill 1.5) (layers *.Cu *.SilkS *.Mask))
(pad SW1 thru_hole circle (at -2.5 4.5) (size 2.5 2.5) (drill 1.5) (layers *.Cu *.SilkS *.Mask))
(pad SW2 thru_hole circle (at 2.5 4) (size 2.5 2.5) (drill 1.5) (layers *.Cu *.SilkS *.Mask))
)""",
#
# mx merged with alps, but no LEDs or holes
#
"mxalps-no-led": """(module MXALPS-NOLED locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr MXALPS-NOLED)
(tags MXALPS-NOLED)
(fp_text reference {reference} (at 0 3.5) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.2)) (justify mirror))
)
(fp_text value {reference} (at 0 8.2) (layer F.SilkS) hide
(effects (font (thickness 0.3048)))
)
(fp_line (start -6.35 -6.35) (end 6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 -6.35) (end 6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start 6.35 6.35) (end -6.35 6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -6.35 6.35) (end -6.35 -6.35) (layer Cmts.User) (width 0.1524))
(fp_line (start -9.398 -9.398) (end 9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 -9.398) (end 9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start 9.398 9.398) (end -9.398 9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -9.398 9.398) (end -9.398 -9.398) (layer Dwgs.User) (width 0.1524))
(fp_line (start -6.35 -6.35) (end -4.572 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 4.572 -6.35) (end 6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 -6.35) (end 6.35 -4.572) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 4.572) (end 6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start 6.35 6.35) (end 4.572 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -4.572 6.35) (end -6.35 6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 6.35) (end -6.35 4.572) (layer F.SilkS) (width 0.381))
(fp_line (start -6.35 -4.572) (end -6.35 -6.35) (layer F.SilkS) (width 0.381))
(fp_line (start -6.985 -6.985) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.985) (end 6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 6.4) (end 7.75 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 -6.4) (end -6.985 -6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 -6.4) (end -6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 6.4) (end 7.75 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -7.75 6.4) (end -6.985 6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start -6.985 6.4) (end -6.985 6.985) (layer Eco2.User) (width 0.1524))
(fp_line (start 7.75 -6.4) (end 6.985 -6.4) (layer Eco2.User) (width 0.1524))
(fp_line (start 6.985 -6.4) (end 6.985 -6.985) (layer Eco2.User) (width 0.1524))
(pad "" np_thru_hole circle (at 0 0) (size 3.98781 3.98781) (drill 3.9878) (layers *.Cu *.Mask F.SilkS)
(clearance 0.1524))
(pad SW1 thru_hole oval (at -3.405 -3.27 330.95) (size 2.5 4.17) (drill oval 1.5 3.17) (layers *.Cu *.Mask F.SilkS))
(pad SW2 thru_hole oval (at 2.52 -4.79 356.1) (size 2.5 3.08) (drill oval 1.5 2.08) (layers *.Cu *.Mask F.SilkS))
)""",
"diode_SOD-123": """(module Diodes_SMD:SOD-123 (layer B.Cu) (tedit 5530FCB9) (tstamp 57436F4A)
(at {x_pos} {y_pos} {rotate})
(descr SOD-123)
(tags SOD-123)
(attr smd)
(fp_text reference {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_text value {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer B.Fab) hide
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
)
(fp_line (start 0.3175 0) (end 0.6985 0) (layer B.SilkS) (width 0.15))
(fp_line (start -0.6985 0) (end -0.3175 0) (layer B.SilkS) (width 0.15))
(fp_line (start -0.3175 0) (end 0.3175 0.381) (layer B.SilkS) (width 0.15))
(fp_line (start 0.3175 0.381) (end 0.3175 -0.381) (layer B.SilkS) (width 0.15))
(fp_line (start 0.3175 -0.381) (end -0.3175 0) (layer B.SilkS) (width 0.15))
(fp_line (start -0.3175 0.508) (end -0.3175 -0.508) (layer B.SilkS) (width 0.15))
(fp_line (start -2.25 1.05) (end 2.25 1.05) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.25 1.05) (end 2.25 -1.05) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.25 -1.05) (end -2.25 -1.05) (layer B.CrtYd) (width 0.05))
(fp_line (start -2.25 1.05) (end -2.25 -1.05) (layer B.CrtYd) (width 0.05))
(fp_line (start -2 -0.9) (end 1.54 -0.9) (layer B.SilkS) (width 0.15))
(fp_line (start -2 0.9) (end 1.54 0.9) (layer B.SilkS) (width 0.15))
(pad 1 smd rect (at -1.635 0 270) (size 0.91 1.22) (layers B.Cu B.Paste B.Mask))
(pad 2 smd rect (at 1.635 0 270) (size 0.91 1.22) (layers B.Cu B.Paste B.Mask))
)
""",
"diode_DO-35": """(module Diode_DO-35_SOD27_Horizontal_RM10 locked (layer F.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr "Diode, DO-35, SOD27, Horizontal, RM 10mm")
(tags "Diode, DO-35, SOD27, Horizontal, RM 10mm, 1N4148,")
(fp_text reference {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer F.Fab) hide
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 7.36652 -0.00254) (end 8.76352 -0.00254) (layer F.SilkS) (width 0.15))
(fp_line (start 2.92152 -0.00254) (end 1.39752 -0.00254) (layer F.SilkS) (width 0.15))
(fp_line (start 3.30252 -0.76454) (end 3.30252 0.75946) (layer F.SilkS) (width 0.15))
(fp_line (start 3.04852 -0.76454) (end 3.04852 0.75946) (layer F.SilkS) (width 0.15))
(fp_line (start 2.79452 -0.00254) (end 2.79452 0.75946) (layer F.SilkS) (width 0.15))
(fp_line (start 2.79452 0.75946) (end 7.36652 0.75946) (layer F.SilkS) (width 0.15))
(fp_line (start 7.36652 0.75946) (end 7.36652 -0.76454) (layer F.SilkS) (width 0.15))
(fp_line (start 7.36652 -0.76454) (end 2.79452 -0.76454) (layer F.SilkS) (width 0.15))
(fp_line (start 2.79452 -0.76454) (end 2.79452 -0.00254) (layer F.SilkS) (width 0.15))
(pad 2 thru_hole circle (at 10.16052 -0.00254 180) (size 1.69926 1.69926) (drill 0.70104) (layers *.Cu *.Mask F.SilkS))
(pad 1 thru_hole rect (at 0.00052 -0.00254 180) (size 1.69926 1.69926) (drill 0.70104) (layers *.Cu *.Mask F.SilkS))
(model Diodes_ThroughHole.3dshapes/Diode_DO-35_SOD27_Horizontal_RM10.wrl
(at (xyz 0.2 0 0))
(scale (xyz 0.4 0.4 0.4))
(rotate (xyz 0 0 180))
)
)""",
"diode_MiniMELF": """(module Diodes_SMD:MiniMELF_Standard (layer B.Cu) (tedit {tedit}) (tstamp {tstamp})
(at {x_pos} {y_pos} {rotate})
(descr "Diode Mini-MELF Standard")
(tags "Diode Mini-MELF Standard")
(attr smd)
(fp_text reference {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer B.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value {reference} (at {label_x_pos} {label_y_pos} {label_rotate}) (layer B.Fab) hide
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -2.55 1) (end 2.55 1) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.55 1) (end 2.55 -1) (layer B.CrtYd) (width 0.05))
(fp_line (start 2.55 -1) (end -2.55 -1) (layer B.CrtYd) (width 0.05))
(fp_line (start -2.55 -1) (end -2.55 1) (layer B.CrtYd) (width 0.05))
(fp_line (start -0.40024 -0.0508) (end 0.60052 0.85) (layer B.SilkS) (width 0.15))
(fp_line (start 0.60052 0.85) (end 0.60052 -0.85) (layer B.SilkS) (width 0.15))
(fp_line (start 0.60052 -0.85) (end -0.40024 0) (layer B.SilkS) (width 0.15))
(fp_line (start -0.40024 0.85) (end -0.40024 -0.85) (layer B.SilkS) (width 0.15))
(pad 1 smd rect (at -1.75006 0 90) (size 1.30048 1.69926) (layers B.Cu B.Paste B.Mask))
(pad 2 smd rect (at 1.75006 0 90) (size 1.30048 1.69926) (layers B.Cu B.Paste B.Mask))
(model Diodes_SMD.3dshapes/MiniMELF_Standard.wrl
(at (xyz 0 0 0))
(scale (xyz 0.3937 0.3937 0.3937))
(rotate (xyz 0 0 0))
)
)
""",
}
schem_template_header = """EESchema Schematic File Version 2
LIBS:cherrymx
EELAYER 25 0
EELAYER END
$Descr A2 11693 8268
encoding utf-8
Sheet 1 1
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr"""
schem_template_footer = "$EndSCHEMATC"
project_template = """update=Friday, March 25, 2016 'PMt' 09:12:47 PM
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.040000000000
SolderMaskMinWidth=0.100000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[general]
version=1
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=../kicad-libs/device
LibName2=../kicad-libs/cherrymx
LibName3=device
"""
component_templates = {
"switch": u"""$Comp
L MX_LED %(ref)s
U %(pkg)d 1 %(timestamp)x
P %(x)d %(y)d
F 0 "%(ref)s" H %(x)d %(ref_y)d 60 0000 C CNN
F 1 "MX_LED" H %(x)d %(y)d 60 0001 C CNN
F 2 "" H %(x)d %(y)d 60 0000 C CNN
F 3 "" H %(x)d %(y)d 60 0000 C CNN
%(pkg)d %(x)d %(y)d
1 0 0 -1
$EndComp""",
"led": u"""$Comp
L MX_LED %(ref)s
U %(pkg)d 1 %(timestamp)x
P %(x)d %(y)d
F 0 "%(ref)s" H %(x)d %(ref_y)d 60 0000 C CNN
F 1 "MX_LED" H %(x)d %(y)d 60 0001 C CNN
F 2 "" H %(x)d %(y)d 60 0000 C CNN
F 3 "" H %(x)d %(y)d 60 0000 C CNN
%(pkg)d %(x)d %(y)d
0 1 1 0
$EndComp""",
"diode": u"""$Comp
L D D%(ref)s
U %(pkg)d 1 %(timestamp)x
P %(x)d %(y)d
F 0 "%(ref)s" H %(ref_x)d %(ref_y)d 60 0000 C CNN
F 1 "D" H %(x)d %(y)d 60 0001 C CNN
F 2 "" H %(x)d %(y)d 60 0000 C CNN
F 3 "" H %(x)d %(y)d 60 0000 C CNN
%(pkg)d %(x)d %(y)d
0 -1 -1 0
$EndComp"""
}
def add_to_schematic(schem, x, y, timestamp=None, reference=None):
if reference is None:
reference = "%d_%d" % (x, y)
schem.write(component_templates["switch"] % {
"x": int((x * sw_spacing + sw_x_origin) / 100) * 100,
"y": int((y * sw_spacing + sw_y_origin) / 100) * 100,
"ref_y": y * sw_spacing + sw_y_origin - 100,
"pkg": 1,
"ref": unicode(reference),
"timestamp": time() if timestamp is None else timestamp
})
schem.write(component_templates["led"] % {
"x": int((x * led_spacing + led_x_origin) / 100) * 100,
"y": int((y * led_spacing + led_y_origin) / 100) * 100,
"ref_y": y * led_spacing + led_y_origin - 150,
"pkg": 2,
"ref": unicode(reference),
"timestamp": time() if timestamp is None else timestamp + 1
})
schem.write(component_templates["diode"] % {
"x": int((x * sw_spacing + sw_x_origin) / 100) * 100 + 400,
"y": int((y * sw_spacing + sw_y_origin) / 100) * 100 + 150,
"ref_x": int((x * sw_spacing + sw_x_origin) / 100) * 100 + 400,
"ref_y": int((y * sw_spacing + sw_y_origin) / 100) * 100 + 250,
"pkg": 1,
"ref": unicode(reference.replace("SW_", "D")),
"timestamp": time() if timestamp is None else timestamp
})
def place_text_footprint(pcb_text, x, y, reference=None, i=None, timestamp=None):
if reference is None:
reference = "SW%d_%d" % (x, y)
pcb_text.write(footprints[footprint_name].format(
reference=unicode(reference),
x_pos=x * pcb_spacing,
y_pos=y * pcb_spacing,
rotate=switch_rotate,
tstamp=unicode(time() if timestamp is None else timestamp),
tedit=unicode(time() if timestamp is None else timestamp)
))
if i is not None:
reference = "D%d" % (i)
if reference is None:
reference = "D%d_%d" % (x, y)
pcb_text.write(footprints[diode_template].format(
reference=unicode(reference),
x_pos=x * pcb_spacing + diode_x_offset,
y_pos=y * pcb_spacing + diode_y_offset,
rotate=diode_rotate,
label_x_pos=diode_label_x_offset,
label_y_pos=diode_label_y_offset,
label_rotate=diode_label_rotate,
tstamp=unicode(time() if timestamp is None else timestamp),
tedit=unicode(time() if timestamp is None else timestamp)
))
def main():
if not os.path.exists(output_directory):
os.mkdir(output_directory)
if os.path.exists(project_file_name):
print "Project exists, destroy it (y/n)?"
if raw_input().lower() == "y":
with open(project_file_name, mode="w") as project_file:
project_file.write(project_template)
else:
with open(project_file_name, mode="w") as project_file:
project_file.write(project_template)
sch_name = schematic_file_name
if os.path.exists(sch_name):
print "Schematic exists, destroy it (y/n)?"
if raw_input().lower() == "n":
sch_name = os.devnull
switch_sch = codecs.open(sch_name, mode="w", encoding='utf-8')
pcb_name = pcb_file_name
if os.path.exists(pcb_name):
print "PCB exists, destroy it (y/n)?"
if raw_input().lower() == "n":
pcb_name = os.devnull
pcb_txt = codecs.open(pcb_name, mode="w", encoding='utf-8')
with open(layout_file_name) as layout_file:
layout = json.load(layout_file)
switch_sch.write(schem_template_header)
pcb_txt.write(pcb_header)
x, y = x_origin, y_origin
i = 1
timestamp = int(time())
for row in layout:
if not isinstance(row, list):
continue
x = x_origin
y_offset = 0.0
width = 1.0
for col in row:
if isinstance(col, dict):
y_offset = (float(col.get("h", 1)) - 1) / 2
width = float(col.get("w", 1))
x += float(col.get("x", 0))
y += float(col.get("y", 0))
elif isinstance(col, six.string_types):
ref = "SW_X%dY%d" % (x, y)
if col.split() and col.split()[0].isalnum():
ref = u"SW_" + col.split()[0]
ref += "_%d" % i
ref = "SW_%d" % i # just want them numbered by order
x_offset = (width - 1.0) / 2
place_text_footprint(pcb_txt, x + x_offset, y + y_offset, ref, i, timestamp + i)
add_to_schematic(switch_sch, x + x_offset, y + y_offset, timestamp + i, ref)
x += width
width = 1.0
i += 1
y += 1
switch_sch.write(schem_template_footer)
switch_sch.close()
pcb_txt.write(pcb_footer)
pcb_txt.close()
if __name__ == "__main__":
main()