Newer
Older
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
from koko.lib.pcb import *
from koko.lib.sam import *
class TagConnectPDI(Component):
'''
'''
_pad = s2d.circle(0,0,.5*.031)
_via = s2d.circle(0,0,.5*.039)
pins = [
Pin(-.05,-.025,_pad,'CLK',label_size=.02),
Pin( .00,-.025,_pad,'NC',label_size=.02),
Pin( .05,-.025,_pad,'DAT',label_size=.02),
Pin(-.05,.025,_pad,'VCC',label_size=.02),
Pin( .00,.025,_pad,'NC',label_size=.02),
Pin( .05,.025,_pad,'GND',label_size=.02)
]
vias = [
Via(-.1,0,_via),
Via(.1,0.04,_via),
Via(.1,-.04,_via),
]
class Button(Component):
''' SW262CT-ND
'''
rect = rectangle(-.75/25.4,.75/25.4,-.5/25.4,.5/25.4)
pins = [
Pin(-2/25.4,.8/25.4,rect),
Pin( 2/25.4,.8/25.4,rect),
Pin(-2/25.4,-.8/25.4,rect),
Pin( 2/25.4,-.8/25.4,rect)
]
prefix = 'button'
vias = []
shadow = rectangle(-2.1/25.4,2.1/25.4,-1.4/25.4,1.4/25.4)
class TagConnectSWD(Component):
'''
'''
_pad = s2d.circle(0,0,.5*.031)
_via = s2d.circle(0,0,.5*.039)
pins = [
Pin(-.05,-.025,_pad,'GND',label_size=.012),
Pin( .00,-.025,_pad,'NC',label_size=.012),
Pin( .05,-.025,_pad,'VCC',label_size=.012),
Pin(-.05,.025,_pad,'RST',label_size=.012),
Pin( .00,.025,_pad,'SWDCLK',label_size=.012),
Pin( .05,.025,_pad,'SWDIO',label_size=.012)
]
vias = [
Via(-.1,0,_via),
Via(.1,0.04,_via),
Via(.1,-.04,_via),
]
class Regulator_SOT23(Component):
''' SOT23 voltage regulator
'''
_pad_SOT23 = s2d.rectangle(-.02,.02,-.012,.012)
pins = [
Pin(-0.045, -0.0375, _pad_SOT23,'IN'),
Pin(-0.045, 0.0375, _pad_SOT23,'OUT'),
Pin(0.045, 0, _pad_SOT23,'GND')
]
prefix = 'U'
vias = []
class Crystal_FC135(Component):
''' CRYSTAL 32.7680KHZ 12.5PF SMT
'''
_pad = s2d.rectangle(-.5/25.4,.5/25.4,-.9/25.4,.9/25.4)
pins = [
Pin(-1.25/25.4, 0, _pad),
Pin( 1.25/25.4, 0, _pad),
]
prefix = 'U'
vias = []
class Header_FTDI(Component):
''' FTDI cable header
'''
_pad_header = chamfered_rectangle(-0.06, 0.08,-0.035, 0.035,.007)
pins = [
Pin(0, 0.25, _pad_header, 'RTS'),
Pin(0, 0.15, _pad_header, 'RX'),
Pin(0, 0.05, _pad_header, 'TX'),
Pin(0, -0.05, _pad_header, 'VCC'),
Pin(0, -0.15, _pad_header, 'CTS'),
Pin(0, -0.25, _pad_header, 'GND')
]
prefix = 'J'
vias = []
shadow = s2d.rectangle(-.06,8/25.4,-.3,.3)
class Header_RPi_SWD(Component):
''' Header for Raspberry pi swd programming
'''
_pad_header = chamfered_rectangle(-0.06, 0.06,-0.04, 0.04,.007)
pins = [
Pin(0, 0.25, _pad_header, 'SWDCLK'),
Pin(0, 0.15, _pad_header, ''),
Pin(0, 0.05, _pad_header, 'SWDIO'),
Pin(0, -0.05, _pad_header, ''),
Pin(0, -0.15, _pad_header, 'GND'),
Pin(0, -0.25, _pad_header, 'nRST')
]
prefix = 'J'
vias = [Via(p.x,p.y,circle(0,0,.018)) for p in pins]
shadow = s2d.rectangle(-.07,.07,-.3,.3)
shadow = s2d.rectangle(-.07,.07,-.3,.3)
class Header_TC_SWD(Component):
''' Header for tag connect swd programming
'''
_pad_header = chamfered_rectangle(-0.04, 0.04,-0.04, 0.04,.007)
pins = [
Pin( .05, 0.1, _pad_header, 'SWDCLK'),
Pin( .05, 0.0, _pad_header, 'SWDIO'),
Pin( .05, -0.1, _pad_header, 'GND'),
Pin(-.05, 0.1, _pad_header, ''),
Pin(-.05, 0.0, _pad_header, ''),
Pin(-.05, -0.1, _pad_header, ''),
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
]
prefix = 'J'
vias = [Via(p.x,p.y,circle(0,0,.018)) for p in pins]
shadow = s2d.rectangle(-.1,.1,-.15,.15)
class Header_Daughter(Component):
''' FTDI cable header
'''
_pad_header = chamfered_rectangle(-0.03, 0.03,-0.015, 0.015,.002)
labels=['SDA','SCL','A4','A5']
pins = [ Pin(0,.05*(i-1.5),_pad_header,l) for i,l in enumerate(labels)]
prefix = 'J'
vias = [Via(p.x,p.y,circle(0,0,.017)) for p in pins]
shadow = s2d.rectangle(-.03,.03,-.1,.1)
def bot_chamfered_rectangle(x0,x1,y0,y1,c):
r = rectangle(x0,x1,y0,y1)
c1 = triangle(x0,y0,x0,y0+c,x0+c,y0)
c2 = triangle(x1,y1, x1, y1-c, x1-c, y1)
c3 = triangle(x0,y1, x0+c, y1, x0, y1-c)
c4 = triangle(x1,y0, x1-c, y0, x1, y0+c)
return r-c2-c3
class CR20XX(Component):
#coin cell battery, e.g. 2032
pins = [
Pin(0,0,circle(0,0,5./25.4),'-')
]
shadow = circle(0,0,10./25.4)
vias = []
class AAA(Component):
#AAA battery smd holder
pad = chamfered_rectangle(-.125,.125,-.12,.12,.05)
pins = [
Pin(1.21-.125,0,pad,'+',label_size=.08),
Pin(-1.21+.125,0,pad,'-',label_size=.08),
]
shadow = rectangle(-1.07,1.07,-.25,.25)
vias = [
Via(-1.21+.25,.209,circle(0,0,.039))
]
class MDBT42(Component):
#Raytach nrf52 module
p = .7/25.4
pad_hw = .15/25.4
pad_hh = .8/25.4
_padv = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
_padh = rectangle(-pad_hh,pad_hh,-pad_hw,pad_hw)
_padg = rectangle(-pad_hh,pad_hh,-.35/25.4,.4/25.4)
c= 5/25.4
start_y = 11.8/25.4
start_x = .8/25.4
y_os = .25
names = [
'GND1','SDA','SCL','P27','A4','A5','A6','A7','DEC4','DCC','VDD',
'GND2','XL1','XL2','P2','P3','P4','P5','P6','P7','P8','P9','P10','GND3',
'P11','P12','P13','P14','P15','P16','P17','P18','P19','P20','RESET','SWDCLK','SWDIO','P22','GND4'
]
pins = [Pin(-c,start_y-y_os,_padg,n,label_size=.018) for i,n in enumerate(names[:1])]
pins += [Pin(-c,start_y-3./25.4-i*p-y_os,_padh,n,label_size=.018) for i,n in enumerate(names[1:11])]
pins += [Pin(-c+start_x+i*p,-y_os,_padv,n,label_size=.018,label_rot=-90) for i,n in enumerate(names[11:24])]
pins += [Pin(c,start_y-.9/25.4-i*p-y_os,_padh,n,label_size=.018) for i,n in enumerate(names[24:38][::-1])]
pins += [Pin(c,start_y-y_os,_padg,n,label_size=.018) for i,n in enumerate(names[38:])]
vias = []
shadow = rectangle(-c,c,-y_os,start_y+4.2/25.4-y_os)
class BT832(Component):
#Fanstel BT832 nrf52 module
p = 1.1/25.4
pad_hw = .7/25.4
pad_hh = .35/25.4
_pad = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
c= 7/25.4
start_y = 1.1/25.4
y_os = .25
names = [
'SDA','SCL','XL1','XL2','AIN0','AIN1','NFC1','NFC2',
'VCC','GND','P13','P18','P20','RESET','SWDCLK','SWDIO'
]
pins = [Pin(-c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[:8][::-1])]
pins += [Pin(c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[8:16])]
vias = []
shadow = rectangle(-c,c,-y_os,16/25.4-y_os)
class BC832(Component):
#Fanstel BC832 micro nrf52 module
p = 1.1/25.4
pad_hw = .7/25.4
pad_hh = .35/25.4
_pad = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
c= 3.9/25.4
start_y = .618/25.4
y_os = .18
names = [
'P26/SDA','P27/SCL','XL1','XL2','AIN0','AIN1','P9/NFC1','P10/NFC2',
'VCC','GND','P13','P18','P20','RESET','SWDCLK','SWDIO'
]
pins = [Pin(-c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[:8][::-1])]
pins += [Pin(c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[8:16])]
vias = []
shadow = rectangle(-c,c,-y_os,8.8/25.4-y_os)
class Hole(Component):
pins = [Pin(0,0,circle(0,0,0.01))]
vias = [Via(0,0,circle(0,0,.5*2.1/25.4))]
tap = circle(0,0,.5*1.9/25.5)
width = .6
height = .45
pcb = PCB(0,0,width,height,chamfer_distance=.03)
def connectG(pin,dx,dy,width=.012):
'''
Convenience function for connecting to ground plane
'''
pcb.connectD(pin,[pin.x+dx,pin.y+dy],[pin.x+dx-.0001,pin.y+dy],width=width,sides=[0,1,1])
def connectS(pin,dx,dy,width=.012):
pcb.connectD(pin,[pin.x+dx+.0001,pin.y+dy],width=width)
def connectM(pin1,pin2,dx,width=.012):
pcb.connectD(pin1,[pin1.x+dx,pin1.y],pin2,width=width)
rpi = Header_RPi_SWD(.5*width,.35,90,'rpi')
pcb += rpi
tc = Header_TC_SWD(rpi.x-.02,rpi.y-.24,90,'tc')
pcb.connectH(tc['SWDCLK'],rpi['SWDCLK'])
pcb.connectH(tc['SWDIO'],rpi['SWDIO'])
#pcb.connectH(tc['nRST'],rpi['nRST'])
pcb.connectH(tc['GND'],rpi['GND'])
eps = .02
extra = rectangle(-eps,width+eps,-eps,height+eps)
cad.shapes = pcb.layout()
#cad.shape = pcb.traces+(pcb.cutout-pcb.cutout)+(extra-extra)
#cad.shape = pcb.cutout+(pcb.traces-pcb.traces)+(extra-extra)