Skip to content

Commit

Permalink
Overwritten the plugin with V2 version
Browse files Browse the repository at this point in the history
  • Loading branch information
MitjaNemec committed Jul 13, 2018
1 parent 3b37abd commit 3cb3f91
Show file tree
Hide file tree
Showing 11 changed files with 1,058 additions and 391 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ This plugin has been developed as a complex plugin according the [Python Plugin

Within the plugin folder only *.py files are required for operation.

This plugin swaps two pads (in layout) and coresponding pins (in schematics). The pins in the shematics have to be connected to local or global label or hierarchical label either directly at the symbol or through a short wire segment. Eeschema has to be closed when the plugin is executed in pcbnew.
Once the plugin is done, save the layout, as the undo will only undo the layout leaving schematics in changed state. In order to undo the operation, you have to run the plugin again. The plugin does not work across multi unit parts and/or across different hierarchical levels.
This plugin swaps two pads (in layout) and coresponding pins (in schematics). The pins in the shematics have to be connected to local or global label or hierarchical label either directly or through short wire segment. The plugin also works across multi unit parts and/or across different hierarchical levels.

Example of pin swaping
Only one pin can be connected. Currently "no connection" flags are not supported. Eeschema has to be closed when the plugin is executed in pcbnew. Once the plugin is done, save the layout, as the undo will only undo the layout leaving schematics in changed state. In order to undo the operation, you have to run the plugin again.

Example of pin swaping
![swaping of pins on local labels](https://raw.githubusercontent.com/MitjaNemec/Kicad_action_plugins/master/screenshots/Swap_pins_animation.gif)

## Swap units
Expand Down
Binary file modified screenshots/Swap_pins_animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 23 additions & 12 deletions swap_pins/Level_2.sch
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ F 3 "http://ww1.microchip.com/downloads/en/DeviceDoc/39564c.pdf" H 3200 3450 50
1 3200 3800
1 0 0 -1
$EndComp
Wire Wire Line
4200 2900 4500 2900
Wire Wire Line
4200 3000 4500 3000
Wire Wire Line
4200 3100 4500 3100
Wire Wire Line
4200 3200 4500 3200
Wire Wire Line
3100 5100 3100 5200
Wire Wire Line
Expand Down Expand Up @@ -73,12 +65,31 @@ F 3 "" H 3100 2300 50 0001 C CNN
1 3100 2300
1 0 0 -1
$EndComp
Text HLabel 4500 2900 2 50 Input ~ 0
Text HLabel 4200 2900 2 50 Input ~ 0
RC1
Text HLabel 4500 3000 2 50 Input ~ 0
Text HLabel 4200 3000 2 50 Input ~ 0
RC2
Text HLabel 4500 3100 2 50 Input ~ 0
Text HLabel 4200 3100 2 50 Input ~ 0
RC3
Text HLabel 4500 3200 2 50 Input ~ 0
Text HLabel 4200 3200 2 50 Input ~ 0
RC4
$Comp
L Amplifier_Operational:LM324 U1
U 3 1 5B34BA87
P 4550 5550
F 0 "U1" H 4550 5750 50 0000 L CNN
F 1 "LM324" H 4550 5350 50 0000 L CNN
F 2 "" H 4500 5650 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/lm2902-n.pdf" H 4600 5750 50 0001 C CNN
3 4550 5550
1 0 0 -1
$EndComp
Wire Wire Line
4250 5650 4050 5650
Text GLabel 4050 5650 0 50 Input ~ 0
A4
Wire Wire Line
4250 5450 4050 5450
Text GLabel 4050 5450 0 50 Input ~ 0
A5
$EndSCHEMATC
14 changes: 7 additions & 7 deletions swap_pins/action_swap_pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def Run(self):

# set up logger
logging.basicConfig(level=logging.DEBUG,
filename="swap_pins.log",
filename="swap_pins_V2.log",
filemode='w',
format='%(asctime)s %(name)s %(lineno)d:%(message)s',
datefmt='%m-%d %H:%M:%S',
disable_existing_loggers=False)
logger = logging.getLogger(__name__)
logger.info("Action plugin Swap pins started")
logger.info("Action plugin Swap pins V2 started")

stdout_logger = logging.getLogger('STDOUT')
sl = StreamToLogger(stdout_logger, logging.INFO)
Expand All @@ -71,14 +71,14 @@ def Run(self):
sl = StreamToLogger(stderr_logger, logging.ERROR)
sys.stderr = sl

caption = 'Swap pins'
caption = 'Swap pins V2'
message = "Is eeschema closed?"
dlg = wx.MessageDialog(_pcbnew_frame, message, caption, wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
res = dlg.ShowModal()
dlg.Destroy()

if res == wx.ID_NO:
caption = 'Swap pins'
caption = 'Swap pins V2'
message = "You need to close eeschema and then run the plugin again!"
dlg = wx.MessageDialog(_pcbnew_frame, message, caption, wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
Expand All @@ -89,7 +89,7 @@ def Run(self):
# check if there are precisely two pads selected
selected_pads = filter(lambda x: x.IsSelected(), pcbnew.GetBoard().GetPads())
if len(selected_pads) != 2:
caption = 'Swap pins'
caption = 'Swap pins V2'
message = "More or less than 2 pads selected. Please select exactly two pads and run the script again"
dlg = wx.MessageDialog(_pcbnew_frame, message, caption, wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
Expand All @@ -101,7 +101,7 @@ def Run(self):
pad1 = selected_pads[0]
pad2 = selected_pads[1]
if pad1.GetParent().GetReference() != pad2.GetParent().GetReference():
caption = 'Swap pins'
caption = 'Swap pins V2'
message = "Pads don't belong to the same footprint"
dlg = wx.MessageDialog(_pcbnew_frame, message, caption, wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
Expand All @@ -110,7 +110,7 @@ def Run(self):
return

# swap pins
swap_pins.swap(board, pad1, pad2)
swap_pins_v2.swap(board, pad1, pad2)


class StreamToLogger(object):
Expand Down
29 changes: 17 additions & 12 deletions swap_pins/level_1.sch
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,13 @@ F 3 "" H 2800 1750 50 0001 C CNN
1 2800 1750
1 0 0 -1
$EndComp
Wire Wire Line
3800 3400 4100 3400
Wire Wire Line
3800 3500 4100 3500
Wire Wire Line
3800 3600 4100 3600
Wire Wire Line
3800 3700 4100 3700
Text Label 4100 3400 0 50 ~ 0
Text Label 3800 3400 0 50 ~ 0
RD1
Text Label 4100 3500 0 50 ~ 0
Text Label 3800 3500 0 50 ~ 0
RD2
Text Label 4100 3600 0 50 ~ 0
Text Label 3800 3600 0 50 ~ 0
RD3
Text Label 4100 3700 0 50 ~ 0
Text Label 3800 3700 0 50 ~ 0
RD4
$Comp
L Device:R R1
Expand Down Expand Up @@ -289,4 +281,17 @@ Wire Wire Line
8900 3000 9750 3000
Wire Wire Line
8900 3300 9750 3300
Text GLabel 4900 4850 2 50 Input ~ 0
A1
$Comp
L Amplifier_Operational:LM324 U1
U 2 1 5B34B8B0
P 4600 4850
F 0 "U1" H 4600 5050 50 0000 L CNN
F 1 "LM324" H 4600 4650 50 0000 L CNN
F 2 "" H 4550 4950 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/lm2902-n.pdf" H 4650 5050 50 0001 C CNN
2 4600 4850
1 0 0 -1
$EndComp
$EndSCHEMATC
Loading

0 comments on commit 3cb3f91

Please sign in to comment.