diff --git a/README b/README index b785e45..bfd905b 100644 --- a/README +++ b/README @@ -208,7 +208,7 @@ Pads Pads are similar to rectangles, but they also have a name. -pad "" +pad "" [] Variables can be expanded in a pad's name by prefixing their name with a dollar sign. The ${name} syntax is also available. @@ -218,6 +218,16 @@ Example: vec @(1mm, 1mm) pad "1" @ . +Pads normally affect the surface copper layer, the solder mask layer, +and the solder paste layer. This can be modified with the optional +type argument: + +Type Layers +--------- ------------------------------------- +(default) copper, solder mask, and solder paste +bare copper and solder mask +paste solder paste + Rounded pads - - - - - - @@ -226,7 +236,7 @@ Rounded pads are like rectangular pads except that they end with a semi-circle at each of the smaller sides of the enclosing rectangle. If enclosed in a square, rounded pads form a circle. -rpad "" +rpad "" [] Measurements diff --git a/dump.c b/dump.c index 5970500..9abaa86 100644 --- a/dump.c +++ b/dump.c @@ -318,8 +318,22 @@ char *print_obj(const struct obj *obj, const struct vec *prev) break; case ot_pad: s1 = obj_base_name(obj->u.pad.other, prev); - s = stralloc_printf("%spad \"%s\" %s %s", - obj->u.pad.rounded ? "r" : "", obj->u.pad.name, base, s1); + switch (obj->u.pad.type) { + case pt_normal: + s2 = ""; + break; + case pt_bare: + s2 = " bare"; + break; + case pt_paste: + s2 = " paste"; + break; + default: + abort(); + } + s = stralloc_printf("%spad \"%s\" %s %s%s", + obj->u.pad.rounded ? "r" : "", + obj->u.pad.name, base, s1, s2); free(s1); break; case ot_arc: diff --git a/fpd.y b/fpd.y index e79f071..d4cf190 100644 --- a/fpd.y +++ b/fpd.y @@ -13,6 +13,7 @@ #include +#include #include "util.h" #include "error.h" @@ -146,6 +147,7 @@ static struct obj *new_obj(enum obj_type type) struct value *value; struct vec *vec; struct obj *obj; + enum pad_type pt; enum meas_type mt; struct { int inverted; @@ -172,6 +174,7 @@ static struct obj *new_obj(enum obj_type type) %type obj meas %type expr opt_expr add_expr mult_expr unary_expr primary_expr %type opt_string +%type pad_type %type meas_type %type meas_op @@ -441,21 +444,23 @@ base: ; obj: - TOK_PAD STRING base base + TOK_PAD STRING base base pad_type { $$ = new_obj(ot_pad); $$->base = $3; $$->u.pad.name = $2; $$->u.pad.other = $4; $$->u.pad.rounded = 0; + $$->u.pad.type = $5; } - | TOK_RPAD STRING base base + | TOK_RPAD STRING base base pad_type { $$ = new_obj(ot_pad); $$->base = $3; $$->u.pad.name = $2; $$->u.pad.other = $4; $$->u.pad.rounded = 1; + $$->u.pad.type = $5; } | TOK_RECT base base opt_expr { @@ -506,6 +511,18 @@ obj: } ; +pad_type: + ID + { + if (!strcmp($1, "bare")) + $$ = pt_bare; + else if (!strcmp($1, "paste")) + $$ = pt_paste; + else + $$ = pt_normal; + } + ; + measurements: | measurements meas { diff --git a/kicad.c b/kicad.c index f889cea..81b9c83 100644 --- a/kicad.c +++ b/kicad.c @@ -56,6 +56,7 @@ static void kicad_pad(FILE *file, const struct inst *inst) { struct coord min, max; unit_type tmp; + int layers; min.x = units_to_kicad(inst->base.x); min.y = units_to_kicad(inst->base.y); @@ -85,10 +86,21 @@ static void kicad_pad(FILE *file, const struct inst *inst) /* * Attributes: pad type, N, layer mask */ - fprintf(file, "At SMD N %8.8X\n", - (1 << layer_top) | - (1 << layer_paste_top) | - (1 << layer_mask_top)); + layers = 0; + switch (inst->obj->u.pad.type) { + case pt_normal: + layers = 1 << layer_paste_top; + /* fall through */ + case pt_bare: + layers |= (1 << layer_top) | (1 << layer_mask_top); + break; + case pt_paste: + layers = 1 << layer_paste_top; + break; + default: + abort(); + } + fprintf(file, "At SMD N %8.8X\n", layers); /* * Position: Xpos, Ypos diff --git a/obj.h b/obj.h index 164a696..b838c28 100644 --- a/obj.h +++ b/obj.h @@ -139,6 +139,12 @@ enum obj_type { ot_meas, }; +enum pad_type { + pt_normal, /* copper and solder mask */ + pt_bare, /* only copper (and finish) */ + pt_paste, /* only solder paste */ +}; + struct frame_ref { struct frame *ref; int lineno; @@ -153,6 +159,7 @@ struct pad { char *name; struct vec *other; /* NULL if frame origin */ int rounded; + enum pad_type type; }; struct arc { diff --git a/postscript.c b/postscript.c index 85617e9..8fa0f24 100644 --- a/postscript.c +++ b/postscript.c @@ -172,6 +172,20 @@ static void ps_pad_name(FILE *file, const struct inst *inst) inst->u.pad.name, PS_FONT_OUTLINE); } +static const char *hatch(enum pad_type type) +{ + switch (type) { + case pt_normal: + return "crosspath"; + case pt_bare: + return "hatchpath"; + case pt_paste: + return "backhatchpath"; + default: + abort(); + } +} + static void ps_pad(FILE *file, const struct inst *inst, int show_name) { @@ -183,7 +197,8 @@ static void ps_pad(FILE *file, const struct inst *inst, int show_name) fprintf(file, " %d %d lineto\n", b.x, a.y); fprintf(file, " %d %d lineto\n", b.x, b.y); fprintf(file, " %d %d lineto\n", a.x, b.y); - fprintf(file, " closepath gsave crosspath grestore stroke\n"); + fprintf(file, " closepath gsave %s grestore stroke\n", + hatch(inst->obj->u.pad.type)); if (show_name) ps_pad_name(file, inst); @@ -213,7 +228,8 @@ static void ps_rpad(FILE *file, const struct inst *inst, int show_name) fprintf(file, " %d %d lineto\n", a.x+r, b.y); fprintf(file, " %d %d %d 90 270 arc\n", a.x+r, a.y+r, r); } - fprintf(file, " closepath gsave hatchpath grestore stroke\n"); + fprintf(file, " closepath gsave %s grestore stroke\n", + hatch(inst->obj->u.pad.type)); if (show_name) ps_pad_name(file, inst);