Dear All,Nowadays I find lot of datasheets, in which the dimensions are appear only in metric system. I don't know whether any of you interested in creating footprints in mm instead of mil or mil/100, but it was a nightmare for me to calculate every value from metric to English units.
So I made a really simple patch of parse_y.y, by which I can use um (micrometer) to specify the items. The format is same as in "[" "]" case but the specifier is "<" and ">". All the other thing is the same.
Since the ratio between mil/100 and um is floating point and the parser file user these values as integer, there is a minor error during conversion. This is still an issue, but I can live with it.
In the hope that someone find it useful (and that I did not break the rules of parsing the original format), I would like to share this patch.
The modification based on the latest cvs checkout. I would like to know your opinion, so please tell me if you like/dislike it. It isn't tested well, I just created one footprint with it (attached). Regards, /sza2
--- parse_y.y.old 2008-03-16 15:33:59.000000000 +0100 +++ parse_y.y.new 2008-06-10 22:36:55.000000000 +0200 @@ -63,6 +63,8 @@ RCSID("$Id: parse_y.y,v 1.43 2008/03/16 14:33:59 danmc Exp $"); +#define UM 3.937007874016 + static LayerTypePtr Layer; static PolygonTypePtr Polygon; static SymbolTypePtr Symbol; @@ -285,6 +287,7 @@ @syntax PCB ["Name" Width Height] +PCB <"Name" Width Height> PCB ("Name" Width Height] PCB ("Name") @end syntax @@ -320,6 +323,12 @@ yyPCB->MaxWidth = $4; yyPCB->MaxHeight = $5; } + | T_PCB '<' STRING NUMBER NUMBER '>' + { + yyPCB->Name = $3; + yyPCB->MaxWidth = $4*UM; + yyPCB->MaxHeight = $5*UM; + } ; /* %start-doc pcbfile Grid @@ -694,6 +703,7 @@ via : via_hi_format + | via_um_format | via_2.0_format | via_1.7_format | via_newformat @@ -704,6 +714,7 @@ @syntax Via [X Y Thickness Clearance Mask Drill "Name" SFlags] +Via <X Y Thickness Clearance Mask Drill "Name" SFlags> Via (X Y Thickness Clearance Mask Drill "Name" NFlags) Via (X Y Thickness Clearance Drill "Name" NFlags) Via (X Y Thickness Drill "Name" NFlags) @@ -740,6 +751,15 @@ } ; +via_um_format + /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ + : T_VIA '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags '>' + { + CreateNewVia(yyData, $3*UM, $4*UM, $5*UM, $6*UM, $7*UM, $8*UM, $9, $10); + SaveFree($9); + } + ; + via_2.0_format /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')' @@ -792,6 +812,7 @@ @syntax Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags] +Rat <X1 Y1 Group1 X2 Y2 Group2 SFlags> Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags) @end syntax @@ -814,6 +835,11 @@ CreateNewRat(yyData, $3, $4, $6, $7, $5, $8, Settings.RatThickness, $9); } + | T_RAT '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags '>' + { + CreateNewRat(yyData, $3*UM, $4*UM, $6*UM, $7*UM, $5, $8, + Settings.RatThickness, $9); + } | T_RAT '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')' { CreateNewRat(yyData, $3*100, $4*100, $6*100, $7*100, $5, $8, @@ -880,9 +906,11 @@ layerdefinition : line_hi_format + | line_um_format | line_1.7_format | line_oldformat | arc_hi_format + | arc_um_format | arc_1.7_format | arc_oldformat /* x1, y1, x2, y2, flags */ @@ -892,6 +920,7 @@ $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags($7)); } | text_hi_format + | text_um_format | text_newformat | text_oldformat /* flags are passed in */ @@ -924,6 +953,7 @@ @syntax Line [X1 Y1 X2 Y2 Thickness Clearance SFlags] +Line <X1 Y1 X2 Y2 Thickness Clearance SFlags> Line (X1 Y1 X2 Y2 Thickness Clearance NFlags) Line (X1 Y1 X2 Y2 Thickness NFlags) @end syntax @@ -954,6 +984,14 @@ } ; +line_um_format + /* x1, y1, x2, y2, thickness, clearance, flags */ + : T_LINE '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags '>' + { + CreateNewLineOnLayer(Layer, $3*UM, $4*UM, $5*UM, $6*UM, $7*UM, $8*UM, $9); + } + ; + line_1.7_format /* x1, y1, x2, y2, thickness, clearance, flags */ : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')' @@ -978,6 +1016,7 @@ @syntax Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags] +Arc <X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags> Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags) Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags) @end syntax @@ -1019,6 +1058,14 @@ } ; +arc_um_format + /* x, y, width, height, thickness, clearance, startangle, delta, flags */ + : T_ARC '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags '>' + { + CreateNewArcOnLayer(Layer, $3*UM, $4*UM, $5*UM, $6*UM, $9*UM, $10*UM, $7, $8, $11); + } + ; + arc_1.7_format /* x, y, width, height, thickness, clearance, startangle, delta, flags */ : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')' @@ -1041,6 +1088,7 @@ @syntax Text [X Y Direction Scale "String" SFlags] +Text <X Y Direction Scale "String" SFlags> Text (X Y Direction Scale "String" NFlags) Text (X Y Direction "String" NFlags) @end syntax @@ -1117,6 +1165,30 @@ } ; +text_um_format + /* x, y, direction, scale, text, flags */ + : T_TEXT '<' NUMBER NUMBER NUMBER NUMBER STRING flags '>' + { + /* FIXME: shouldn't know about .f */ + /* I don't think this matters because anything with hi_format + * will have the silk on its own layer in the file rather + * than using the ONSILKFLAG and having it in a copper layer. + * Thus there is no need for anything besides the 'else' + * part of this code. + */ + if ($8.f & ONSILKFLAG) + { + LayerTypePtr lay = &yyData->Layer[yyData->LayerN + + (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; + + CreateNewText(lay, yyFont, $3*UM, $4*UM, $5, $6, $7, $8); + } + else + CreateNewText(Layer, yyFont, $3*UM, $4*UM, $5, $6, $7, $8); + SaveFree($7); + } + ; + /* %start-doc pcbfile Polygon @syntax @@ -1157,6 +1229,7 @@ @syntax Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] ( +Element <SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags> ( Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) ( Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) ( Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) ( @@ -1212,6 +1285,7 @@ | element_newformat | element_1.7_format | element_hi_format + | element_um_format ; element_oldformat @@ -1311,10 +1385,32 @@ } ; +element_um_format + /* element_flags, description, pcb-name, value, mark_x, mark_y, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '<' flags STRING STRING STRING NUMBER NUMBER + NUMBER NUMBER NUMBER NUMBER flags '>' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, $3, + $4, $5, $6, ($7+$9)*UM, ($8+$10)*UM, $11, $12, $13, False); + yyElement->MarkX = $7*UM; + yyElement->MarkY = $8*UM; + SaveFree($4); + SaveFree($5); + SaveFree($6); + } + relementdefs ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + /* %start-doc pcbfile ElementLine @syntax ElementLine [X1 Y1 X2 Y2 Thickness] +ElementLine <X1 Y1 X2 Y2 Thickness> ElementLine (X1 Y1 X2 Y2 Thickness) @end syntax @@ -1333,6 +1429,7 @@ @syntax ElementArc [X Y Width Height StartAngle DeltaAngle Thickness] +ElementArc <X Y Width Height StartAngle DeltaAngle Thickness> ElementArc (X Y Width Height StartAngle DeltaAngle Thickness) @end syntax @@ -1362,6 +1459,7 @@ @syntax Mark [X Y] +Mark <X Y> Mark (X Y) @end syntax @@ -1390,6 +1488,11 @@ CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7); } /* x1, y1, x2, y2, thickness */ + | T_ELEMENTLINE '<' NUMBER NUMBER NUMBER NUMBER NUMBER '>' + { + CreateNewLineInElement(yyElement, $3*UM, $4*UM, $5*UM, $6*UM, $7*UM); + } + /* x1, y1, x2, y2, thickness */ | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')' { CreateNewLineInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7*100); @@ -1400,6 +1503,11 @@ CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9); } /* x, y, width, height, startangle, anglediff, thickness */ + | T_ELEMENTARC '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER '>' + { + CreateNewArcInElement(yyElement, $3*UM, $4*UM, $5*UM, $6*UM, $7, $8, $9*UM); + } + /* x, y, width, height, startangle, anglediff, thickness */ | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')' { CreateNewArcInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100); @@ -1410,6 +1518,11 @@ yyElement->MarkX = $3; yyElement->MarkY = $4; } + | T_MARK '<' NUMBER NUMBER '>' + { + yyElement->MarkX = $3*UM; + yyElement->MarkY = $4*UM; + } | T_MARK '(' NUMBER NUMBER ')' { yyElement->MarkX = $3*100; @@ -1426,8 +1539,10 @@ relementdef : pin_1.7_format | pin_hi_format + | pin_um_format | pad_1.7_format | pad_hi_format + | pad_um_format /* x1, y1, x2, y2, thickness */ | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']' { @@ -1435,6 +1550,12 @@ $4 + yyElement->MarkY, $5 + yyElement->MarkX, $6 + yyElement->MarkY, $7); } + | T_ELEMENTLINE '<' NUMBER NUMBER NUMBER NUMBER NUMBER '>' + { + CreateNewLineInElement(yyElement, $3*UM + yyElement->MarkX, + $4*UM + yyElement->MarkY, $5*UM + yyElement->MarkX, + $6*UM + yyElement->MarkY, $7*UM); + } | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')' { CreateNewLineInElement(yyElement, $3*100 + yyElement->MarkX, @@ -1447,6 +1568,11 @@ CreateNewArcInElement(yyElement, $3 + yyElement->MarkX, $4 + yyElement->MarkY, $5, $6, $7, $8, $9); } + | T_ELEMENTARC '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER '>' + { + CreateNewArcInElement(yyElement, $3*UM + yyElement->MarkX, + $4*UM + yyElement->MarkY, $5*UM, $6*UM, $7, $8, $9*UM); + } | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')' { CreateNewArcInElement(yyElement, $3*100 + yyElement->MarkX, @@ -1459,6 +1585,7 @@ @syntax Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags] +Pin <rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags> Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags) Pin (aX aY Thickness Drill "Name" "Number" NFlags) Pin (aX aY Thickness Drill "Name" NFlags) @@ -1502,6 +1629,18 @@ SaveFree($10); } ; +pin_um_format + /* x, y, thickness, clearance, mask, drilling hole, name, + number, flags */ + : T_PIN '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags '>' + { + CreateNewPin(yyElement, $3*UM + yyElement->MarkX, + $4*UM + yyElement->MarkY, $5*UM, $6*UM, $7*UM, $8*UM, $9, + $10, $11); + SaveFree($9); + SaveFree($10); + } + ; pin_1.7_format /* x, y, thickness, clearance, mask, drilling hole, name, number, flags */ @@ -1565,6 +1704,7 @@ @syntax Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags] +Pad <rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags> Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags) Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags) Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags) @@ -1610,6 +1750,20 @@ } ; +pad_um_format + /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ + : T_PAD '<' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags '>' + { + CreateNewPad(yyElement, $3*UM + yyElement->MarkX, + $4*UM + yyElement->MarkY, + $5*UM + yyElement->MarkX, + $6*UM + yyElement->MarkY, $7*UM, $8*UM, $9*UM, + $10, $11, $12); + SaveFree($10); + SaveFree($11); + } + ; + pad_1.7_format /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')' @@ -1725,6 +1879,7 @@ symboldefinitions : symboldefinition | hiressymbol + | umressymbol | ; @@ -1732,6 +1887,7 @@ @syntax SymbolLine [X1 Y1 X2 Y1 Thickness] +SymbolLine <X1 Y1 X2 Y1 Thickness> SymbolLine (X1 Y1 X2 Y1 Thickness) @end syntax @@ -1759,6 +1915,14 @@ } ; +umressymbol + /* x1, y1, x2, y2, thickness */ + : T_SYMBOLLINE '<' NUMBER NUMBER NUMBER NUMBER NUMBER '>' + { + CreateNewLineInSymbol(Symbol, $3*UM, $4*UM, $5*UM, $6*UM, $7*UM); + } + ; + /* %start-doc pcbfile Netlist @syntax
Attachment:
WT2022-1.fp
Description: application/pcb-footprint
_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user