← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] IPC-7351 Footprint wizard

 

On 27/04/14 20:18, Francesco Del Degan wrote:
> 
> Yes, I will try to reuse the helper classes that was committed few days ago,
> and fix some issues with it. (I just discovered that actual BGA
> footprint uses all
> 26 letters, but only ABCDEFGHJKLMNPRTUVWY should be allowed) . 

My bad, thanks for catching it! Patch attached, which also fixed a
transposition of the row/col parameters for BGA. This patch will allow
any alphabet to be used by the underlying helper function, the BGA
wizard provides the one you gave above.

>  Chip Resistor, Capacitor and Inductor 
>  Aluminum Electrolytic Capacitors 
>  Tantalum Capacitor 
>  Molded Inductor 
>  Wire Wound Inductor 
>  Molded Resistor, Diode 
>  TO Packages
>  Oscillators and Chip Array’s
>  QFN 
>  SOJ 
>  PLCC 
>  SOT 
>  MELF 
>  LCC 
>  CFP
>  CQFP
>  BGA 
>  QFP 
>  SQFP 
>  TQFP 
>  SOIC 
>  SOP 
>  TSOP
> TSSOP 

A lot of these should be very easily doable by subclassing from the
current SOIC wizard and implementing new default values.

> On Sun, Apr 27, 2014 at 08:01:00PM +0200, jp charras wrote:
>>     Be careful with wxPython when it is used in Pcbnew: today we have some
>>     troubles with it:
>>    - It does not work on Windows (at least for me)
>>     - It has serious issues (crashes) (not yet fixed) on Linux.
>>    (I do not know the status on OSX)

I did the wizard helpers on the pre-kiway branch of the repo, as the
trunk at that time (haven't tried it since) crashed immediately on
start otherwise. It seemed pretty stable on Linux Mint 15 and 16, 64
bit, FWIW.

> I'm also very interested, at the end, to bring python support more
> deeply (and stable) into kicad itself

Me too, but I have not got around to looking at the C++ side of the
plugin fence yet.

Something that would be handy would be a way to pass strings into the
parameter map. Also, a fixed list of items that is presented in KiCad as
a drop-down would be useful too.

Cheers,

John
diff --git a/pcbnew/scripting/plugins/PadArray.py b/pcbnew/scripting/plugins/PadArray.py
index 99fa70e..3c5d5f7 100644
--- a/pcbnew/scripting/plugins/PadArray.py
+++ b/pcbnew/scripting/plugins/PadArray.py
@@ -75,13 +75,14 @@ class PadGridArray(PadArray):
 
     # handy utility function 1 - A, 2 - B, 26 - AA, etc
     # aIndex = 0 for 0 - A
-    def AlphaNameFromNumber(self, n, aIndex = 1):
+    # alphabet = set of allowable chars if not A-Z, eg ABCDEFGHJKLMNPRTUVWY for BGA
+    def AlphaNameFromNumber(self, n, aIndex = 1, alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
 
-        div, mod = divmod(n - aIndex, 26)
-        alpha = chr(65 + mod)
+        div, mod = divmod(n - aIndex, len(alphabet))
+        alpha = alphabet[mod]
 
         if div > 0:
-            return self.AlphaNameFromNumber(div) + alpha;
+            return self.AlphaNameFromNumber(div, aIndex, alphabet) + alpha;
 
         return alpha;
 
diff --git a/pcbnew/scripting/plugins/bga_wizard.py b/pcbnew/scripting/plugins/bga_wizard.py
index 7fd6258..36a86eb 100644
--- a/pcbnew/scripting/plugins/bga_wizard.py
+++ b/pcbnew/scripting/plugins/bga_wizard.py
@@ -24,7 +24,7 @@ import PadArray as PA
 class BGAPadGridArray(PA.PadGridArray):
 
     def NamingFunction(self, x, y):
-        return "%s%d" % (self.AlphaNameFromNumber(y + 1), x + 1)
+        return "%s%d" % (self.AlphaNameFromNumber(y + 1, alphabet="ABCDEFGHJKLMNPRTUVWY"), x + 1)
 
 
 class BGAWizard(HFPW.HelpfulFootprintWizardPlugin):
@@ -79,7 +79,7 @@ class BGAWizard(HFPW.HelpfulFootprintWizardPlugin):
         pin1Pos = pcbnew.wxPoint(-((rows - 1) * pad_pitch) / 2,
                                 -((cols - 1) * pad_pitch) / 2)
 
-        array = BGAPadGridArray(pad, rows, cols, pad_pitch, pad_pitch, pin1Pos)
+        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch, pin1Pos)
         array.AddPadsToModule()
 
         #box

Follow ups

References