Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
1cf52baa
Commit
1cf52baa
authored
Mar 17, 2013
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New register() method in plugins, used by the loader to handle runtime plugin reloading
parent
31a693cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
79 deletions
+85
-79
fpc_footprint_wizard.py
pcbnew/scripting/plugins/fpc_footprint_wizard.py
+30
-26
touch_slider_wizard.py
pcbnew/scripting/plugins/touch_slider_wizard.py
+55
-53
No files found.
pcbnew/scripting/plugins/fpc_footprint_wizard.py
View file @
1cf52baa
...
@@ -18,10 +18,10 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -18,10 +18,10 @@ class FPCFootprintWizard(FootprintWizardPlugin):
"from_top"
:
FromMM
(
1.3
),
"from_top"
:
FromMM
(
1.3
),
"width"
:
FromMM
(
1.5
),
"width"
:
FromMM
(
1.5
),
"height"
:
FromMM
(
2
)},
"height"
:
FromMM
(
2
)},
}
}
self
.
ClearErrors
()
self
.
ClearErrors
()
# build a rectangular pad
# build a rectangular pad
def
smdRectPad
(
self
,
module
,
size
,
pos
,
name
):
def
smdRectPad
(
self
,
module
,
size
,
pos
,
name
):
pad
=
D_PAD
(
module
)
pad
=
D_PAD
(
module
)
...
@@ -36,14 +36,14 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -36,14 +36,14 @@ class FPCFootprintWizard(FootprintWizardPlugin):
# This method checks the parameters provided to wizard and set errors
# This method checks the parameters provided to wizard and set errors
def
CheckParameters
(
self
):
def
CheckParameters
(
self
):
p
=
self
.
parameters
p
=
self
.
parameters
pads
=
p
[
"Pads"
][
"*n"
]
pads
=
p
[
"Pads"
][
"*n"
]
errors
=
""
errors
=
""
if
(
pads
<
1
):
if
(
pads
<
1
):
self
.
parameter_errors
[
"Pads"
][
"n"
]
=
"Must be positive"
self
.
parameter_errors
[
"Pads"
][
"n"
]
=
"Must be positive"
errors
+=
"Pads/n has wrong value, "
errors
+=
"Pads/n has wrong value, "
p
[
"Pads"
][
"n"
]
=
int
(
pads
)
# make sure it stays as int (default is float)
p
[
"Pads"
][
"n"
]
=
int
(
pads
)
# make sure it stays as int (default is float)
pad_width
=
p
[
"Pads"
][
"width"
]
pad_width
=
p
[
"Pads"
][
"width"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
...
@@ -51,22 +51,22 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -51,22 +51,22 @@ class FPCFootprintWizard(FootprintWizardPlugin):
shl_height
=
p
[
"Shield"
][
"height"
]
shl_height
=
p
[
"Shield"
][
"height"
]
shl_to_pad
=
p
[
"Shield"
][
"shield_to_pad"
]
shl_to_pad
=
p
[
"Shield"
][
"shield_to_pad"
]
shl_from_top
=
p
[
"Shield"
][
"from_top"
]
shl_from_top
=
p
[
"Shield"
][
"from_top"
]
return
errors
return
errors
# build the footprint from parameters
# build the footprint from parameters
def
BuildFootprint
(
self
):
def
BuildFootprint
(
self
):
print
"parameters:"
,
self
.
parameters
print
"parameters:"
,
self
.
parameters
#self.ClearErrors()
#self.ClearErrors()
#print "errors:",self.parameter_errors
#print "errors:",self.parameter_errors
module
=
MODULE
(
None
)
# create a new module
module
=
MODULE
(
None
)
# create a new module
self
.
module
=
module
self
.
module
=
module
p
=
self
.
parameters
p
=
self
.
parameters
pads
=
int
(
p
[
"Pads"
][
"*n"
])
pads
=
int
(
p
[
"Pads"
][
"*n"
])
pad_width
=
p
[
"Pads"
][
"width"
]
pad_width
=
p
[
"Pads"
][
"width"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
...
@@ -74,19 +74,19 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -74,19 +74,19 @@ class FPCFootprintWizard(FootprintWizardPlugin):
shl_height
=
p
[
"Shield"
][
"height"
]
shl_height
=
p
[
"Shield"
][
"height"
]
shl_to_pad
=
p
[
"Shield"
][
"shield_to_pad"
]
shl_to_pad
=
p
[
"Shield"
][
"shield_to_pad"
]
shl_from_top
=
p
[
"Shield"
][
"from_top"
]
shl_from_top
=
p
[
"Shield"
][
"from_top"
]
size_pad
=
wxSize
(
pad_width
,
pad_height
)
size_pad
=
wxSize
(
pad_width
,
pad_height
)
size_shld
=
wxSize
(
shl_width
,
shl_height
)
size_shld
=
wxSize
(
shl_width
,
shl_height
)
module
.
SetReference
(
"FPC"
+
str
(
pads
))
# give it a reference name
module
.
SetReference
(
"FPC"
+
str
(
pads
))
# give it a reference name
module
.
Reference
()
.
SetPos0
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPos0
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPosition
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPosition
(
wxPointMM
(
-
1
,
-
2
))
# create a pad array and add it to the module
# create a pad array and add it to the module
for
n
in
range
(
0
,
pads
):
for
n
in
range
(
0
,
pads
):
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
wxPoint
(
pad_pitch
*
n
,
0
),
str
(
n
+
1
))
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
wxPoint
(
pad_pitch
*
n
,
0
),
str
(
n
+
1
))
module
.
Add
(
pad
)
module
.
Add
(
pad
)
pad_s0
=
self
.
smdRectPad
(
module
,
pad_s0
=
self
.
smdRectPad
(
module
,
size_shld
,
size_shld
,
...
@@ -95,8 +95,8 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -95,8 +95,8 @@ class FPCFootprintWizard(FootprintWizardPlugin):
pad_s1
=
self
.
smdRectPad
(
module
,
pad_s1
=
self
.
smdRectPad
(
module
,
size_shld
,
size_shld
,
wxPoint
((
pads
-
1
)
*
pad_pitch
+
shl_to_pad
,
shl_from_top
),
wxPoint
((
pads
-
1
)
*
pad_pitch
+
shl_to_pad
,
shl_from_top
),
"0"
)
"0"
)
module
.
Add
(
pad_s0
)
module
.
Add
(
pad_s0
)
module
.
Add
(
pad_s1
)
module
.
Add
(
pad_s1
)
...
@@ -108,11 +108,15 @@ class FPCFootprintWizard(FootprintWizardPlugin):
...
@@ -108,11 +108,15 @@ class FPCFootprintWizard(FootprintWizardPlugin):
module
.
Add
(
e
)
module
.
Add
(
e
)
module
.
SetLibRef
(
"FPC"
+
str
(
pads
))
module
.
SetLibRef
(
"FPC"
+
str
(
pads
))
# create our footprint wizard
def
register
():
fpc_wizard
=
FPCFootprintWizard
()
# create our footprint wizard
fpc_wizard
=
FPCFootprintWizard
()
# register it into pcbnew
fpc_wizard
.
register
()
return
fpc_wizard
# register it into pcbnew
fpc_wizard
.
register
()
pcbnew/scripting/plugins/touch_slider_wizard.py
View file @
1cf52baa
...
@@ -10,15 +10,15 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -10,15 +10,15 @@ class TouchSliderWizard(FootprintWizardPlugin):
self
.
parameters
=
{
self
.
parameters
=
{
"Pads"
:
"Pads"
:
{
"*steps"
:
4
,
# not internal (measurement) units preceded by "*"
{
"*steps"
:
4
,
# not internal (measurement) units preceded by "*"
"*bands"
:
2
,
"*bands"
:
2
,
"width"
:
FromMM
(
10
),
"width"
:
FromMM
(
10
),
"length"
:
FromMM
(
50
),
"length"
:
FromMM
(
50
),
"clearance"
:
FromMM
(
1
)
"clearance"
:
FromMM
(
1
)
}
}
}
}
self
.
ClearErrors
()
self
.
ClearErrors
()
# build a rectangular pad
# build a rectangular pad
def
smdRectPad
(
self
,
module
,
size
,
pos
,
name
):
def
smdRectPad
(
self
,
module
,
size
,
pos
,
name
):
pad
=
D_PAD
(
module
)
pad
=
D_PAD
(
module
)
...
@@ -30,8 +30,8 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -30,8 +30,8 @@ class TouchSliderWizard(FootprintWizardPlugin):
pad
.
SetPosition
(
pos
)
pad
.
SetPosition
(
pos
)
pad
.
SetPadName
(
name
)
pad
.
SetPadName
(
name
)
return
pad
return
pad
def
smdTrianglePad
(
self
,
module
,
size
,
pos
,
name
,
up_down
=
1
,
left_right
=
0
):
def
smdTrianglePad
(
self
,
module
,
size
,
pos
,
name
,
up_down
=
1
,
left_right
=
0
):
pad
=
D_PAD
(
module
)
pad
=
D_PAD
(
module
)
pad
.
SetSize
(
wxSize
(
size
[
0
],
size
[
1
]))
pad
.
SetSize
(
wxSize
(
size
[
0
],
size
[
1
]))
...
@@ -47,30 +47,30 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -47,30 +47,30 @@ class TouchSliderWizard(FootprintWizardPlugin):
# This method checks the parameters provided to wizard and set errors
# This method checks the parameters provided to wizard and set errors
def
CheckParameters
(
self
):
def
CheckParameters
(
self
):
p
=
self
.
parameters
p
=
self
.
parameters
steps
=
p
[
"Pads"
][
"*steps"
]
steps
=
p
[
"Pads"
][
"*steps"
]
errors
=
""
errors
=
""
if
(
steps
<
1
):
if
(
steps
<
1
):
self
.
parameter_errors
[
"Pads"
][
"*steps"
]
=
"Must be positive"
self
.
parameter_errors
[
"Pads"
][
"*steps"
]
=
"Must be positive"
errors
+=
"Pads/*steps has wrong value"
errors
+=
"Pads/*steps has wrong value"
p
[
"Pads"
][
"*steps"
]
=
int
(
pads
)
# make sure it stays as int (default is float)
p
[
"Pads"
][
"*steps"
]
=
int
(
pads
)
# make sure it stays as int (default is float)
bands
=
p
[
"Pads"
][
"*bands"
]
bands
=
p
[
"Pads"
][
"*bands"
]
if
(
bands
<
1
):
if
(
bands
<
1
):
self
.
parameter_errors
[
"Pads"
][
"*bands"
]
=
"Must be positive"
self
.
parameter_errors
[
"Pads"
][
"*bands"
]
=
"Must be positive"
errors
+=
"Pads/*bands has wrong value"
errors
+=
"Pads/*bands has wrong value"
p
[
"Pads"
][
"*bands"
]
=
int
(
bands
)
# make sure it stays as int (default is float)
p
[
"Pads"
][
"*bands"
]
=
int
(
bands
)
# make sure it stays as int (default is float)
touch_width
=
p
[
"Pads"
][
"width"
]
touch_width
=
p
[
"Pads"
][
"width"
]
touch_length
=
p
[
"Pads"
][
"length"
]
touch_length
=
p
[
"Pads"
][
"length"
]
touch_clearance
=
p
[
"Pads"
][
"clearance"
]
touch_clearance
=
p
[
"Pads"
][
"clearance"
]
return
errors
# The start pad is made of a rectangular pad plus a couple of
return
errors
# The start pad is made of a rectangular pad plus a couple of
# triangular pads facing tips on the middle/right of the first
# triangular pads facing tips on the middle/right of the first
# rectangular pad
# rectangular pad
def
AddStartPad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
def
AddStartPad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
...
@@ -79,9 +79,9 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -79,9 +79,9 @@ class TouchSliderWizard(FootprintWizardPlugin):
size_pad
=
wxSize
(
step_length
/
2.0
+
(
step_length
/
3
),
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
+
(
step_length
/
3
),
touch_width
)
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
position
-
wxPoint
(
step_length
/
6
,
0
),
name
)
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
position
-
wxPoint
(
step_length
/
6
,
0
),
name
)
module
.
Add
(
pad
)
module
.
Add
(
pad
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
position
+
wxPoint
(
size_pad
[
0
]
/
2
,
size_pad
[
1
]
/
4
),
position
+
wxPoint
(
size_pad
[
0
]
/
2
,
size_pad
[
1
]
/
4
),
name
)
name
)
...
@@ -91,18 +91,18 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -91,18 +91,18 @@ class TouchSliderWizard(FootprintWizardPlugin):
name
name
,
-
1
)
,
-
1
)
module
.
Add
(
tp
)
module
.
Add
(
tp
)
# compound a "start pad" shape plus a triangle on the left, pointing to
# compound a "start pad" shape plus a triangle on the left, pointing to
# the previous touch-pad
# the previous touch-pad
def
AddMiddlePad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
def
AddMiddlePad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
module
=
self
.
module
module
=
self
.
module
step_length
=
step_length
-
clearance
step_length
=
step_length
-
clearance
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
position
,
name
)
pad
=
self
.
smdRectPad
(
module
,
size_pad
,
position
,
name
)
module
.
Add
(
pad
)
module
.
Add
(
pad
)
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
position
+
wxPoint
(
size_pad
[
0
]
/
2
,
size_pad
[
1
]
/
4
),
position
+
wxPoint
(
size_pad
[
0
]
/
2
,
size_pad
[
1
]
/
4
),
name
)
name
)
...
@@ -112,80 +112,82 @@ class TouchSliderWizard(FootprintWizardPlugin):
...
@@ -112,80 +112,82 @@ class TouchSliderWizard(FootprintWizardPlugin):
name
name
,
-
1
)
,
-
1
)
module
.
Add
(
tp
)
module
.
Add
(
tp
)
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
position
+
wxPoint
(
-
size_pad
[
0
],
0
),
position
+
wxPoint
(
-
size_pad
[
0
],
0
),
name
,
name
,
0
,
0
,
-
1
)
-
1
)
module
.
Add
(
tp
)
module
.
Add
(
tp
)
def
AddFinalPad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
def
AddFinalPad
(
self
,
position
,
touch_width
,
step_length
,
clearance
,
name
):
module
=
self
.
module
module
=
self
.
module
step_length
=
step_length
-
clearance
step_length
=
step_length
-
clearance
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
size_pad
=
wxSize
(
step_length
/
2.0
,
touch_width
)
pad
=
self
.
smdRectPad
(
module
,
pad
=
self
.
smdRectPad
(
module
,
wxSize
(
size_pad
[
0
]
+
(
step_length
/
3
),
size_pad
[
1
]),
wxSize
(
size_pad
[
0
]
+
(
step_length
/
3
),
size_pad
[
1
]),
position
+
wxPoint
(
step_length
/
6
,
0
),
position
+
wxPoint
(
step_length
/
6
,
0
),
name
)
name
)
module
.
Add
(
pad
)
module
.
Add
(
pad
)
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
tp
=
self
.
smdTrianglePad
(
module
,
wxSize
(
size_pad
[
0
],
size_pad
[
1
]
/
2
),
position
+
wxPoint
(
-
size_pad
[
0
],
0
),
position
+
wxPoint
(
-
size_pad
[
0
],
0
),
name
,
name
,
0
,
0
,
-
1
)
-
1
)
module
.
Add
(
tp
)
module
.
Add
(
tp
)
def
AddStrip
(
self
,
pos
,
steps
,
touch_width
,
step_length
,
touch_clearance
):
def
AddStrip
(
self
,
pos
,
steps
,
touch_width
,
step_length
,
touch_clearance
):
self
.
AddStartPad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
"1"
)
self
.
AddStartPad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
"1"
)
for
n
in
range
(
2
,
steps
):
for
n
in
range
(
2
,
steps
):
pos
=
pos
+
wxPoint
(
step_length
,
0
)
pos
=
pos
+
wxPoint
(
step_length
,
0
)
self
.
AddMiddlePad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
str
(
n
))
self
.
AddMiddlePad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
str
(
n
))
pos
=
pos
+
wxPoint
(
step_length
,
0
)
pos
=
pos
+
wxPoint
(
step_length
,
0
)
self
.
AddFinalPad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
str
(
steps
))
self
.
AddFinalPad
(
pos
,
touch_width
,
step_length
,
touch_clearance
,
str
(
steps
))
# build the footprint from parameters
# build the footprint from parameters
def
BuildFootprint
(
self
):
def
BuildFootprint
(
self
):
module
=
MODULE
(
None
)
# create a new module
module
=
MODULE
(
None
)
# create a new module
self
.
module
=
module
self
.
module
=
module
p
=
self
.
parameters
p
=
self
.
parameters
steps
=
int
(
p
[
"Pads"
][
"*steps"
])
steps
=
int
(
p
[
"Pads"
][
"*steps"
])
bands
=
int
(
p
[
"Pads"
][
"*bands"
])
bands
=
int
(
p
[
"Pads"
][
"*bands"
])
touch_width
=
p
[
"Pads"
][
"width"
]
touch_width
=
p
[
"Pads"
][
"width"
]
touch_length
=
p
[
"Pads"
][
"length"
]
touch_length
=
p
[
"Pads"
][
"length"
]
touch_clearance
=
p
[
"Pads"
][
"clearance"
]
touch_clearance
=
p
[
"Pads"
][
"clearance"
]
step_length
=
float
(
touch_length
)
/
float
(
steps
)
step_length
=
float
(
touch_length
)
/
float
(
steps
)
module
.
SetReference
(
"TS"
+
str
(
steps
))
# give it a reference name
module
.
SetReference
(
"TS"
+
str
(
steps
))
# give it a reference name
module
.
Reference
()
.
SetPos0
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPos0
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPosition
(
wxPointMM
(
-
1
,
-
2
))
module
.
Reference
()
.
SetPosition
(
wxPointMM
(
-
1
,
-
2
))
# starting pad
# starting pad
pos
=
wxPointMM
(
0
,
0
)
pos
=
wxPointMM
(
0
,
0
)
band_width
=
touch_width
/
bands
band_width
=
touch_width
/
bands
for
b
in
range
(
bands
):
for
b
in
range
(
bands
):
self
.
AddStrip
(
pos
,
steps
,
band_width
,
step_length
,
touch_clearance
)
self
.
AddStrip
(
pos
,
steps
,
band_width
,
step_length
,
touch_clearance
)
pos
+=
wxPoint
(
0
,
band_width
)
pos
+=
wxPoint
(
0
,
band_width
)
module
.
SetLibRef
(
"S"
+
str
(
steps
))
# create our footprint wizard
module
.
SetLibRef
(
"S"
+
str
(
steps
))
touch_slider_wizard
=
TouchSliderWizard
()
def
register
():
# create our footprint wizard
touch_slider_wizard
=
TouchSliderWizard
()
# register it into pcbnew
touch_slider_wizard
.
register
()
return
touch_slider_wizard
# register it into pcbnew
touch_slider_wizard
.
register
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment