1
# This python script wizard creates a FPC connector
2
# for Surface Mounted Technology
7
class FPCFootprintWizard(FootprintWizardPlugin):
9
FootprintWizardPlugin.__init__(self)
11
self.description = "FPC (SMTechnology) Footprint Wizard"
14
{"*n":40, # not internal units preceded by "*"
16
"width": FromMM(0.25),
17
"height": FromMM(1.6)},
19
{"shield_to_pad": FromMM(1.6),
20
"from_top": FromMM(1.3),
27
# build a rectangular pad
28
def smdRectPad(self,module,size,pos,name):
31
pad.SetShape(PAD_RECT)
32
pad.SetAttribute(PAD_SMD)
33
pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS)
39
# This method checks the parameters provided to wizard and set errors
40
def CheckParameters(self):
42
pads = p["Pads"]["*n"]
45
self.parameter_errors["Pads"]["n"]="Must be positive"
46
errors +="Pads/n has wrong value, "
47
p["Pads"]["n"] = int(pads) # make sure it stays as int (default is float)
49
pad_width = p["Pads"]["width"]
50
pad_height = p["Pads"]["height"]
51
pad_pitch = p["Pads"]["pitch"]
52
shl_width = p["Shield"]["width"]
53
shl_height = p["Shield"]["height"]
54
shl_to_pad = p["Shield"]["shield_to_pad"]
55
shl_from_top = p["Shield"]["from_top"]
60
# build the footprint from parameters
61
def BuildFootprint(self):
63
print "parameters:",self.parameters
65
#print "errors:",self.parameter_errors
67
module = MODULE(None) # create a new module
71
pads = int(p["Pads"]["*n"])
72
pad_width = p["Pads"]["width"]
73
pad_height = p["Pads"]["height"]
74
pad_pitch = p["Pads"]["pitch"]
75
shl_width = p["Shield"]["width"]
76
shl_height = p["Shield"]["height"]
77
shl_to_pad = p["Shield"]["shield_to_pad"]
78
shl_from_top = p["Shield"]["from_top"]
80
offsetX = pad_pitch*(pads-1)/2
81
size_pad = wxSize(pad_width,pad_height)
82
size_shld = wxSize(shl_width,shl_height)
83
size_text = wxSize( FromMM( 0.8), FromMM( 0.7) )
84
textposy = pad_height/2 + FromMM(1)
86
module.SetReference("FPC"+str(pads)) # give it a reference name
87
module.Reference().SetPos0(wxPoint(0, textposy))
88
module.Reference().SetTextPosition(module.Reference().GetPos0())
89
module.Reference().SetSize( size_text )
91
textposy = textposy + FromMM(1)
92
module.SetValue("Val***") # give it a default value
93
module.Value().SetPos0( wxPoint(0, textposy) )
94
module.Value().SetTextPosition(module.Value().GetPos0())
95
module.Value().SetSize( size_text )
97
module.SetLibRef("FPC"+str(pads)) #the name in library
99
# create a pad array and add it to the module
100
for n in range (0,pads):
101
xpos = pad_pitch*n - offsetX
102
pad = self.smdRectPad(module,size_pad,wxPoint(xpos,0),str(n+1))
106
xpos = -shl_to_pad-offsetX
107
pad_s0 = self.smdRectPad(module, size_shld, wxPoint(xpos,shl_from_top), "0")
108
xpos = (pads-1)*pad_pitch+shl_to_pad-offsetX
109
pad_s1 = self.smdRectPad(module, size_shld, wxPoint(xpos,shl_from_top), "0")
115
outline = EDGE_MODULE(module)
117
posy = -pad_height/2 - width/2 -FromMM(0.2)
118
outline.SetStartEnd(wxPoint(pad_pitch * pads - pad_pitch*0.5-offsetX, posy),
119
wxPoint( - pad_pitch*0.5-offsetX, posy))
120
outline.SetWidth(width)
121
outline.SetLayer(SILKSCREEN_N_FRONT) #default: not needed
122
outline.SetShape(S_SEGMENT)
125
outline1 = EDGE_MODULE(module)
126
outline1.Copy(outline) #copy all settings from outline
127
posy = pad_height/2 + width/2 +FromMM(0.2)
128
outline1.SetStartEnd(wxPoint(pad_pitch * pads - pad_pitch*0.5-offsetX, posy),
129
wxPoint( - pad_pitch*0.5-offsetX, posy))
133
# create our footprint wizard
134
fpc_wizard = FPCFootprintWizard()
136
# register it into pcbnew
137
fpc_wizard.register()