2012-05-05 20:18:47 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from pcbnew import *
|
|
|
|
|
|
|
|
class FPCFootprintWizard(FootprintWizardPlugin):
|
|
|
|
def __init__(self):
|
|
|
|
FootprintWizardPlugin.__init__(self)
|
|
|
|
self.name = "FPC"
|
|
|
|
self.description = "FPC Footprint Wizard"
|
|
|
|
self.parameters = {
|
|
|
|
"Pads":
|
2012-07-22 22:23:17 +00:00
|
|
|
{"*n":40, # not internal units preceded by "*"
|
|
|
|
"pitch": FromMM(0.5),
|
|
|
|
"width": FromMM(0.25),
|
|
|
|
"height": FromMM(1.6)},
|
2012-05-05 20:18:47 +00:00
|
|
|
"Shield":
|
2012-07-22 22:23:17 +00:00
|
|
|
{"shield_to_pad": FromMM(1.6),
|
|
|
|
"from_top": FromMM(1.3),
|
|
|
|
"width": FromMM(1.5),
|
|
|
|
"height": FromMM(2)},
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2012-05-16 09:35:18 +00:00
|
|
|
self.ClearErrors()
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-07-22 22:23:17 +00:00
|
|
|
# build a rectangular pad
|
2012-05-05 20:18:47 +00:00
|
|
|
def smdRectPad(self,module,size,pos,name):
|
|
|
|
pad = D_PAD(module)
|
|
|
|
pad.SetSize(size)
|
|
|
|
pad.SetShape(PAD_RECT)
|
|
|
|
pad.SetAttribute(PAD_SMD)
|
|
|
|
pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS)
|
|
|
|
pad.SetPos0(pos)
|
2012-05-10 20:49:07 +00:00
|
|
|
pad.SetPosition(pos)
|
2012-05-05 20:18:47 +00:00
|
|
|
pad.SetPadName(name)
|
|
|
|
return pad
|
2012-07-22 22:23:17 +00:00
|
|
|
|
|
|
|
# This method checks the parameters provided to wizard and set errors
|
2012-05-16 09:35:18 +00:00
|
|
|
def CheckParameters(self):
|
2013-03-17 01:18:09 +00:00
|
|
|
p = self.parameters
|
|
|
|
pads = p["Pads"]["*n"]
|
2012-05-16 09:35:18 +00:00
|
|
|
errors = ""
|
|
|
|
if (pads<1):
|
|
|
|
self.parameter_errors["Pads"]["n"]="Must be positive"
|
|
|
|
errors +="Pads/n has wrong value, "
|
2013-03-17 01:18:09 +00:00
|
|
|
p["Pads"]["n"] = int(pads) # make sure it stays as int (default is float)
|
|
|
|
|
2012-05-16 09:35:18 +00:00
|
|
|
pad_width = p["Pads"]["width"]
|
|
|
|
pad_height = p["Pads"]["height"]
|
|
|
|
pad_pitch = p["Pads"]["pitch"]
|
|
|
|
shl_width = p["Shield"]["width"]
|
|
|
|
shl_height = p["Shield"]["height"]
|
|
|
|
shl_to_pad = p["Shield"]["shield_to_pad"]
|
|
|
|
shl_from_top = p["Shield"]["from_top"]
|
2013-03-17 01:18:09 +00:00
|
|
|
|
|
|
|
return errors
|
|
|
|
|
|
|
|
|
|
|
|
# build the footprint from parameters
|
2012-05-05 20:18:47 +00:00
|
|
|
def BuildFootprint(self):
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-16 09:35:18 +00:00
|
|
|
print "parameters:",self.parameters
|
|
|
|
#self.ClearErrors()
|
|
|
|
#print "errors:",self.parameter_errors
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-16 09:35:18 +00:00
|
|
|
module = MODULE(None) # create a new module
|
|
|
|
self.module = module
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-10 20:49:07 +00:00
|
|
|
p = self.parameters
|
2013-03-17 01:18:09 +00:00
|
|
|
pads = int(p["Pads"]["*n"])
|
2012-05-10 20:49:07 +00:00
|
|
|
pad_width = p["Pads"]["width"]
|
|
|
|
pad_height = p["Pads"]["height"]
|
|
|
|
pad_pitch = p["Pads"]["pitch"]
|
|
|
|
shl_width = p["Shield"]["width"]
|
|
|
|
shl_height = p["Shield"]["height"]
|
|
|
|
shl_to_pad = p["Shield"]["shield_to_pad"]
|
|
|
|
shl_from_top = p["Shield"]["from_top"]
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-10 20:49:07 +00:00
|
|
|
size_pad = wxSize(pad_width,pad_height)
|
|
|
|
size_shld = wxSize(shl_width,shl_height)
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
module.SetReference("FPC"+str(pads)) # give it a reference name
|
2013-03-15 00:56:36 +00:00
|
|
|
module.Reference().SetPos0(wxPointMM(-1,-2))
|
|
|
|
module.Reference().SetPosition(wxPointMM(-1,-2))
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
# create a pad array and add it to the module
|
|
|
|
for n in range (0,pads):
|
2012-05-10 20:49:07 +00:00
|
|
|
pad = self.smdRectPad(module,size_pad,wxPoint(pad_pitch*n,0),str(n+1))
|
2012-05-05 20:18:47 +00:00
|
|
|
module.Add(pad)
|
2013-03-17 01:18:09 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
|
|
|
|
pad_s0 = self.smdRectPad(module,
|
|
|
|
size_shld,
|
2012-05-10 20:49:07 +00:00
|
|
|
wxPoint(-shl_to_pad,shl_from_top),
|
2012-05-05 20:18:47 +00:00
|
|
|
"0")
|
|
|
|
pad_s1 = self.smdRectPad(module,
|
|
|
|
size_shld,
|
2012-05-10 20:49:07 +00:00
|
|
|
wxPoint((pads-1)*pad_pitch+shl_to_pad,shl_from_top),
|
2013-03-17 01:18:09 +00:00
|
|
|
"0")
|
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
module.Add(pad_s0)
|
|
|
|
module.Add(pad_s1)
|
|
|
|
|
|
|
|
e = EDGE_MODULE(module)
|
2012-05-10 22:30:26 +00:00
|
|
|
e.SetStartEnd(wxPointMM(-1,0),wxPointMM(0,0))
|
2012-05-05 20:18:47 +00:00
|
|
|
e.SetWidth(FromMM(0.2))
|
|
|
|
e.SetLayer(EDGE_LAYER)
|
|
|
|
e.SetShape(S_SEGMENT)
|
|
|
|
module.Add(e)
|
|
|
|
|
|
|
|
module.SetLibRef("FPC"+str(pads))
|
2012-05-16 09:35:18 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
|
2013-03-17 01:18:09 +00:00
|
|
|
def register():
|
|
|
|
# create our footprint wizard
|
|
|
|
fpc_wizard = FPCFootprintWizard()
|
|
|
|
|
|
|
|
# register it into pcbnew
|
|
|
|
fpc_wizard.register()
|
|
|
|
|
|
|
|
return fpc_wizard
|
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
|